ccc1919

Hello everybody,

when calling AddInStore.Rebuild() I get the following string in the result string[] array:

"While examining an assembly for pipeline segments, got a ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. File Name: D:\output\AddInSideAdapters\AddInSideAdapters.dll"

The assembly AddInSideAdapters.dll references the AddInViews.dll and AddInContracts.dll assemblies (which contain the AddIn-View class and the AddIn-contract interface).
Besides this two it references also a shared assembly containing some common types (DataLayer.dll). This assembly is located in the root output path.

Here the output structure:
output\AddInSideAdapters\AddInSideAdapters.dll
output\AddInViews\AddInViews.dll
output\Contracts\AddInContracts.dll
output\DataLayer.dll

After investigating a bit, I found out that DataLayer.dll cannot be found by the AddInStore loading process (i.e. the call AddInStore.Rebuild() tries to load the assemblies to use Reflection to look for AddIn-classes).

If I copy DataLayer.dll to the folder AddInViews\ then it works. But this is more an ugly workaround than a solution. So the question is: How can I tell the AddInStore where to look for referenced assemblies

Thanks a lot for your help!
Alexander

P.S.: I'm using Visual Studio 2008 Beta 2


Re: .NET Base Class Library System.AddIn namespace: AddIn not loaded due to "ReflectionTypeLoadException" in AddInStore.Rebuild

Feng Chen - MSFT

Hi,

You can first check out this article Different Approaches to Add-In Discovery [Jesse Kaplan] which concentrates on the simpler scenarios where the application wants to find all the add-ins in a directory, set of directories, or an individual file.

Maybe the solution in the article can help you solve this issue, and I suggest that you can reach to the author of that article for more help.

Hope this helps!

Thanks!






Re: .NET Base Class Library System.AddIn namespace: AddIn not loaded due to "ReflectionTypeLoadException" in AddInStore.Rebuild

ccc1919

Thank you for the link! It is really helpful.

Alexander




Re: .NET Base Class Library System.AddIn namespace: AddIn not loaded due to "ReflectionTypeLoadException" in AddInStore.Rebuild

Jesse Kaplan - MSFT

The reason we can't find the Datalayer dependency if it is simply located in the root output directory is that, when discovering assemblies, we only look for dependencies in locations where we'll be able to load those assemblies at runtime. If you activated an add-in and it, or anything else in its AppDomain, tried to load an assembly that was only located in the host directory it would fail. This is actually a good thing as it makes it very hard for add-ins to accidentally depend on parts of the hosts object model that were not intended for its use.

I'm not sure exactly how your DataLayer.dll is used but you should be careful. If any types it defines actually show up in your contract assembly then you are probably bypassing versioning resilience the architecture is designed to promote; this could be fine for your cases, but you should understand the limitations.

If it is just being used to access a database (and not as a system of types to communicate directly to the host with) then it probably makes more sense for this assembly to be considered part of the addinview (either physically or logically) and be placed in that directory.

Does this help

--Jesse





Re: .NET Base Class Library System.AddIn namespace: AddIn not loaded due to "ReflectionTypeLoadException" in AddInStore.Rebuild

c_marius

Hi Jesse,

I did had the same problem and it has been solved by copying the required assemblies into the AddInAdapters, respectivelly HostSideAdapters folders. In this way it found its dependencies.

Hope it helps,

C. Marius