Search code examples
assemblyinfo

Using a class library assembly that internally uses a link to a global assembly info file


I am struggling with the current scenario below. I'm using vs 2010 and C# with .NET 4:

  • I have a separate solution (call it solution A) that has 2 class library projects in it (call them B and C). Project B has a link to a "GlobalAssemblyInfo.cs" file in Project C, BUT Project B does not depend on Project C, it merely just has a link to the .cs file in Project C. This is all well and good as everything compiles and B.dll + C.dll is produced.

  • Now I have a totally different solution (call it D) that has only 1 console application project in it (call it E). Now in Project E, I add a reference to B.dll. When I compile all is well.

The problem is when I debug Project E, when I get to a line of code that uses any object from Project B (or B.dll), I get an error that says "FileNotFoundException unhandled exception. Could not load file or assembly B", where B is the fully qualified name of assembly B.

How do I resolve this problem? I know the problem is caused by the linking to the "GlobalAssemblyInfo.cs" file in Project C because when I remove / delete this link everything works fine and I can use object in assembly B.

Here is a url that explains how to link to files within a solution / project if you need to understand what linking is http://bloggingabout.net/blogs/jschreuder/archive/2006/11/02/Centralizing-AssemblyInfo-settings_2C00_-or-simplify-versioning-of-solutions.aspx


Solution

  • I had the same problem, after I started using a global AssemblyInfo my unit tests were throwing FileNotFound exceptions for the app project. Turns out it was because I had specified

    [assembly: AssemblyCulture("en")]
    

    in the global assembly. Changing it to

    [assembly: AssemblyCulture("")]
    

    Solved it for me.