0

I'm creating a new appdomain for loading some libraries and it seems to have problem finding some files. I'm using the event

ReflectionOnlyAssemblyResolve(object sender, ResolveEventArgs args)

In one of them, the event was raised with the assembly below requested.

System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

This is how all the needed assembly will be requested.

My question is given the full name, how can I get the location of the actually library to load? If that is also not necessary and there is another way to load the libraries, I'll appreciate that as well.

PS: The main application is a .net 4.0 application.

1 Answer 1

1

You should try the Assembly.Load(String) method. It's supposed to work, in the general cases.

3
  • It appear to work fine. I changed the line to read var assm = Assembly.ReflectionOnlyLoad(args.Name); return assm; The problem now is that it is throwing some exception for one of the libraries. Inheritance security rules violated by type: 'System.Web.Mvc.CompareAttribute'. Derived types must either match the security accessibility of the base type or be less accessible.
    – ritcoder
    Jan 4, 2012 at 20:05
  • The assembly may be already loaded in the AppDomain with different security settings. In this case, you can try to check AppDomain.GetAssemblies() and compare full names. Jan 4, 2012 at 20:50
  • Didn't work. I got the same error. From the breakpoints I set, it appears the event is not raised if the assembly has already been loaded.
    – ritcoder
    Jan 4, 2012 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.