locked
2011 Customer Portal RTM - issue with xrm.cs generated from CrmSvcUtil RRS feed

  • Question

  • I have the customer portal up and running fine out of the box. However we have some custom entities we also would like to use, so I generated the updated xrm.cs file using the CrmSvcUtil. After I remove the original xrm.cs and add in the new one, I get all sorts of build errors. Looking at the original xrm.cs and the new xrm.cs file side by side I see numerous differences in the same classes. It seems like the new xrm.cs file adds a bunch of extra stuff and leaves out some stuff.

    Here are a couple of the build errors:

    • Error 10 Operator '==' cannot be applied to operands of type 'Xrm.ServiceAppointmentState?' and 'int' C:\Users\rob.mensing\Documents\Visual Studio 2010\Projects\CustomerPortal\Web\Pages\eService\ViewScheduledServices.aspx.cs 29 125 CustomerPortal
    • Error 11 'Microsoft.Xrm.Sdk.OptionSetValue' does not contain a definition for 'GetValueOrDefault' and no extension method 'GetValueOrDefault' accepting a first argument of type 'Microsoft.Xrm.Sdk.OptionSetValue' could be found (are you missing a using directive or an assembly reference?) C:\Users\rob.mensing\Documents\Visual Studio 2010\Projects\CustomerPortal\Web\Controls\EventCalendar.ascx.cs 33 27 CustomerPortal
    • Error 12 Cannot implicitly convert type 'int' to 'Microsoft.Xrm.Sdk.OptionSetValue' C:\Users\rob.mensing\Documents\Visual Studio 2010\Projects\CustomerPortal\Web\Pages\eService\CreateCase.aspx.cs 35 20 CustomerPortal

    Within the xrm.cs file I notice the classes are setup differently. Here is an example:

    Original xrm.cs file
    /// <summary>
     /// Business that represents a customer or potential customer. The company that is billed in business transactions.
     /// </summary>
     [System.Runtime.Serialization.DataContractAttribute()]
     [Microsoft.Xrm.Sdk.Client.EntityLogicalNameAttribute("account")]
     [System.Data.Services.Common.DataServiceKeyAttribute("Id")]
     [System.Data.Services.IgnorePropertiesAttribute("Item", "Attributes", "EntityState", "FormattedValues", "RelatedEntities", "ExtensionData")]
     [Microsoft.Xrm.Client.Metadata.EntityAttribute("AccountSet")]
     [System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "1.0.0.0")]
     public partial class Account : Microsoft.Xrm.Client.CrmEntity
     {

    New xrm.cs file for the same class
    /// <summary>
     /// Business that represents a customer or potential customer. The company that is billed in business transactions.
     /// </summary>
     [System.Runtime.Serialization.DataContractAttribute()]
     [Microsoft.Xrm.Sdk.Client.EntityLogicalNameAttribute("account")]
     [System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "5.0.9688.42")]
     public partial class Account : Microsoft.Xrm.Sdk.Entity, System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged
     {

    I can't figure out why the code is so different and why I am getting all these errors now. Has anyone successfully got their custom generated xrm.cs file to work nicely with the 2011 Customer Portal?

    Thanks! 

    Wednesday, February 23, 2011 9:40 PM

Answers

  • Can you try using the PortalGen.exe tool that is part of the Customer Portal and Partner Portal technical previews? Until the final version of the portals is released, we need to use PortalGen to generate custom xrm.cs.

    Please let us know if PortalGen resolves these issues.

    Thanks
    - Palak

    • Marked as answer by rmensing Thursday, February 24, 2011 10:12 PM
    Wednesday, February 23, 2011 11:17 PM

All replies

  • Can you try using the PortalGen.exe tool that is part of the Customer Portal and Partner Portal technical previews? Until the final version of the portals is released, we need to use PortalGen to generate custom xrm.cs.

    Please let us know if PortalGen resolves these issues.

    Thanks
    - Palak

    • Marked as answer by rmensing Thursday, February 24, 2011 10:12 PM
    Wednesday, February 23, 2011 11:17 PM
  • Thanks Palak. I gave that a shot, but get the following error below. Any idea what it is referring to?

    C:\Users\rob.mensing\Documents\Visual Studio 2010\Projects\Utilities>PortalGen.e
    xe /out:Xrm.cs /url:https://<mysite>.crm.dynamics.com/XRMServices/2011/Organiza
    tion.svc /username:<LiveID> /password:<LiveIDPassword> /namespace:Xrm /s
    erviceContextName:XrmServiceContext
    PortalGen : xRM Portal Code Generation Utility [Version 1.0.0.0]
    Copyright c Microsoft 2011


    Exiting program with exception: The length of the data should be a multiple of 1
    6 bytes.
    Enable tracing and view the trace files for more information.

    Thursday, February 24, 2011 6:35 PM
  • Ok, got it to work now using the PortalGen tool. Thank you!!
    Thursday, February 24, 2011 10:12 PM
  • Is this still the case with the current customer portal? I am having similar issues using the most recent SDK code to generate the Xrm.cs and do not see where to get PortalGen. For details see this post: http://social.microsoft.com/Forums/eu/crmlabs/thread/47f6b21a-53af-4a51-b117-e2a6f7d713fc
    Stephen V Noe, CRM MCT
    Wednesday, March 16, 2011 3:40 PM
  • Try generating it with following command .. 

     

    CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:Xrm.cs /url:http://<crmserver>/<crm-org>/XRMServices/2011/Organization.svc /domain:<domain> /username:<admin> /password:<password> /namespace:Xrm /serviceContextName:XrmServiceContext /serviceContextPrefix:Xrm

     

     

    Friday, May 20, 2011 7:24 AM
  • Hi i generated Xrm.cs from following command 

    CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:Xrm.cs /url:http://<crmserver>/<crm-org>/XRMServices/2011/Organization.svc /domain:<domain> /username:<admin> /password:<password> /namespace:Xrm /serviceContextName:XrmServiceContext /serviceContextPrefix:Xrm

     

    Everything seems to be working fine except Website content edit functionality .... i am getting an error while editing contents from portal . 

    any help ??

     

    how to get the portalgen tool ??

     

    Wednesday, June 29, 2011 11:23 AM
  • 'PortalGen' was the name of the code-gen tool that we had in early betas.  When the product team made CrmSvcUtil extensible, we retired the use of a standalone utility and now use the /codeCustomization switch with a custom assembly.  The end result is the same - the tool simply outputs code that you can use in your project.

    As for problem with CMS editing, there can be many contributing problems.  The easiest thing would be to use either IE 9 developer toolbar, firebug on firefox, or even fiddler with older versions of IE.  Look for the http GET request to /Services/cms.svc.  The error will be in the response to that request and will likely point you to the solution.  If it isn't immediately obvious, please update this thread with the error and I will be happy to help.


    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com
    Friday, July 1, 2011 12:26 AM
    Moderator
  • Hi Deepak,

    I experienced the same exact problem as you because myself run the CrmSvcUtil.exe same.

    As shan suggested that,i used fiddler and find that "Xrm.XrmCmsDataService, Xrm" could not found.

    Then identified that Xrm.cs does not have  type definitions related to "CMS" because you missed the attribute "/serviceContextPrefix:Xrm"
    these type definations require serviceContextPrefix value.

    This is the complete command you can find at "CustomerPortal.exe\CustomerPortal\CrmSvcUtil.cmd"

    $0\..\..\Microsoft.Xrm\bin\CrmSvcUtil /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:Xrm\Xrm.cs /url:http://Crm/Contoso/XRMServices/2011/Organization.svc /domain:CONTOSO /username:administrator /password:pass@word1 /namespace:Xrm /serviceContextName:XrmServiceContext /serviceContextPrefix:Xrm

    Thanks to Shan for help.

    happy coding,

    P V Y MAHESWAR.



    Monday, July 4, 2011 5:07 AM
  • Thanks Everyone 

     

    Its working fine now .

    Monday, July 4, 2011 8:34 AM
  • I noticed in your earlier post that you did include the namespace, serviceContextName, and serviceContextPrefix command line arguments.  So do you know what it was that made it work for you this time?
    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com
    Tuesday, July 5, 2011 11:21 PM
    Moderator
  • Hi Shan, 

    Unfortunately I am not quite sure exactly what changes i made ... but when i re-generated XRM.CS and rebuild my project it worked fine ..

     

    Wednesday, July 6, 2011 4:43 AM
  • Its because you are not only wrongly generated xrm.cs.

    But also maybe missing references in XRM project- just add them manualy and rebuild...

    Go to XRM - references and add the 3 that are corrupted : Microsoft.xrm.client, Microsoft.xrm.portal and Microsoft.xrm.sdk

    for online the right command is:

    CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /url:https://XXX.api.crm4.dynamics.com/XRMServices/2011/Organization.svc /out:xrm.cs /username:"name" /password:"pass"  /namespace:Xrm  /serviceContextName:XrmServiceContext  /serviceContextPrefix:Xrm

     


    Saturday, November 26, 2011 8:27 AM
  • For me, it turned out I had ommitted the serviceContextPrefix command line argument. Once I added that back in, the edit started working again. I have to make a bat file or command to keep it straght for the portal as it is often a long time between work on it.
    Stephen V Noe, CRM MCT
    Wednesday, December 28, 2011 11:56 AM