Hello all,

I'm running into some subtle behavior with how the assembly resolver and
loader works, and I wonder if anyone can help me understand this.

The manifestation of my problem is that a call to
ConfigurationSettings.GetConfig( "sectionName" ) is throwing an exception,
with a message that states "Could not create
Nairobi.Configuration.ExternalFileSectionHandler, Nairobi".  This type is
the type that I registered as a section handler, so obviously an instance
of this type needs to be created

I've done the obvious checks, double checking spelling, making sure I have
public constructor, etc, and it all seems to check out.

If I look at the source code for
System.Configuration.ConfigurationRecord.GetFactory() (which is where the
exception is being thrown from) with a decompiler, it looks like the
problem comes from a call to Type.GetType(string), which apparently is
returning null.

What puzzles me is that if I make the same call to Type.GetType
("Nairobi.Configuration.ExternalFileSectionHandler, Nairobi") immediately
before the call to ConfigurationSettings.GetConfig(), the correct type
instance is returned, so it looks as though the resolver is able to locate
the assembly in which the handler is defined.

What perhaps is complicating the situation is that the assembly that is
making the call to ConfigurationSettings.GetConfig was loaded by a call to
Assembly.LoadFrom().  The assembly that defines the section handler is in
the same directory as the assembly that was loaded by LoadFrom(), so my
understanding is that the assembly loader should be able to find it.

So I guess my question is:
Does any one have an idea why Type.GetType() succeeds when called from my
code, but seems to fail when called by the framework?

I hope my description makes sense...

Regards,
John

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to