.net - Assembly.GlobalAssemblyCache returning FALSE although assembly is loaded from GAC -


i have created test project understand reflection. i'm loading assembly .net 4.0 gac. (as understand, .net 4.0 maintains it's gac in c:\windows\microsoft.net\assembly)

i wrote code this:

assembly testassembly = assembly.reflectiononlyloadfrom(@"c:\windows\microsoft.net\assembly\gac_32\testreflection\v4.0_1.0.0.0__7ff2353191526e8c\testreflection.dll");          if(testassembly.globalassemblycache)             console.writeline(testassembly.fullname); 

when run code, globalassemblycache property return false although i'm loading assembly gac.

can tell me reason? or missing something?

you may first want make sure assembly in fact loaded onto gac. doing can try following:

gacutil /l system.data 

which provide details of assembly in gac as:

microsoft (r) .net global assembly cache utility.  version 4.0.30319.1 copyright (c) microsoft corporation.  rights reserved.  global assembly cache contains following assemblies:   system.data, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089, processorarchitecture=x86   system.data, version=1.0.5000.0, culture=neutral, publickeytoken=b77a5c561934e089   system.data, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089, processorarchitecture=x86  number of items = 3 

then loading assembly gac reflectiononly usage can try reflectiononlyload instead of reflectiononlyloadfrom

example:

assembly testassembly = assembly.reflectiononlyload(@"system.data, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089, processorarchitecture=x86");  if (testassembly.globalassemblycache) {     console.writeline(testassembly.fullname);     console.writeline(testassembly.location); } else {     console.writeline("not found in gac"); } 

the above gives following output:

system.data, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089 c:\windows\microsoft.net\assembly\gac_32\system.data\v4.0_4.0.0.0__b77a5c561934e089\system.data.dll 

hope helps!


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -