简体   繁体   中英

C# Assembly not found at runtime

A strange error begans to happen with my XNA project on a new pc. 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. The other project is a mix of WindowsForm and XNA. The form launches a XNA class when a button is clicked. When I run the program, it works great till the moment I click the button which launch the XNA class. A FileNotFoundException is fired exactly at the moment that the constructor will be executed.

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. It is most likey a type being loaded via reflection. I see these types of errors with the 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.

HTH

Brian

You can try using depends.exe from the platform sdk, to investigate a missing dependency. I assume you have manually verified the file was in the right folder?

Also, there are apparently issues with this dll on x64

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

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.

Just leaving it here for reference, also, close this question already, choose an answer. :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. 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. You can also trap the AssemblyResolve event and manually load the assembly in the From or Neither context.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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