由于格式不正确,加载程序集失败
我开发了一个相当大的 Windows Forms .net (C#) 应用程序,其中包含多个程序集。最初,每个程序集都是为目标平台“任何 CPU”构建的。 由于 x64 机器上的 Crystal Reports 存在问题,我们必须为 x86 目标平台构建整个项目。我开始为 x86 重建一些项目,效果很好。 但对于一个程序集,我遇到的问题是,当我尝试将它用作另一个程序集中的引用时,另一个程序集不会加载它,并出现以下错误:
无法加载文件或程序集#MyAssembly#或其依赖项之一。尝试加载格式不正确的程序。
当在具有多个程序集的示例项目中使用 Crystal 时,我发现当为不同的目标平台构建项目时会发生此错误。但这里的情况并非如此。我为 X86 构建了每个项目,但无法弄清楚问题出在哪里。
I develop on a pretty big windows forms .net (C#) application with several assemblys. Originally each assembly was build for the Target Platfom "Any CPU".
Due to a problem with Crystal Reports on x64 machines we had to build the whole project for x86 target platform. I startet rebuilding some of our Projects for x86 and it worked just fine.
But with one I have the problem that when I try to use it as a reference in another Assembly, the other one won't load it giving following Error:
Could not load file or assembly #MyAssembly# or one of its dependencies. An attempt was made to load a program with an incorrect format.
When playing Around with Crystal in a sample project with more than one assembly I found out that this error occurs when the Projects are build for different target platforms. But this isn't the case here. I build every Project for X86 and just can't figure out where the problem is here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用目标平台“x86”或“x64”构建 MainProject(可执行文件),并将所有其他项目设置为“任何 CPU”。
You can try, to build your MainProject (Executable) with target platform "x86" or "x64", an all other projects you set to "Any CPU".