c# - RegistrationServices.RegisterAssembly error - help! -


i have assembly on shared folder (unc-path only, no mapped drive). when try register programmatically via registrationservices, i'm getting strange error.

here's code:

using system; using system.io; using system.reflection; using system.runtime.interopservices;  namespace blregisterassembly {     public static class blregisterassembly     {         public static void register()         {             var asm = assembly.loadfile(@"\\myuncpath\myassembly.dll");             var rs = new registrationservices();             rs.registerassembly(asm, assemblyregistrationflags.setcodebase);             // i've tried assemblyregistrationflags.none : same error.         }     } } 

this error i'm getting:

"could not load file or assembly '[xxxxxxxxxxxxx], version=1.0.0.0, culture=neutral, publickeytoken=[xxxxxxxxxxxxxx]' or 1 of dependencies. system cannot find file specified."

(the file in question referenced assembly main assembly uses).

some more points:
- referenced assembly located in same folder main assembly i'm trying register.
- folder cannot mapped logical drive. because of how network folders accessed, users in different groups have different drive mappings same network folders, , these cannot modified, per policy...

can point me in right direction resolve problem?

answered
because using assembly.loadfile, dependent assemblies have resolved manually via assemblyresolve. following code update fixed woes:

public void register() {     appdomain.currentdomain.assemblyresolve +=        new resolveeventhandler(currentdomain_assemblyresolve);      var asm = assembly.loadfile(path.combine(m_path, assemblyname));     var rs = new registrationservices();     rs.registerassembly(asm, assemblyregistrationflags.setcodebase); }  static assembly currentdomain_assemblyresolve(object sender,    resolveeventargs args) {     //... code resolve path , load dependent assembly... } 

you should never use loadfile(), use loadfrom() clr has shot @ finding dependent assemblies. if still have trouble use fuslogvw.exe trace of assembly resolution attempt. backup plan implement appdomain.assemblyresolve.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -