views:

1040

answers:

2

I have a VS 2005 C# project that uses a special Plugin folder to load extra DLLs (for use as nodes in an asset conversion process).

I have a mixture of C# and C++ DLLs in this folder.

The issue I have is that when Shadow Copying is enabled, the C++ DLLs refuse to load using Assembly.LoadFrom. I have attempted to create a custom app domain, and used Load, but this also failed.

Finally, I tried reading the DLL in as byte[] data and using Load on that - again, only the C# DLLs would work this way, with an error "Additional information: Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)".

An article on the net prompted me to attempt to use /clr:safe when building that particular DLL, but then it simply failed to build due to thousands of errors in Microsoft code... (apparently)

With Shadow Copying disabled, LoadFrom works fine for all DLLs. The app is itself a plugin for Maya, and this used to work with Maya 8.5 but fails with 2008 / 2009 (if Shadow Copying is enabled).

We really would prefer to use Shadow Copying, because it prevents DLL file locks when the app is running (the Plugins folder is stored in a location that Perforce can update while the app is running).

Any ideas as to how I can persuade Shadow Copying to work with a custom folder AND a mix of C# / C++ DLLs without these problems?

+1  A: 

Sounds like a trust issue. Try getting a Fusion log (see this blog post). Your C++ DLLs are unverifiable since they weren't compiled with /clr:safe, so they can only be loaded as full trust. Presumably when shadow copying, the download cache location doesn't have full trust.

Running caspol -s may get you up and running if this is a development-only issue.

Sunlight
A: 

Assembly.Load(byte[] ...) explicitly disallows unverifiable (mixed mode) assemblies. you can check the issue on Microsoft Connect.

Govert