views:

21

answers:

1

I have a solution in C# that has 1 main project Kingrey (exe) and one project called DllReporter and another called ProductReportClasses.

When I do try to list all assemblies in my exe from DllReporter level:

AppDomain.CurrentDomain.GetAssemblies()

I get only Kingrey and DllReporter, but not ProductReportClasses.

But when I di this before getting assemblies in main code of Kingrey:

ProductReportClasses.ClassBasic b = new ProductReportClasses.ClassBasic();

and than use AppDomain.CurrentDomain.GetAssemblies() than I get all 3 assemblies as supposed to.

So my question is: how to get all assemblies or force all assemblies to be listed in GetAssemblies?

A: 

Simple answer: If you A) know all the assemblies you want to have loaded in the appdomain and 2) know a type from each assembly you can force them to be loaded by doing the following

Type temp = typeof(ClassInAssemblyA);
temp = typeof(ClassInAssemblyB);
temp = typeof(ClassInAssemblyC);

somewhere near the beginning of your application's execution. This seems a bit hacky and it is. But it works (as long as you qualify for A and 2 above and reference assemblies A, B and C) and is simple to do.

Will
Unfortunately I don't know
tomaszs
Then you have to iterate through all the assemblies in a specific location and load them into the current appdomain first. http://msdn.microsoft.com/en-us/library/25y1ya39.aspx The question then becomes what directories do you search in.
Will
I can not do this because I have more dlls from other projects in the same folder
tomaszs
So, you need to load assemblies at runtime, but you don't know what they are, and you cant figure them out at runtime. Son, you need to reconsider your design. Something has to change.
Will