Just to increase confusion:
static void Main(string[] args)
{
Assembly assembly = Assembly.GetEntryAssembly();
AssemblyName[] refs = assembly.GetReferencedAssemblies();
Console.WriteLine(refs.Length);
Type t = Type.GetType("ClassLibrary1.Class1, ClassLibrary1");
object o = Activator.CreateInstance(t);
refs = assembly.GetReferencedAssemblies();
Console.WriteLine(refs.Length);
}
The type and the instance retrieved perfectly, while ClassLibrary1 still not
visible among referenced assemblies. It is not "dynamically referenced", it
just behaves odd hiding ClassLibrary1.
Is there any other suggestion, how to preload assemblies? My current
"solution" is browsing the files of the execution folder. It works fine as
long as I have read permission on the disk (as I have no interest in the
GAC), but on a web server having disk read permission is not an guarantee.
[quoted text, click to view] "Marc Gravell" wrote:
> > the resulted AssemblyName array contains one single element
>
> Interesting; I've just done a test, and it looks like the compiler
> removes the references that aren't actually used by your code - i.e.
> commenting out blocks of code can reduce the
> assembly.GetReferencedAssembles() count... As such, I imagine that
> adding some more code might make it start working. I am, however,
> confused as to why you didn't see "System"... using copy/paste on your
> code (in 2.0) gives me both System and mscorlib....
>
> Marc
>
[quoted text, click to view] >I am, however,
> confused as to why you didn't see "System"... using copy/paste on your
> code (in 2.0) gives me both System and mscorlib....
I believe the same reason you wrote above. They were not in use. I have no
clue why you have seen them (both 2.0), I have repeated the test on two
separate machines. They were consistent, only mscorlib was visible.
However, my personal interest is in my plugin system. I want to browse the
plugins via my plugin handler, both are referenced by a neutral host app. As
binding is prescribed in config files loaded during runtime, it has a fair
chance that types from the plugins will be used completely dynamically