BehaviorExtension in module config file gives ConfigurationErrorsException

Topics: Prism v2 - WPF 3.5
Nov 18, 2010 at 8:19 AM

I have a problem with a module using a WCFservice. The service i configured in the config file of the module, and a custom behaviorextension is also defined there. The extension is defined in a common module assembly (called ClientLibrary), where there is also a generic class to create a channelfactory based on the configurationfile of the module (using ConfigurationManager.OpenMappedExeConfiguration).

My problem is that when the channelfactory is created, I get a ConfigurationErrorsException (wrapped in a ModuleInitializeException) saying that the behaviorextension type cannot be loaded:

System.Configuration.ConfigurationErrorsException: The type 'NextGeneration.ClientLibrary.PathologyClientMessageInspectorExtensionElement, ClientLibrary' registered for extension 'PathologyMessageInspector' could not be loaded. (C:\ProgramData\Company\Modules\LoginModule.dll.config line 17)

The only way I can get around this, is to define the modulefolder (I use DirectoryModuleCatalog, and syncronize te module folder against a networkshare containing updated modules at application start) as a subdirectory to the application directory, and adding the following to the shells config:

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="Modules"/>

This however is not possible in production, since the module will be installed in programfiles folder, and the modulefolder should reside in Programdata folder.


Any comment would be much appreciated - I hope I do not have to add the behaviorextension programmatically when creating the channelfactory.

Nov 18, 2010 at 6:24 PM


If your scenario requires to call a WCF service, you have take into account some concepts. Therefore, if you are using Prism v2, I think that you will find the following links interesting:

Hope this helps.

Fernando Antivero

Nov 22, 2010 at 9:13 AM

Hi fantivero

Thank you for the reply!

The first link you provided just states that when using a service from a module, the modules config (not the shells) file will contain the client side settings. This is why I use the ConfigurationManager.OpenMappedExeConfiguration to create the channel from settings in the modules config file. And this works great as long as the modules are in a folder, that can be registered as a probingpath in the shells config, since otherwise it cannot load the extensiontype.

As stated above this is not possible in production, and so the only solution I can see is to add the behaviourextension programmatically. I would like to avoid that...

Anybody that had similar problems?