locked
latest sdk (5.0.12) the version of microsoft.xrm.client.codegeneration.dll and crmsvcutil are different, cause "The type initializer for 'Microsoft.Xrm.Client.CodeGeneration.CodeCustomization' threw an exception." RRS feed

  • Question

  • I was trying to run the following command using the tool crmsvcutil.exe in latest sdk 5.0.12

    D:\sdk\bin>CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneratio
    n.CodeCustomization,Microsoft.Xrm.Client.CodeGeneration" /url:https://test.ap
    i.crm5.dynamics.com/XRMServices/2011/Organization.svc /username:admin@test.on
    microsoft.com /password:password /deviceid:1z1lbsnvezriqrxm3ed /devicepa
    ssword:#$(rOT;cy/nJs,-_.q/ /out:"XrmWithCC.cs" /namespace:Xrm

    Got following error:

    Exiting program with exception: The type initializer for 'Microsoft.Xrm.Client.C
    odeGeneration.CodeCustomization' threw an exception.
    Enable tracing and view the trace files for more information.

    according to a troubleshooting post: http://msdn.microsoft.com/en-us/library/gg309305.aspx 

    I compared the versions between the file microsoft.xrm.client.codegeneration.dll (5.0.9689.1985) and file crmsvcutil.exe (5.0.9689.2730), they are different.

    I wonder if this is Microsoft problem. Or that's still my environment issue. 


    Weifeng
    Send a mail to Weifeng
    Welcome to CRM QQ Super Group:149371424


    Monday, August 27, 2012 9:06 AM

Answers

  • I have confirmed that there seems to be a small regression bug that has creeped into the latest SDK.  I get the same experience you do when I use the 5.0.12 SDK, but the same command runs fine on previous SDK builds.  For now, I would recommend using the crmsvcutil.exe command from the previous SDK drops until a better resolution is found.  I have notified the SDK team of the problem.

    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com

    • Marked as answer by Weifeng Jiang Thursday, September 13, 2012 7:46 AM
    Thursday, August 30, 2012 6:01 PM
    Moderator
  • one other small note - you don't need the device credentials if you are using the Office 365 version of CRM Online - that is only necessary for the Live ID version.

    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com

    • Marked as answer by Weifeng Jiang Thursday, September 13, 2012 7:46 AM
    Thursday, August 30, 2012 6:01 PM
    Moderator
  • The SDK has been replaced with a new version that addresses this issue.  Please discard the previous version and download it again.


    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com

    • Marked as answer by Weifeng Jiang Thursday, September 13, 2012 7:47 AM
    Monday, September 10, 2012 7:36 PM
    Moderator

All replies

  • Try putting quotes around your device password - it looks like you have lots of special characters in that.

    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com

    Monday, August 27, 2012 5:01 PM
    Moderator
  • still the same issue. 

    Actually, I tried onpremise first, but it didn't work, and I turned to online for another try. still no luck..

    But thanks Shan.


    Weifeng
    Send a mail to Weifeng
    Welcome to CRM QQ Super Group:149371424

    Tuesday, August 28, 2012 1:58 AM
  • still the same issue. 

    Actually, I tried onpremise first, but it didn't work, and I turned to online for another try. still no luck..

    But thanks Shan.

    Same here.

    I have no previous version of CRM SDK installed - I have just installed the 17th August release here: http://www.microsoft.com/en-us/download/details.aspx?id=24004

    When trying to run CrmSvcUtil in the bin\ directory of the SDK, it blows up as stated above. The trace says:

    Exiting program with exception: The type initializer for 'Microsoft.Xrm.Client.CodeGeneration.CodeCustomization' threw an exception.
    Enable tracing and view the trace files for more information.
    CrmSvcUtil.exe Error: 0 : Exiting program with exit code 2 due to exception : System.TypeInitializationException: The type initializer for 'Microsoft.Xrm.Client.CodeGeneration.CodeCustomization' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9689.1985, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
       at Microsoft.Xrm.Client.CodeGeneration.CodeCustomization..cctor()
       --- End of inner exception stack trace ---
       at Microsoft.Xrm.Client.CodeGeneration.CodeCustomization.CustomizeCodeDom(CodeCompileUnit codeUnit, IServiceProvider services)
       at Microsoft.Crm.Services.Utility.CodeGenerationService.WriteFile(String outputFile, String language, CodeNamespace codenamespace, ServiceProvider serviceProvider)
       at Microsoft.Crm.Services.Utility.CodeGenerationService.Microsoft.Crm.Services.Utility.ICodeGenerationService.Write(IOrganizationMetadata organizationMetadata, String language, String outputFile, String outputNamespace, IServiceProvider services)
       at Microsoft.Crm.Services.Utility.CrmSvcUtil.WriteCode(IOrganizationMetadata organizationMetadata)
       at Microsoft.Crm.Services.Utility.CrmSvcUtil.Run()
       at Microsoft.Crm.Services.Utility.CrmSvcUtil.Main(String[] args)

    Checking the versions of DLLs in the directory, it appears to be trying to load Microsoft.Xrm.Client, Version=5.0.9689.1985, but this dll is actually version 5.0.9690.2165

    Rob.

    Thursday, August 30, 2012 4:30 PM
  • I have confirmed that there seems to be a small regression bug that has creeped into the latest SDK.  I get the same experience you do when I use the 5.0.12 SDK, but the same command runs fine on previous SDK builds.  For now, I would recommend using the crmsvcutil.exe command from the previous SDK drops until a better resolution is found.  I have notified the SDK team of the problem.

    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com

    • Marked as answer by Weifeng Jiang Thursday, September 13, 2012 7:46 AM
    Thursday, August 30, 2012 6:01 PM
    Moderator
  • one other small note - you don't need the device credentials if you are using the Office 365 version of CRM Online - that is only necessary for the Live ID version.

    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com

    • Marked as answer by Weifeng Jiang Thursday, September 13, 2012 7:46 AM
    Thursday, August 30, 2012 6:01 PM
    Moderator
  • Thanks for the response,

    Rob.

    Thursday, August 30, 2012 6:03 PM
  • Thank you. 

    Weifeng
    Send a mail to Weifeng
    Welcome to CRM QQ Super Group:149371424

    Friday, August 31, 2012 1:45 AM
  • You don't know where I'd be able to get a previous version of the SDK from do you? Everywhere I look points to the latest version. MSDN subscriber downloads doesn't even have the latest versions (I can't find them when searching), although I can find really, really old versions - I can find CRM 3.0 SDK.
    Friday, August 31, 2012 8:51 AM
  • I had the same problem, re-downloaded the SDK few moments ago, it appears that they have fixed the problem, since it created my file with no problems. 
    Monday, September 3, 2012 6:39 AM
  • I had the same problem, re-downloaded the SDK few moments ago, it appears that they have fixed the problem, since it created my file with no problems. 
    really? but why it's not the case on my side, I just tried it again. still the same issue. Could you please share more information on this?

    Weifeng
    Send a mail to Weifeng
    Welcome to CRM QQ Super Group:149371424

    Monday, September 3, 2012 7:28 AM
  • Interesting, during the weekend I was working on my home computer and had that problem, but this morning I downloaded the SDK on my work computer and it worked, I thought that they had replaced the .dll, but I now see that it's the same version as I had on my home computer. I don't know what the difference could be, as I was using the same CRM server to create early-bound types. 

    My home computer is x64, while my work comp is x86, if it helps. 

    Strange. 

    Monday, September 3, 2012 9:08 AM
  • Is there an ETA on this, or at least a link to a previous version of the SDK?  I am having the same issue.
    Thursday, September 6, 2012 1:49 AM
  • The SDK has been replaced with a new version that addresses this issue.  Please discard the previous version and download it again.


    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com

    • Marked as answer by Weifeng Jiang Thursday, September 13, 2012 7:47 AM
    Monday, September 10, 2012 7:36 PM
    Moderator
  • I just downloaded the SDK at http://www.microsoft.com/en-us/download/details.aspx?id=24004 (5.0.12), dated 9/6/2012 and still get the error. Does someone have another link they know works?
    Monday, September 17, 2012 10:23 PM
  • This version definately works on mine, and I had the problem with the previous release, can you paste up the error and trace?
    Tuesday, September 18, 2012 7:19 AM
  • Hi,

    I know this is a very old post, but still posting it so that this may be useful for others.

    I added Both the files Microsoft.Xrm.Client.dll and Microsoft.Xrm.Client.CodeGeneration.dll  in the  file location <system drive>:\Program Files\Microsoft Dynamics CRM\Tools 

    to fix the below error

    Exiting program with exception: The type initializer for 'Microsoft.Xrm.Client.CodeGeneration.CodeCustomization' threw an exception.
    Enable tracing and view the trace files for more information

    Monday, March 23, 2015 11:26 PM