0

I have a very strange problem, within VS 2010 I am able to run my application perfectly. But when I build it OR release it and run the '.exe' I get the following error:

System.IO.FileNotFoundException: Could not load file or assembly [my assembly] or one of its dependencies, Version=1.0.0.0, Culture=nl-NL, PublicKeyToken=null .....
  • I checked the release management and build order, all OK.
  • I checked the 'Copy local' option it is on 'True'.
  • Cleaned my Solution
  • The reference is from a different project inside the solution and is added by 'project reference'.
  • The Environment.CurrentDirectory Is the same as the .exe location.

I'm lost.

E. van der Spoel
  • 260
  • 1
  • 15
  • 1
    So the app works if executed outside VS in the DEBUG folder and not if in the RELEASE folder? – Steve Jul 24 '14 at 15:01
  • Try cleaning the debug and release folders in your solution, removing and re-adding the assembly reference, and rebuild. – arao6 Jul 24 '14 at 15:15
  • @Steve No the application only works when running inside the context of visual studio. None of the builded applications runs, they all give the JIT error. – E. van der Spoel Jul 25 '14 at 07:19
  • I could give you this link http://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net it is possible that you could find here the tools and tips to resolve your problem – Steve Jul 25 '14 at 07:22

2 Answers2

3

Could not load ... Version=1.0.0.0, Culture=nl-NL, PublicKeyToken=null

There is something very wrong about this assembly reference, the Culture attribute is incorrect. The CLR is going to be pretty cranky about trying to find such an assembly. Assemblies that contain code must have a neutral Culture attribute, Culture=neutral. Only satellite assemblies, the kind that contain localized resources, have the culture set. They are loaded differently, an explicit Assembly.LoadFrom() call emitted by the ResourceManager.

Not real sure how you avoided this problem in Visual Studio. I'd guess that the Hosting process has something to do with it. You could try disabling it to repro the problem, Project + Properties, Debug tab.

I have no idea how you got the attribute set to "nl-NL", there certainly isn't any way to do that in the IDE that I know of. You can write the [assembly:AssemblyCulture] attribute in the AssemblyInfo.cs file but the build system is going to complain loudly when you do. Anyhoo, you'll have to get it back to neutral to solve your problem. In general, the Fuslogvw.exe utility shows assembly resolution problems.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • I am going to accept this as a enter, there is something wrong with the assembly (reference). I don't know what happened, i recreated a class library copied my classes into that new project. Then added it as a project reference to my class. Build it, and it runs fine, without any problems. It is not really a solution but this take to much time. Thanks for the insight. – E. van der Spoel Jul 25 '14 at 08:09
1

Well it looks like you are on the right track. One of the referenced assemblies is missing when you run the app. And copy local is important when the assemblies are not in the GAC. The "copy local" attribute may not be set in the referenced project for those related assemblies - you should check there for the missing assembly.

When you run the app in VS it runs based on your active configuration (Debug or Release). Which of those two do you have selected? By default it would be Debug.

If you are using the Debug configuration when you build the app the .exe would be compiled into the bin/Debug/ folder. Is that where you are running it from and it does not work?

When you release the app you need to make sure you copy the {appname}.exe file (and {appname}.pdb file for debugging information) ,all of the .dll files found in the output folder and the {appname}.exe.config file. As a side note - you can skip the {appname}.vshost.exe and those related files because they are not needed.

Charmless
  • 61
  • 2