crm 2011: missing microsoft.xrm.client.dll on server/bin
-
2 พฤศจิกายน 2554 11:25
Hi All,
In a custom workflow that i'm currently working on, i'm using the following code for cloning an entity
CustEntity sr = Crm.CustEntitySet.Where(s => s.Id == SearchRequestId).First(); Entity e = EntityExtensions.Clone(sr, false); e.Id = Guid.NewGuid(); e.EntityState = null; Id = Crm.Create(e); Crm.SaveChanges();
the process uses the dll mentioned in the subject line. the process compiles and is registered to the server. however when i run the code the workflow keeps on staying on waiting stage and the comes up with an error similar to this,
Workflow paused due to error: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. at CRMSync.CRMSync.Execute(CodeActivityContext executionContext) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
i looked in the server/bin directory and found out that the dll in question is missing.
I have used code similar to this in a third party web application before. the dll came in the sdk pack for crm 2011. and i presume since the third party web application is running using its own set of dlls and xrm.client is one of them, the application is running without any error.
i checked the other instances of the CRM in the organization i work in and found out that this dll is not present in any of them.
is there any patch update on CRM 2011 which solves this issue? and any ideas of how can i get around to this problem will be much appreciated.
thanks in advance
im
ตอบทั้งหมด
-
2 พฤศจิกายน 2554 12:13
I have had DLL problems with other libraries before, where it worked locally under debugging, but failed due to DLL dependencies when deployed. I have always been able to resolve it by statically referencing the DLL and bypassing the GAC (if applicable).
Add a reference to microsoft.xrm.client.dll in your solution. In solution explorer, navigate to that reference, go to Properties for it and change Copy to Output Directory to Copy Always. Then, build as usual and it will deploy the file to the BIN directory.
Ben, MCPD & Technology Solutions Manager at eImagine Technology Group, Inc. Think. Connect. Deliver.- เสนอเป็นคำตอบโดย Ben Klopfer 2 พฤศจิกายน 2554 12:23
-
12 มีนาคม 2555 10:47im197, have you resolved your problem with FileNofFoundException for microsoft.xrm.client.dll when executing workflow?
Can you tell me solution? -
13 มีนาคม 2555 3:04
Microsoft.Xrm.Client.dll is not installed as a component of the CRM Server, nor is it intended to be. As it is purely a client-access assembly, you are responsible for its distribution.
To use it from within a plugin/custom workflow assembly, you can either:
- Copy onto the Server(s) yourself
- Use ILMerge to merge Microsoft.Xrm.Client and any other dependent assemblies into a single self-contained plugin assembly
The latter can be done by adding a Post-Build step to your plugin project, similar to the following:
ilmerge.exe /targetplatform:v4,"C:\Windows\Microsoft.NET\Framework\v4.0.30319" /keyfile:"..\..\PluginKey.snk" /out:$(TargetName).Merged.dll $(TargetFileName) Microsoft.Xrm.Client.dll
The targetplatform switch will ensure ILMerge compiles against the .NET v4.0 Framework. The /keyfile switch ensures that the resultant assembly is still signed. You can add as many assembly names to this statement as you like. Each will be compiled into the output assembly.
--pogo (pat) @ pogo69.wordpress.com
-
25 เมษายน 2555 18:47
Pogo,
I am trying to write a plug-in for CRM 2011 and saw your post.
I followed your instructions by adding an ilmerge post-Build step.
ilmerge.exe /targetplatform:v4,"C:\Windows\Microsoft.NET\Framework\v4.0.30319" /keyfile:"..\..\ContactIDPlugin.snk" /out:$ContactIDPlugin.Merged.dll $ContactIDPlugin Microsoft.Xrm.Client.dll
When I tried to Build the solution, it failed with: "exited with code 9009".
Some research suggested I should
1) check for embedded spaces: I did, but the path was already in quotes.
2) precede the ilmerge with
call "$(DevEnvDir)..\Tools\vsvars32.bat"
Silly question: is the (DevEnvDir) a literal or do I substitute an actual value? I tried:
call "$C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat" but the Build failed with the same error code.
Any advice?
Thank you.
-
26 เมษายน 2555 22:33
You don't need the:
"$(DevEnvDir)..\Tools\vsvars32.bat"
The issue is with your mixing the $ which signifies the beginning of a Build Event macro, with a string literal for the name(s) of the assemblies. In my original example, I was using macros to signify the name of the assemblies as they are built by Visual Studio - this way you do not have to specify the actual name of the assemblies and the code will continue to work should you ever choose to rename them.
You will either need to put your post-build event code back the way I demonstrated:
ilmerge.exe /targetplatform:v4,"C:\Windows\Microsoft.NET\Framework\v4.0.30319" /keyfile:"..\..\ContactIDPlugin.snk" /out:$(TargetName).Merged.dll $(TargetFileName) Microsoft.Xrm.Client.dll
or if you really do want to hard-code the assembly names, alter your version to:
ilmerge.exe /targetplatform:v4,"C:\Windows\Microsoft.NET\Framework\v4.0.30319" /keyfile:"..\..\ContactIDPlugin.snk" /out:ContactIDPlugin.Merged.dll ContactIDPlugin.dll Microsoft.Xrm.Client.dll
--pogo (pat) @ pogo69.wordpress.com
-
2 พฤษภาคม 2555 13:57
Thanks for responding, Pogo, and sorry for the delay in getting back to you.
I tried your post-build event but the Build failed with 'The command "ilmerge.exe.... Microsoft.Xrm.Client.dll" exited with code 9009'
Then I tried the version with the hard-coded assembly names and the Build failed with the same message.
Can you help? Thank you again.
-
2 พฤษภาคม 2555 23:05
9009 is a path/file not found issue.
Is ilmerge in your path? In case it is not, try:
"C:\Program Files (x86)\Microsoft\ILMerge\ilmerge.exe" /targetplatform:v4,"C:\Windows\Microsoft.NET\Framework\v4.0.30319" /keyfile:"..\..\ContactIDPlugin.snk" /out:$(TargetName).Merged.dll $(TargetFileName) Microsoft.Xrm.Client.dll
Also; given that I did not explicitly mention the need. Have you installed ilmerge? It is not installed by default as part of Visual Studio, the OS or the .NET Framework.
http://www.microsoft.com/en-us/download/details.aspx?id=17630
--pogo (pat) @ pogo69.wordpress.com
-
3 พฤษภาคม 2555 14:33
Yes, I had installed ilmerge, and it is at C:\Program Files\Microsoft\ILMerge, but thanks for noting that possibility.
I added your code exactly as written, above, to the post-Build event command line and got:
"The command............. exited with code 3"
I also tried:
"C:\Program Files\Microsoft\ILMerge\ilmerge.exe" /targetplatform:v4,"C:\Windows\Microsoft.NET\Framework\v4.0.30319" /keyfile:"..\..\ContactIDPlugin.snk" /out:$(TargetName).Merged.dll $(TargetFileName) Microsoft.Xrm.Client.dll
This Build failed with "exited with code 1". What's a code 1 and where can I find these Buid codes?
I also checked to make sure C:\Windows\Microsoft.NET\Framework\v4.0.30319 was a valid path and it is.
I also tried hardcoding the TargetNames and then also giving the full path for Microsoft.Xrm.Client.dll in the bin, but nothing works.
-
3 พฤษภาคม 2555 23:50
I found the 9009 exit code by Googling. No idea where the definitive list lives.
Try to elicit more verbose output by changing the following to Verbose:
--pogo (pat) @ pogo69.wordpress.com
-
4 พฤษภาคม 2555 13:52
Great idea, Pogo.... except it didn't work. I am still receiving the same "9009" message as I started with, with no new detail. I tried specifying ilmerge.exe both with and without its full path. In the former case, exit with code 1, in the latter case, exit with code 9009. So, if 9009 is path not found, I will stick with specifying the full path. I have now tried every combination of fullpath and hardcoding the assembly names, and the result is still "exited with code 1".
I also tried making the bin not read-only per a post I saw on another forum. No change.
If I double-click on the error message I am brought to a file called "Microsoft.Common.targets", the line which begins "<Exec", see below:
<Target Name="PostBuildEvent" Condition="'$(PostBuildEvent)' != '' and ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or '$(_AssemblyTimestampBeforeCompile)' != '$(_AssemblyTimestampAfterCompile)')" DependsOnTargets="$(PostBuildEventDependsOn)"> <Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" /> </Target>
- แก้ไขโดย MeProgrammer 4 พฤษภาคม 2555 14:06
-
4 พฤษภาคม 2555 20:30
The 9009 is most definitely a path not found (or variation thereof) error, borne out by the fact that you must specify the full path. The alternative is to ensure that ilmerge.exe is in your environment path (I must have done this, but I forget WAY more than I remember).
I don't know what the exit code 1 or 3 mean, so I'm not sure what to suggest. Although; I would probably try to run the ilmerge statement on the command line, outside of Visual Studio - obviously you will have to supply real assembly names instead of the macro variables but at least a) it will allow you to get the merge done or b) highlight if there is an issue outside of the VS/ilmerge interface.
--pogo (pat) @ pogo69.wordpress.com
-
7 พฤษภาคม 2555 13:25
I ran the ilmerge in an Administrator Command Prompt, with all files fully qualified.
It errored with:
An exception ocurred during merging:
Unresolved assembly reference not allowed: Presentation FrameworkA search on that exact error text turned up nothing, although there were plenty of merging errors documented, with "Unresolved assembly reference not allowed"
Would anyone know what exactly do I need to add to the merge to resolve this error?
-
7 พฤษภาคม 2555 13:54
Since you are talking about CRM custom workflow activity, I assume that you are working with CRM on-premise. In this case, have you tried to put the assembly in GAC on the server?
This may not be what you are looking for, but it is a quick way to solve your problem.
Daniel Cai | http://danielcai.blogspot.com | @danielwcai | Data Integration made easy with SSIS Integration Toolkit
-
7 พฤษภาคม 2555 14:03
Update:
I found the following posting on: http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx
"ILMerge is not able to merge WPF assemblies. They contain resources with encoded assembly identities. ILMerge is unable to deserialize the resources, modify the assembly identities, and then re-serialize them. Sorry!"
There are some suggested work-arounds at http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx?PageIndex=3#comments
However, my program Output type is a Class Library. It is designed as a plug-in for Dynamics CRM 2011. I don't believe I am doing anything unusual (the plug-in merely copies one field to another) and I know plug-ins are fairly standard customizations for CRM. Although my program is written in C#, I am not fluent in that language.
Poster ".Net Lover" wrote in the jeffrey richter blog:
"Great article.. saved my time..Note if you are using it in a class library just call the assembly resolve in the default constructor.." but I don't know how to do that.
-
25 พฤษภาคม 2555 17:16
For anyone who is interested: The problem I documented above has been resolved.
The SDK's instructions for creating a plug-in use the /codeCustomization option of utility crmscvutil. This option requires Microsoft.Xrm.Client.dll. Based on something I found on another thread, I removed that option and re-created the Xrm.cs file. I had to juggle some namespaces but when I rebuilt the solution and then re-registered it with the Plugin Registration Tool, it worked exactly as planned.
I did not need ILmerge.
-
18 มกราคม 2556 15:08
Hi MeProgrammer,
Have you registered the dll in GAC. If you would have registered in GAC you do not need to ILMERGE.
But the solid solution is ILMERGE the dll with plugin dll.
Sreeni Pavalla