插件执行时出现System.BadImageFormatException [英] System.BadImageFormatException when plugin executes

查看:92
本文介绍了插件执行时出现System.BadImageFormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的CRM 2011实例中注册了一个自定义插件。直到今天,该插件仍能正常工作,但在创建记录时突然出现了System.BadImageFormatException错误。我曾尝试研究此问题,但在注册插件时只能找到遇到此问题的人。我的研究使我相信这与64位和32位有关。我尝试将程序集的目标从 Any CPU更改为64位,但是在执行插件时遇到相同的错误。错误详细信息如下。

 未处理的异常:System.ServiceModel.FaultException`1 [[Microsoft.Xrm.Sdk.OrganizationServiceFault,Microsoft。 Xrm.Sdk,版本= 5.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35]]:System.BadImageFormatException:Microsoft Dynamics CRM遇到错误。管理员或支持人员的参考编号:#6C9D565A详细信息:
< OrganizationServiceFault xmlns:i = http://www.w3.org/2001/XMLSchema-instance xmlns = http://schemas.microsoft.com / xrm / 2011 / Contracts>
< ErrorCode> -2147220970< / ErrorCode>
< ErrorDetails xmlns:d2p1 = http://schemas.datacontract.org/2004/07/System.Collections.Generic />
< Message> System.BadImageFormatException:Microsoft Dynamics CRM遇到错误。管理员或支持人员的参考编号:#6C9D565A< / Message>
< Timestamp> 2016-03-17T19:05:45.6106609Z< / Timestamp>
< InnerFault i:nil = true />
< TraceText>

[PluginProfiler.Plugins:PluginProfiler.Plugins.ProfilerPlugin]
[0b8f5ab6-66ec-e511-8367-000c29e9a79c:MultiFamily.PostHomeCreate:创建anh_home(Profiler)]


< / TraceText>
< / OrganizationServiceFault>


解决方案

我设法解决了问题,但我仍然不知道是什么原因。我不是100%确定该错误与插件代码无关,因此我注释掉了所有代码行(节省了注册和执行插件所需的行),并通过插件注册工具编译和更新了插件。然后,我从CRM内部触发了插件的执行,发现插件执行没有错误。现在,我只需要查找导致错误的代码行。



由于完全实现的插件引发错误,因此我无法剖析和调试插件,因此我通过恢复插件线的功能来解决问题。线。每次恢复一些功能时,我都会从CRM中构建,更新程序集并测试插件的执行情况。奇怪的是,我能够恢复所有原始功能,构建,更新和测试插件而没有任何错误。



我不确定可能出了什么问题,但绝对没有已经更改,但是我现在有一个功能齐全的插件。吸取了教训,当其他任何事情都不起作用时,所有的人都会离开游泳池。 >

I have a custom plugin registered in my CRM 2011 instance. Until today the plugin was working perfect but al of a sudden I am get this System.BadImageFormatException error when creating a record. I have tried researching the issue but I can only find people having this issue while registering a plugin. My research has led me to believe it is something to do with 64 bit vs 32 bit. I have tried changing the target of my assembly from "Any CPU" to 64 bit but I get the same error when the plugin executes. The error details are below. Thanks in advance.

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.BadImageFormatException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #6C9D565ADetail: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ErrorCode>-2147220970</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>System.BadImageFormatException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #6C9D565A</Message>
  <Timestamp>2016-03-17T19:05:45.6106609Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText>

[PluginProfiler.Plugins: PluginProfiler.Plugins.ProfilerPlugin]
[0b8f5ab6-66ec-e511-8367-000c29e9a79c: MultiFamily.PostHomeCreate: Create of anh_home (Profiler)]


</TraceText>
</OrganizationServiceFault>

解决方案

I managed to resolve my issue but I'm still not sure what the cause was. I wasn't 100% sure that the error wasn't related to the plugin code so I commented out all the lines of code (save the lines required to register and execute the plugin), compiled and updated the plugin via the plugin registration tool. I then triggered the plugin execution from inside CRM and low and behold the plugin executed with no errors. Now I just had to find the line of code that was causing the error. This is where things got weird.

Since the fully implemented plugin was throwing errors I was unable to profile and debug the plugin so I resorted to restoring functionality to the plugin line by line. Every time I would restore some functionality I would build, update the assembly and test the plugin execution from CRM. Oddly, I was able to restore all the original functionality, build, update and test the plugin without any errors.

I am not sure what might have gone wrong but absolutely nothing had changed but I now have a fully functional plugin. Lesson learned, when nothing else works, everyone out of the pool.

Thanks Jordi for your time and comments hopefully they can help someone more than they helped me.

这篇关于插件执行时出现System.BadImageFormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆