开发者

Distinguish two same private assemblies

I have an application that uses (has referenced) a class library (myLib.dll private assembly).

I created a new class library project with exactly tha same code of the first class library.

When i put in a folder the application and the second dll it throws an exception when i run it.

How does the application distinguish the two assemblies since they are not strong named?

this is the application

class Program
{
    static void Main(string[] args)
    {
        try
        {
            mYnameSpace.Class1 c = new mYnameSpace.Class1();
          开发者_如何学编程  c.test1();
            Console.ReadLine();
        }
        catch(Exception ex)
        {
            Console.WriteLine(ex);
        }
    }
}

this is the code of each library

namespace mYnameSpace
{
  public class Class1
  {
    public void test1()
    {
        Console.WriteLine("hello");
    }
  }
}

It's displayed the junt in time debuger. ("an unhandled exception occured")


If the assembly is not in the GAC then the CLR will search the directories in the probing paths for an executable with the same display name. Which ever one it finds is then checked for the rest of the assembly attributes, AssemblyVersion, Culture and PublicKeyToken. A mismatch with the reference assembly produces an exception. I'd guess at an assembly version mismatch since culture is normally * and public key token is null.

Of course, the exception message will give you a better diagnostic than my answer.


The assemblies may not be signed, but they still have their own GUIDs. Assemblies are primarily identified by their GUIDs in the GAC and not their filenames.

Namespaces are different. If you have both assemblies referenced in your project and they share a common namespace, then the compiler will throw an ambiguity exception as it cannot determine which assembly you're trying to use.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜