System.BadImageFormatException:未能加载文件或程序集“x_Accessor,......”该组件是由一个运行时新建成 [英] System.BadImageFormatException: Could not load file or assembly 'x_Accessor,...' This assembly is built by a runtime newer

查看:1174
本文介绍了System.BadImageFormatException:未能加载文件或程序集“x_Accessor,......”该组件是由一个运行时新建成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.BadImageFormatException: Could not load file or assembly 'x_Accessor, 
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 
This assembly is built by a runtime newer than the currently loaded runtime and 
cannot be loaded.

我有一个很难找到治愈这种疾病...

I am having a hard time finding a cure for this ailment...

我创建单元测试点网试验项目。使用默认的单元测试框架。

I have created unit tests for dot net test projects. With the default unit test framework.

自动化工具创建一个访问 - 这将用于测试的私有方法

The automated tool created an accessor - which would be used for testing private methods.

[我知道理论,私有方法应该通过调用者进行测试 - 但,这取决于它们的目的,内容,背景等等......所以,如果可以,我将考验他们。]

[ I know the theory, private methods should be tested through their callers - but then, it depends on their purpose, content, context and so on... so if I can, I will test them.]

我在过去的几个项目做到了这一点,它工作得很好。

I have done this in the past on a couple of projects, and it worked fine.

但在这两个项目我想现在来测试,我遇到了这个问题...

But on these two projects I am trying to test now, I am running into this problem...

注:我使用的框架3.5 - 这可能是一个问题? - 但访问应该知道!

Note: I am using Framework 3.5 - that may be an issue ? - but the accessor should know that !

我看绝对行不通的,我可以修改运行时的组装......我想象的访问者。

I see absolutely nowhere where I can modify the runtime for the assembly... which I imagine is the accessor.

是的,我做了清洁和重建,我也完全删除输出文件夹和重建,我没有删除访问和私有方法,并重新创建它。

And yes, I did clean and rebuild, I did completely erase the output folder and rebuilt, I did delete the accessor and private method and re-create it.

请帮我看看怎么解决这个问题!谢谢你。

Please help me find how to fix this ! Thank you.

推荐答案

您不能引用被编译在一个更高的.NET版本(的CLR或版本更准确)的组件。因此,在你的例子,如果你有一个组件单元测试是.NET 3.5,那么你不能引用程序集是.NET 4.0。

You can't reference an assembly that is compiled in a higher .NET version (or version of the CLR to be more accurate). So in your example if you have an assembly for unit tests that is .NET 3.5 then you cannot reference an assembly that is .NET 4.0.

这答案是你在找什么,我认为:

This answer is what you are looking for I think:

<一个href="http://stackoverflow.com/questions/5397251/vs2010-sp1-unit-tests-targeting-3-5-framework-fail-if-using-private-accessor">VS2010针对3.5框架SP1单元测试失败,如果使用私有访问

这篇关于System.BadImageFormatException:未能加载文件或程序集“x_Accessor,......”该组件是由一个运行时新建成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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