开发者

Deploying a plugin for MS Dynamics CRM - missing assembly

I have followed the steps from this link, and created a plugin: http://msdn.microsoft.com/en-us/library/bb955365.aspx

I have registered it on a Retrieve message for one of my entities, but when it triggers I get this error:

Web Service Plug-in failed in OrganizationId: a2dcffbc-e056-4971-adfb-662979139800; SdkMessageProcessingStepId: 5b6921b8-192e-e011-846c-001d0928c4ac; EntityName: new_csvpr开发者_Python百科oiect; Stage: 50; MessageName: Retrieve; AssemblyName: MSDynCRMPlugin.Plugin, MSDynCRMPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a6a43dc7a3dcc61d; ClassName: MSDynCRMPlugin.Plugin;

Exception: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. at MSDynCRMPlugin.Plugin.Execute(IPluginExecutionContext context) at Microsoft.Crm.Extensibility.PluginStep.Execute(PipelineExecutionContext context)

Any ideas?


Make sure that your plugin project is set to target the .NET 4 framework, NOT The .NET 4 Client Profile framework. With Visual Studio 2010, the default for new projects appears to be .NET 4 Client Profile.

I think that references to System.Web.Services will compile under .NET 4 Client Profile, but will actually fail to execute when you run them.


You'll need to merge outside assemblies into your plugin dll. Here are the instructions you should follow: Using ILMerge with CRM Plugin Assemblies


Use this code:

AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
        {
            String resourceName = "AssemblyLoadingAndReflection." + new AssemblyName(args.Name).Name + ".dll";

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
            {
                Byte[] assemblyData = new Byte[stream.Length];

                stream.Read(assemblyData, 0, assemblyData.Length);

                return Assembly.Load(assemblyData);
            }
        };
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜