Monday, 20 June 2011

"Plug-in assembly does not contain the required types or assembly content cannot be updated"-CRM 2011

 Plugin Registration tool used in CRM 2011 may throw some generic error message "Plug-in assembly does not contain the required types or assembly content cannot be updated"
Lets explore how it could happen.



Error Message:


Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Plug-in assembly does not contain the required types or assembly content cannot be updated.
Detail: <OrganizationServiceFault xmlns="
http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <ErrorCode>-2147204725</ErrorCode>
  <ErrorDetails xmlns:a="
http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>Plug-in assembly does not contain the required types or assembly content cannot be updated.</Message>
  <Timestamp>2011-06-20T08:31:56.6192334Z</Timestamp>
  <InnerFault>
    <ErrorCode>-2147204725</ErrorCode>
    <ErrorDetails xmlns:a="
http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
    <Message>Plug-in assembly does not contain the required types or assembly content cannot be updated.</Message>
    <Timestamp>2011-06-20T08:31:56.6192334Z</Timestamp>
    <InnerFault i:nil="true" />
    <TraceText i:nil="true" />
  </InnerFault>
  <TraceText i:nil="true" />
</OrganizationServiceFault>
Server stack trace:
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Xrm.Sdk.IOrganizationService.Update(Entity entity)
   at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.UpdateCore(Entity entity)
   at PluginRegistrationTool.RegistrationHelper.UpdateAssembly(CrmOrganization org, String pathToAssembly, CrmPluginAssembly assembly) in C:\Users\Administrator\Desktop\CRMTools\CrmSDK2011\tools\pluginregistration\RegistrationHelper.cs:line 427
   at PluginRegistrationTool.PluginRegistrationForm.btnRegister_Click(Object sender, EventArgs e) in C:\Users\Administrator\Desktop\CRMTools\CrmSDK2011\tools\pluginregistration\PluginRegistrationForm.cs:line 371

When you are trying to update the plugin using Plugin registration tool in CRM 2011, then you might get this error if there are some mismatches between old assembly and new assembly.

Consider a scenario:

2 Developers John & Harry are working in the same project. They are retaining their source code in a version control. They have maintained one common dll for the plugin assembly using IL Merge to avoid dependency issues. ( How to use IL Merge Refer: http://crmdm.blogspot.com/2011/02/crm-cannot-find-plugin-assembly-or-one.html ) . Imagine there are a total number of 10 plugins already in the project. Now John develops a plugin and he updates the plugin assembly with his plugin. But he forgets to check in the source code of new plugin in the version control. Next day Harry would like to develop a plugin. He checks out latest source code(but John's plugin missing) from the version control and starts developing his plugin. When Harry tries to update the plugin assembly he would see the above error message. Harry must get the right previous version of plugin dll ( which includes John's plugin) because the last version in the assembly contains John's plugin. In simple words, when Harry tries to update the plugin assembly in CRM 2011, his dll should have required types or assembly content. This is a sample case of mismatch.

So if you get this error message just think of the possibilities of mismatch and then you could easily resolve it.


 

6 comments:

  1. Hi,
    I have registered a plug-in in Disk deployment mode and it was working fine. Then I did some changes in plug-in code and tried to register plug-in in Database mode. For that I have merged all the referred dlls into a single DLL. Now I am trying to re-register the new merged assembly(not updating the old assembly) and I am getting this issue. Any idea on this ?
    Thanks in advance.

    ReplyDelete
  2. I have a plugin DLL and a component DLL.I have tried to merge all my refered DLLs and plugincomponent DLL into one DLL. And the resulting DLL I have merged with my actual plugin DLL. Now with this new DLL I can register the plugin in DB mode. But when i am updating a contact in crm, it is giving the error "Could not load file or assembly 'PluginComponent' or one of its dependencies".............

    ReplyDelete
  3. Check this pls. http://blogs.msdn.com/b/sayanghosh/archive/2007/04/21/solution-to-could-not-load-file-or-assembly-or-one-of-its-dependencies-access-is-denied.aspx

    Also make sure that your dlls were merged properly. Was that successful?

    ReplyDelete
  4. Yes, those DLLs merged properly. Plugin is working fine in Dev environment, but when I try in QA environment I am getting that error.

    ReplyDelete
  5. "Plugin is working fine in Dev environment" From this I doubt its a privilege issue. Its one of the possibilities. Please verify the following.

    http://crmdm.blogspot.com/2011/06/plugin-registration-tool-error-in-crm.html

    ReplyDelete