locked
Visual Studio deployment issue? RRS feed

  • Question

  •  

    We're testing a simple customization using CRM.  Our web project solution consists of one ASPX page that connects to the CRMService web service and creates a new Contact during the Page_Load event (please see below).  Also, we're opening this page from a custom button we've added by importing a modified ISV.Config file.

     

    Testing the custom logic works perfectly from the Visual Studio web solution.  However, after deploying this solution (straight XCopy into ISV folder) we're seeing the following error in the Event Viewer after pressing the custom button:

     

    The type or namespace name 'wrCRMService' could not be found (are you missing a using directive or an assembly reference?)

     

    wrCRMService is the name we gave to the CRMService web service and this error is occuring at the point we combine it with the USING clause.  For some reason, our standalone project is fine but when this page is called via the CRM button this error is being raised. 


    Thanks in advance

     

     

    Here is our ASPX.cs code...

     

    Code Snippet

    using System;

    using System.Configuration;

    using System.Data;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.HtmlControls;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

     

    using wrCRMService; //CRM Web service - THIS IS WHERE THE ERROR IS OCCURING IN CRM

    using Microsoft.Crm.Sdk.Utility; //CRM SDK Helper class

     

    public partial class _Default : System.Web.UI.Page

    {

    string _hostname = "localhost";string _port = "5555";

    string _organizationName = "MicrosoftCRM";

    protected void Page_Load(object sender, EventArgs e)

    {

    string sURL = String.Format("http://" + _hostname + ":" + _port + "/mscrmservices/2007/crmservice.asmx");

    CrmService prService = CrmServiceUtility.GetCrmService(_organizationName);

     

    // Create the contact object and its the properties

    contact contact = new contact();

    contact.firstname = "Jesper";

    contact.lastname = "Aaberg";

    contact.address1_line1 = "23 Market St.";

    contact.address1_city = "Sammamish";

    contact.address1_stateorprovince = "MT";

    contact.address1_postalcode = "99999";

    contact.donotbulkemail = new CrmBoolean();

    contact.donotbulkemail.Value = true;

     

    // Create the contact in Microsoft Dynamics CRM.

    Guid contactGuid = prService.Create(contact);

    }

     

    }

     

     

    Monday, June 23, 2008 7:24 AM

Answers

  • We figured out the issue.  After copying our solution files into a subfolder in the ISV folder we had to make it an application from within IIS.  The SDK never mentioned this so it might be an oversight on their part as this is their description in the "ISV Extensibility Best Practices" section:

    Where Should You Put Custom Code?

    You should use the following guidelines for your custom code:

    • Create a subfolder in the <serverroot>\ISV folder and put your ASPX files there.
    • Use a Microsoft Visual Studio Web Deployment project to separate your ASPX files from your DLLs.
    • Place your DLLs in the <installdir>\Server\bin\assembly folder.
    • Use the registry for any settings you require.

    We then encountered the following errors:

    1) PublicKeyToken=31bf3856ad364e35' doesn't exist

    2) Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive...

     

     

    The first error was handled by adding either of the following HTTPModule sections to our applications web.config:

     

    <httpModules>

          <remove name ="CrmAuthentication" /> 
    </httpModules>

     

    or


    <httpModules>
         <clear/>
    </httpModules>

     

    More information on this error can be found here - http://mscrmuk.blogspot.com/2008/01/crm-40-error-with-isv-pages.html

     

     

    The second error was occuring because we were referencing a Session object in our ASPX page.  It was resolved by:

    -Adding EnableSessionState="true" to the Page directive in our ASPX page

    -Added the following to our Web.Config file

    <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"/>

     

    I hope this helps anyone who has the same issue.

    Thursday, June 26, 2008 5:55 PM

All replies

  • update web reference

    Inside the CRM UI, if you go to settings and then customization you should see a option to download the Web Services WSDL. Is in the same place where the options for import/export customizations are.

     

    The redirection to CrmServicewsdl.aspx is normal, in version 4 that's the web page that generates the WSDL for CrmWebService. The odd thing is that it shouldn't show that message in Visual Studio in the description area.

    http://localhost:5555/MSCRMServices/2007/CrmServiceWsdl.aspx

     

    Try to navigate with the IE to that address and see if it produces the WSDL. Do you have more than one org? In that case you should use include the name like in this example http://moss:5555/MSCrmServices/2007/CrmServiceWsdl.aspx?uniquename=OrganizationName

     

    Let me know your findings.

     

    Regards,

    Imran

     

    http://microsoftcrm3.blogspot.com

     

    msn : mscrmexpert@gmail.com

     

     

    Monday, June 23, 2008 4:59 PM
    Moderator
  •  

    Thank you, Imran.  A couple of things:

     

    -I'm using the CRM 4 Virtual Machine VHD from Microsoft and they only have one organization.

    -The web service is working correctly and I can navigate to http://localhost:5555/MSCRMServices/2007/CrmServiceWsdl.aspx

    -The web reference has been added to Visual Studio 2008 (I named it wrCRMService) and the web solution compiles and runs without error.

    -For deployment, all I did was copy this entire solution into a "TestSol" folder in the "ISV" folder.

    -The error I'm seeing isn't from within Visual Studio it's actually from the Event Viewer after I try an open this ASPX page via a custom button in CRM.  Here's the custom "button code" that I added to the ISV.confg:

     

    <Entity name="contact">

    <ToolBar ValidForCreate="0" ValidForUpdate="1">

    <Button Icon="/_imgs/ico_16_1071.gif" Url="/ISV/TestSol/AddContact.aspx" PassParams="1" WinParams="height =305,width=445, top=100, left=100" WinMode="0">

    <Titles>

    <Title LCID="1033" Text="Add Contact" />

    </Titles>

    <ToolTips>

    <ToolTip LCID="1033" Text="Add New Contact" />

    </ToolTips>

    </Button>

    </ToolBar>

    </Entity>

     

    For some reason, when CRM tries to open AddContact.aspx, my "USING wrCRMService;" statement is causing the compilation error.  It's almost like it can't find the web reference information at TestSol\App_WebReferences\wrCRMService?

     

    Thank you

     

    Monday, June 23, 2008 6:57 PM
  • check your right webrefernce, its normally wrong webreference / url access error.

     

    Regards,

    Imran

     

    http://microsoftcrm3.blogspot.com

     

    msn : mscrmexpert@gmail.com

     

     

    Tuesday, June 24, 2008 5:17 PM
    Moderator
  • We figured out the issue.  After copying our solution files into a subfolder in the ISV folder we had to make it an application from within IIS.  The SDK never mentioned this so it might be an oversight on their part as this is their description in the "ISV Extensibility Best Practices" section:

    Where Should You Put Custom Code?

    You should use the following guidelines for your custom code:

    • Create a subfolder in the <serverroot>\ISV folder and put your ASPX files there.
    • Use a Microsoft Visual Studio Web Deployment project to separate your ASPX files from your DLLs.
    • Place your DLLs in the <installdir>\Server\bin\assembly folder.
    • Use the registry for any settings you require.

    We then encountered the following errors:

    1) PublicKeyToken=31bf3856ad364e35' doesn't exist

    2) Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive...

     

     

    The first error was handled by adding either of the following HTTPModule sections to our applications web.config:

     

    <httpModules>

          <remove name ="CrmAuthentication" /> 
    </httpModules>

     

    or


    <httpModules>
         <clear/>
    </httpModules>

     

    More information on this error can be found here - http://mscrmuk.blogspot.com/2008/01/crm-40-error-with-isv-pages.html

     

     

    The second error was occuring because we were referencing a Session object in our ASPX page.  It was resolved by:

    -Adding EnableSessionState="true" to the Page directive in our ASPX page

    -Added the following to our Web.Config file

    <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"/>

     

    I hope this helps anyone who has the same issue.

    Thursday, June 26, 2008 5:55 PM