简体   繁体   English

在运行时找不到C#程序集

[英]C# Assembly not found at runtime

A strange error begans to happen with my XNA project on a new pc. 我在新电脑上的XNA项目开始出现一个奇怪的错误。 I have two projects on the solution and a library that is used by both of them. 我在解决方案上有两个项目,并且两个人都在使用一个库。 One of the projects, a XNA Game Project, runs perfectly. 其中一个项目XNA Game Project可以完美运行。 The other project is a mix of WindowsForm and XNA. 另一个项目是WindowsForm和XNA的混合。 The form launches a XNA class when a button is clicked. 单击按钮时,该窗体启动XNA类。 When I run the program, it works great till the moment I click the button which launch the XNA class. 当我运行该程序时,在单击启动XNA类的按钮之前,它一直有效。 A FileNotFoundException is fired exactly at the moment that the constructor will be executed. 恰好在执行构造函数的那一刻将触发FileNotFoundException。

System.IO.FileNotFoundException was unhandled   Message="Could not load file or assembly 'Microsoft.Xna.Framework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d' or one of its dependencies. The system cannot find the path specified."

The reference is correct, there is no problem on compilation. 参考是正确的,编译没有问题。 We already tried to delete the reference and add it again but it didn't work. 我们已经尝试删除引用,然后再次添加它,但是它不起作用。 Everything worked correctly in others teammate's pc. 在其他队友的电脑上,一切正常。

Anyone has any idea what is the problem? 任何人都知道是什么问题吗?

Check your config file for references to this dll. 检查您的配置文件以获取对此dll的引用。 It is most likey a type being loaded via reflection. 最有可能是通过反射加载的类型。 I see these types of errors with the Ent Lib. 我在Ent Lib中看到了这些类型的错误。

If this File is in the GAC on your teammate's machine or if you have different config files, this error will not show up. 如果此文件位于队友计算机上的GAC中,或者您具有其他配置文件,则不会显示此错误。

HTH HTH

Brian 布赖恩

You can try using depends.exe from the platform sdk, to investigate a missing dependency. 您可以尝试使用平台sdk上的depends.exe来调查缺少的依赖项。 I assume you have manually verified the file was in the right folder? 我假设您已手动验证文件在正确的文件夹中?

Also, there are apparently issues with this dll on x64 另外, x64上的此dll显然存在问题

Hey Gustavo, sounds like you had this a long time ago: 嗨,古斯塔沃,听起来你很久以前就这样:

http://blogs.msdn.com/b/shawnhar/archive/2008/02/25/xna-framework-on-64-bit-windows.aspx http://blogs.msdn.com/b/shawnhar/archive/2008/02/25/xna-framework-on-64-bit-windows.aspx

Sounds like the CLR was trying to look for a 64-bit version of XNA, for which there is none, this is why creating a new project as XNA Project works, since those default to 32-bits. 听起来好像CLR试图寻找64位版本的XNA,但没有,这就是为什么XNA Project可以创建一个新项目的原因,因为默认情况下默认为32位。

Just leaving it here for reference, also, close this question already, choose an answer. 只需将其留在此处以供参考,也请先关闭此问题,然后选择答案。 :3 :3

I solve the problem with a workaround: 我通过一种解决方法解决了这个问题:

I create a new XNA project and move everything to there, then I added the references to WindowsForm. 我创建一个新的XNA项目并将所有内容移动到那里,然后将引用添加到WindowsForm。 The assembly problem didn't happen anymore! 装配问题不再发生了!

Thank you for all the help. 感谢您的所有帮助。

You can use fuslogvw or any of the other things mentioned to find the root cause. 您可以使用fuslogvw或提到的任何其他方式来找到根本原因。 You can also trap the AssemblyResolve event and manually load the assembly in the From or Neither context. 您还可以捕获AssemblyResolve事件,并在FromNeither上下文中手动加载程序集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM