Custom Code :Microsoft Dynamics CRM Web Services

Answered Custom Code :Microsoft Dynamics CRM Web Services

  • 4. června 2009 3:24
     
     
    step 1: Place your .aspx files in the <crmwebroot >\ISV\<myapp > folder.
    step 2:Place your assemblies in <crmwebroot >\ISV\<myapp >\bin (If you have installed Update Rollup 2)
    When I open the browser to Custom Web Services. (http:// xxxx /isv/<myapp>/myapp.aspx)
    I get a error page.
    How to fix it??

Všechny reakce

  • 4. června 2009 5:35
    Moderátor
     
     
    Hi.

    Could you paste here your web.config file?
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
  • 4. června 2009 5:46
     
     
    Is web.config content need copy to <crmwebroot >\web.config ??

    web.config ( <crmwebroot >\ISV\<myapp >\web.config)<?xml version="1.0"?>
    <configuration>
        <appSettings>
        <add key="CrmSDK.CrmServiceWsdl" value="http://.../MSCrmServices/2007/CrmService.asmx"/>
        </appSettings>
        <connectionStrings>
      <add name="AccessConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\...\.....mdb;Persist Security Info=True;Password=...;User ID=...;Jet OLEDB:System database=d:\....\....mdw;Jet OLEDB:Database Password=..."
       providerName="System.Data.OleDb" />
      <add name="CRMConnectionString" connectionString="Data Source=.;Initial Catalog=....._MSCRM;Persist Security Info=True;User ID=....;Password=...."
       providerName="System.Data.SqlClient" />
     </connectionStrings>
        <system.web>

            <compilation debug="true" strict="false" explicit="true">
            </compilation>
            <pages>
                <namespaces>
                    <clear/>
                    <add namespace="System"/>
                    <add namespace="System.Collections"/>
                    <add namespace="System.Collections.Specialized"/>
                    <add namespace="System.Configuration"/>
                    <add namespace="System.Text"/>
                    <add namespace="System.Text.RegularExpressions"/>
                    <add namespace="System.Web"/>
                    <add namespace="System.Web.Caching"/>
                    <add namespace="System.Web.SessionState"/>
                    <add namespace="System.Web.Security"/>
                    <add namespace="System.Web.Profile"/>
                    <add namespace="System.Web.UI"/>
                    <add namespace="System.Web.UI.WebControls"/>
                    <add namespace="System.Web.UI.WebControls.WebParts"/>
                    <add namespace="System.Web.UI.HtmlControls"/>
                </namespaces>
            </pages>
            <!--
                <authentication>
            -->
            <authentication mode="Windows"/>
            <!--
                <customErrors>
            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
        </system.web>
    </configuration>
  • 4. června 2009 6:04
     
     

    Please have a read of the Custom Code Best Practices at the URL below.
    http://msdn.microsoft.com/en-us/library/dd548493.aspx

    You will not need the web.config file. If you have a any parameters the recommendation is that they should be read from the registry.

    Hassan.

    Hassan Hussain | http://hassanhussain.wordpress.com/
  • 4. června 2009 6:19
    Moderátor
     
     Odpovědět Obsahuje kód
    Hi.

    <authentication mode="Windows"/>  - this code must be commented or deleted
    <identity impersonate="true"/> - this code must be added.

    Also you have to add following lines to your web.config:

            <httpModules>
                <add name="MapOrg" type="Microsoft.Crm.MapOrgEngine, Microsoft.Crm, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
                <add name="CrmAuthentication" type="Microsoft.Crm.Authentication.AuthenticationEngine, Microsoft.Crm, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            </httpModules>

    And for the end my default config for all extension pages i made for CRM:

    <?xml version="1.0"?>
    <configuration>
    	<appSettings>
    	</appSettings>
    	<connectionStrings/>
    	<system.web>
    		<httpModules>
    			<add name="MapOrg" type="Microsoft.Crm.MapOrgEngine, Microsoft.Crm, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    			<add name="CrmAuthentication" type="Microsoft.Crm.Authentication.AuthenticationEngine, Microsoft.Crm, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    		</httpModules>
    		<identity impersonate="true"/>
    		<pages buffer="true" enableSessionState="false" enableViewState="true" validateRequest="false"/>
    		<globalization culture="ru-RU" uiCulture="ru-RU"/>
    		<compilation debug="true" defaultLanguage="c#">
    			<assemblies>
    				<add assembly="Microsoft.Crm.Sdk, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    				<add assembly="Microsoft.Crm.SdkTypeProxy, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    		</compilation>
    	</system.web>
    </configuration>
    

    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
  • 4. června 2009 7:11
     
     
            <httpModules>
                <add name="MapOrg" type="Microsoft.Crm.MapOrgEngine, Microsoft.Crm, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
                <add name="CrmAuthentication" type="Microsoft.Crm.Authentication.AuthenticationEngine, Microsoft.Crm, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            </httpModules>

    How to find this description in CRM SDK?
  • 4. června 2009 7:18
    Moderátor
     
     
    Hi.

    I fount this instructions when I developed my first custom aspx page for CRM (a year ago) so I don't remember where I fount it.

    Another one I forgot - on server with Microsoft CRM put Microsoft.Crm.WebServices.dll to the GAC.
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
  • 4. června 2009 8:06
     
      Obsahuje kód
    In web.config
    append
            <httpModules>
                <add name="MapOrg" type="Microsoft.Crm.MapOrgEngine, Microsoft.Crm, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
                <add name="CrmAuthentication" type="Microsoft.Crm.Authentication.AuthenticationEngine, Microsoft.Crm, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    I got som error:
    [NullReferenceException: 並未將物件參考設定為物件的執行個體]
    Microsoft.Crm.Authentication.WebConfigAuthenticationSettings.LoadWebConfigSettings() +47
    Microsoft.Crm.Authentication.WebConfigAuthenticationSettings..ctor() +37
    Microsoft.Crm.Authentication.WebConfigAuthenticationSettings..cctor() +39

    [TypeInitializationException: 'Microsoft.Crm.Authentication.WebConfigAuthenticationSettings' 的型別初始設定式發生例外狀況。]
    Microsoft.Crm.Authentication.WebConfigAuthenticationSettings.get_Instance() +0
    Microsoft.Crm.ServerLocatorService.IsPathBasedURLsEnabled() +92
    Microsoft.Crm.LocatorService.IsPathBasedURLsEnabled() +34
    Microsoft.Crm.MapOrgEngine.Execute(Object sender, EventArgs e) +77
    System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +216
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +120
  • 4. června 2009 8:12
     
     Odpovědět
    Hi, 

    You seem to be mixing two approaches to deploying the custom code for MS CRM.

    Please either follow the instructions at http://msdn.microsoft.com/en-us/library/dd548493.aspx (Recommended by MS)

    OR

    Create a virutal directory. Put all your code including your project web.config file + Microsoft.Crm.WebServices.dll to the bin of your custom project or GAC + web.config (of your project) changes that Andriy recommended. 

    Hassan.

    Hassan Hussain | http://hassanhussain.wordpress.com/
  • 4. června 2009 8:13
    Moderátor
     
     Odpovědět
    Hi.

    This code part must be added only before deploying your page to the server.
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com