Invalid Cast Problem using Enterprise Library MS DAAB (with dynamic dll loading)
-
Hi, I am loading a dll say XYZ.dll dynamically from console application by using activator.createinstance() method. This XYZ.dll is having reference to a data access layer ABC.dll which has reference to the 3 MS-DAAB dlls of enterprise library: 1. Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings 2. Microsoft.Practices.EnterpriseLibrary.Data 3. Microsoft.Practices.ObjectBuilder I have placed these 3 dlls and ABC.dll in the folder with the exe of console application. However XYZ.dll is not placed there as it will be loaded at runtime specifying a certain path. Now when I try using code which uses the MS DAAB dlls then I am getting an error: Unable to cast object of type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings' to type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings' (I do not get this error when I am not dynalically loading the dll) Note: I have specified the dataConfiguration section in App.config of Console Application. Any help is appreciated.
Pankaj Chamria, Software Programmer.