I am using reflection to create an assembly (Assembly A) and invoke a method.
Assembly A has its own config file, which is set at run time. To read this
config file I had to set some binding flags in the code, now this seems to
work fine, Assembly A can read its config file. However Assembly A references
another assembly (Assembly B), which in turn references some Application
Blocks to interact with Authorization Manager.
The error I get says :
System.Configuration.ConfigurationException: Could not create
Microsoft.ApplicationBlocks.Common.ProviderConfigHandler,
Microsoft.ApplicationBlocks.Common,
Version=1.0.0.0,Culture=neutral,PublicKeyToken=efeb39a96c5c847f
Since “ProviderConfigHandler” shows up in the configuration files (XML
files) for the Application Blocks, it leads me to believe that I am having
further binding issues, perhaps farther down the call stack, and that perhaps
these config files cannot be read.
Note: If I make a references to Assembly A directly, i.e. without using
reflection, everything works fine. In fact, I didn’t even need to adjust my
BindingFlags at run time until I started creating the assembly using
reflection.
The binding flags were set to the following:
BindingFlags.NonPublic|BindingFlags.Static
Any ideas?
Trent Rossiter - 28 Jun 2006 21:39 GMT
I spoke with Microsoft Support and found the answer. The application blocks
are using relative addressing to locate things, probably configuration
information. Since I was creating assemblies that reside a different
directory, they could not find their configuration files and were throwing an
exception.
There are two ways to solve the problem:
1. Put all the assemblies in the same directory. This is a very simple
solution, but it was not appealing to me because I wanted the assemblies that
were to be loaded at run-time to be in their own special directory.
2. Add an AppDomain.CurrentDomain.AppendPrivatePath(directory) statement
just before I tried to load the assembly. This fixed my problem and allowed
me to put my assemblies in any directory that I wanted.
Hopefully this will help someone at some point.
Trent

Signature
Trent Rossiter
> I am using reflection to create an assembly (Assembly A) and invoke a method.
> Assembly A has its own config file, which is set at run time. To read this
[quoted text clipped - 22 lines]
>
> Any ideas?