12

I have "mycomp.myassembly.dll" in GAC but Load and LoadFrom throws file not found exception and LoadWithPartialName returns null. I'm doing the following:

    AssemblyName name = new AssemblyName();
    name.Name = "mycomp.myassembly.dll";

    Assembly assembly = Assembly.Load(name);

fails with FileNotFound for mycomp.myassembly.dll file, and

    Assembly assembly = Assembly.Load("mycomp.myassembly.dll");

fails with exactly the same message.

I double checked that assembly is in GAC (and even did gacutil /if for it again) and it does work in all other cases, I just unable to load it myself.

What am I doing wrong here? Do I miss something?

starblue
  • 55,348
  • 14
  • 97
  • 151
Artem
  • 7,275
  • 15
  • 57
  • 97

2 Answers2

22

Have you tried using the fully qualified assembly name? (e.g. "ycomp.myassembly.dll, Version=1.0.2004.0, Culture=neutral, PublicKeyToken=8744b20f8da049e3")

Arnold Zokas
  • 8,306
  • 6
  • 50
  • 76
1

try simply loading with the full name

 // You must supply a valid fully qualified assembly name.            
        Assembly SampleAssembly = Assembly.Load
            ("SampleAssembly, Version=1.0.2004.0, Culture=neutral, PublicKeyToken=8744b20f8da049e3");

I can usually load without the version, culture and public key.

Sky Sanders
  • 36,396
  • 8
  • 69
  • 90
  • I think the public key would be needed, without the public key it's treated as an entirely different assembly. All assemblies in the GAC will have a public key. – erikkallen Feb 17 '10 at 21:00
  • you are right. i was brain farting and thinking of loading local assemblies – Sky Sanders Feb 17 '10 at 21:12