Failed obtaining configuration for Common.Logging from configuration section 'common/logging' - c#

I'm trying to configure a console application with the following logging assemblies:
Common.Logging.dll (2.1.0.0)
Common.Logging.Log4Net1211.dll (2.1.0.0)
log4net.dll (1.2.11.0)
If the logger gets configured programmatically then everything works fine:
NameValueCollection properties = new NameValueCollection(); properties["showDateTime"] = "true";
Common.Logging.LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(properties);
But if I try to launch it using the following configuration file, it blows up:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="FILE-WATCH"/>
<arg key="configFile" value="~/Log4NET.xml"/>
</factoryAdapter>
</logging>
</common>
</configuration>
These are the relevant error messages:
{"Unable to cast object of type 'System.Configuration.DefaultSection' to type 'System.Configuration.AppSettingsSection'."}
{"Failed obtaining configuration for Common.Logging from configuration section 'common/logging'."}
It seems to being unable to parse my configuration file, does anyone know what the correct format should be or is it something else that's wrong? I created my configuration file using the official documentation.

I was having this (or related) issue as well and after half a day of error hunting and debugging I narrowed it down to a configuration problem.
The exception was the same as the OP and the inner exception a few level inside of it was failing to find Common.Logging.Log4Net (FileNotFoundException).
It seems that for the Common.Logging.Log4Net1211 NuGet package, they have renamed the assemblyname to be Common.Logging.Log4Net1211 instead of simply Common.Logging.Log4Net. This means in your app.config you need to refer to this new assembly name:
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net1211">
Here's my entire common/logging section of app.config for reference:
<common>
<logging>
<!-- Notice that it's Log4net1211 -->
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net1211">
<arg key="configType" value="FILE-WATCH" />
<arg key="configFile" value="~/Log4Net-MAIN.config" />
</factoryAdapter>
</logging>
</common>

There are two problems with your application (the one I downloaded):
Your configSections in app.config looks like this:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
Notice that the log4net-section is declared twice? Remove the first one.
After removing the first log4net-section, I get the following:
Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I downloaded log4net 1.2.11.0 from the log4net website, unzipped it, unblocked the dll and replaced the log4net in your example and it seems to work.

I'm using
Common.Logging v3.3.1.0
with
Common.Logging.Log4Net1213 v3.3.1.0
in ASP.NET Web API v5, which throws exception
"parent configuration sections are not allowed"
Exception is thrown from Common.Logging.ConfigurationSectionHandler.Create method
In order to make this work, I had to grammatically configure the adapter
var properties = new Common.Logging.Configuration.NameValueCollection();
properties["configType"] = "INLINE";
Common.Logging.LogManager.Adapter = new Log4NetLoggerFactoryAdapter(properties);
I still have to figure out why IIS/Express calls the Create method twice, which is causing the exception to be thrown inside the if condition, but at least the pressure is off for now.

I got it working by installing a missing package
Install-Package Common.Logging.Log4Net1211

Although this is an old question, I had this issue a few weeks and none of the current answers seemed to remedy it. It seemed my configuration was correct as I had many other applications using near identical configuration with no issue. After quite a bit of debugging and running through stacktraces, I finally found the issue.
Notice that in IIS, I have the API application hosted under another application. In this case both the CAMP application and the API application under it are both using Common.Logging. Because of this, both web.config files get loaded, Common.Logging reads CAMP's configuration, then it sees that API has configuration and tries to read that as well, sees the Common.Logging section and throws up because it already read that from the CAMP application.
In the end the solution was to move the API out from under the CAMP application in IIS. A bit of an obsucre edge case, but perhaps someone else might face this issue some day.

Can you try with Common.Logging.dll version 2.1.1.0 instead.
You can download and compare the source of the two versions yourself, but as far as I can see the only difference between 2.1.0.0 and 2.1.1.0 is a change relating to reading the configuration settings in order to workaround a Framework 4.0 bug. The description of the bug (see http://support.microsoft.com/kb/2580188) refers to running from a network share which I am not running from a network, yet a test app using 2.1.0.0 generates the same error as you are getting whereas 2.1.1.0 doesn't.
If you are using another library that expects version 2.1.0.0 of common.logging.dll, then you should be able to using an assembly redirect to use 2.1.1.0 instead.
PS
Not sure whether it is relevant, but I left the name of the dll as Common.Logging.Log4Net121.dll and modified the app.config instead

I found that it was due to the Common.Logging.Log4Net1211 NuGet package retrieveing an older version of Common.Logging. Check for NuGet updates to Common.Logging and if you find one download it and try again.

If your log4net is 2.0.6 or above, it may be convenient to use Common.Logging.Log4Net.Universal package.

Related

Connection to Oracle using Oracle.ManagedDataAccess exception

I'm using the Oracle.ManagedDataAccess Nuget Package Version 12.2.1100 in my C# (>.NET 4.0) project. Everything works ok in my localhost but on the dev server I'm hit with this exception:
Exception Message: ORA-12154: TNS:could not resolve the connect identifier specified
Exception Source: Oracle Data Provider for .NET, Managed Driver
Now I thought the ManagedDataAcess contained everything I needed. Am I missing something else? Is something else interfering with the package? Do I need to add something else?
Note: there is no <oracle.manageddataaccess.client> tag in my Web.config
Code:
<connectionStrings>
<add name="XXX" connectionString="Data Source=XXX;User ID=XXX;Password=XXX" />
</connectionStrings>
EDIT:
I've confirmed that the TNS_ADMIN variable is set within Control Panel but that didn't seem to do the trick.
I then added the tnsnames.ora file to the bin folder and I've got it working but it isn't a long term solution.
Your program does not find the tnsnames.ora (resp. sqlnet.ora) file. There are several possibilities to specify the location.
Define it in .NET config file (web.config, machine.config, application.config)
Set environment variable TNS_ADMIN
Copy tnsnames.ora, sqlnet.ora files to directory where your application .exe is located.
Example for .NET config file:
<oracle.manageddataaccess.client>
<version number="4.122.*">
<settings>
<setting name="TNS_ADMIN" value="C:\oracle\network\admin"/>
</settings>
</version>
</oracle.manageddataaccess.client>
Note, unlike other drivers/providers the ODP.NET Managed driver does not read the TNS_ADMIN setting from Registry.
You probably don't have TNS configured, which is why that form of connection string isn't working. You don't need TNS configured if you use a different form of connection string, ex:
Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=MyIpOrServerName)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MySID)));User Id=MyUsername;Password=MyPassword;
Replace all the My* placeholders with your values.
We were seeing similar issues in one of our environments and the following solved our problem;
When Oracle Data Provider for .NET is installed on a web server and depending on what you select during install, it writes entries into the machine.config file (located at C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\ depending on the framework version). It seems different versions of the ODP.NET installer do different things to the machine.config (some of our servers have no version number specified in the machine.config and others have a specific version number specified for the oracle managed client)
Depending on the version installed, it adds a couple of lines like this:
...
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
...
<oracle.manageddataaccess.client>
<version number="4.121.2.0">
<settings>
<setting name="TNS_ADMIN" value="C:\oracle\client\product\12.1.0\client_1\network\admin" />
</settings>
</version>
</oracle.manageddataaccess.client>
...
The entries contain a specific version number referring to the ODP.NET oracle client version.
We are building our applications with version 4.122.1.0 of the managed client library (Version 12.2.1100 nuget package) which doesn't match 4.121.2.0
We changed the above entries by removing the oracle managed client library version from this tag:
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess" />
And specifying a '*' for the version number for this tag:
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<setting name="TNS_ADMIN" value="C:\oracle\client\product\12.1.0\client_1\network\admin" />
</settings>
</version>
</oracle.manageddataaccess.client>
If you need specific version numbers specified then ensure your code is compliled with the same version numbers.
You can also remove all these entries from machine.config if they are there and specify them in the applications web.config depending on your configuration.
A simple way in my case.
Set ORACLE_HOME environment variable in Program.cs(Entrypoint class)
without any changes or settings in app.config
[STAThread]
static int Main()
{
var oracleHome = GetOracleHome(); // Find registry...
Environment.SetEnvironmentVariable("ORACLE_HOME", oracleHome);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
...

Applying bindingRedirect config to pythonnet

I have an application that relies on NuGet's <bindingRedirect> feature to ensure a single version of log4net.dll. Binding redirects are automatically added to the applications app.config file.
I'd like to load that application's assemblies into Python and call into its code, but because the binding redirects are application-specific, they're not being picked up by Pythonnet and the assembly fails to load:
LOG: Post-policy reference: log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a
[...snip...]
LOG: Assembly Name is: log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a
WRN: Comparing the assembly name resulted in the mismatch: Major Version
Can I get pythonnet to refer to my application's app.config and use the <bindingRedirect> found there? Or can I apply a binding redirect after startup, without needing an app.config?
Here is how to enable app.config with pythonnet when using .NET assemblies from CPython:
Place python.exe.config file next python.exe with the following configuration for detection later:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="customAppSettingsGroup">
<section name="customAppSettings" type="System.Configuration.AppSettingsSection, System.Configuration" />
</sectionGroup>
</configSections>
<customAppSettingsGroup>
<customAppSettings>
<add key="Debugger" value="True"/>
</customAppSettings>
</customAppSettingsGroup>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
Generate .NET assembly with the following code for testing and reading app.config settings:
using System;
using System.Collections.Specialized;
using System.Configuration;
namespace dotnet20
{
public class Class1
{
public Class1()
{
NameValueCollection settings =
ConfigurationManager.GetSection("customAppSettingsGroup/customAppSettings") as NameValueCollection;
if (settings != null)
{
foreach (string key in settings.AllKeys)
{
if ((key == "Debugger") && (settings[key] == "True"))
{
Console.WriteLine("Detected debugger mode");
}
}
}
}
}
}
Now test that pythonnet is able to detect these custom settings from app.config:
python
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> import sys
>>> sys.path.append(r"C:\pythonnet\dotnet2.0\bin\Debug")
>>> clr.AddReference("dotnet2.0")
<System.Reflection.RuntimeAssembly object at 0x000001A51626D630>
>>> from dotnet20 import Class1
>>> Class1()
Detected debugger mode
<dotnet20.Class1 object at 0x000001A51626D6A0>
>>>
I have got into similar problem using Pythonnet with .net dLLs.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
I didn't have Version 3.1.0.0 of Microsoft.Extensions.DependencyInjection.Abstractions and hence the error. My .net project has app.config file which was pointing to a newer version of this dependency ( 3.1.5.0) [ bindingRedirect ]
The solution was to use this app.config file from .net project, rename it to python.exe.config and put it in the same folder where python.exe is. I am not sure if this is the best solution but i have looked in to a bunch of other solutions and this only seems to be working.
You can use pyinstaller (to install with pip: pip install pyintaller see project page) to create a single executable file and place the config file in the same folder.
be able to work with the app.exe.config files on a per project basis.
pyinstaller --onefile script.py
this will create a dist folder inside your current working directory with an exe file (script.exe) and there you can place your script.exe.config file which will parse upon running script.exe

Oracle .Net ManagedDataAccess Error: Could not load type 'OracleInternal.Common.ConfigBaseClass' from assembly

I have a project that works locally, on our dev server, and on our production server.
When I try to run it on the test server, I get the error below, and I don't know what to do about it beyond stare at my screen blankly. Hints? Process to trace the issue to its source?
I've installed the NuGet package for Oracle 12.2, etc.
Could not load type 'OracleInternal.Common.ConfigBaseClass' from
assembly 'Oracle.ManagedDataAccess, Version=4.121.2.0,
Culture=neutral, PublicKeyToken=89b483f429c47342'. Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type
'OracleInternal.Common.ConfigBaseClass' from assembly
'Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral,
PublicKeyToken=89b483f429c47342'.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[TypeLoadException: Could not load type
'OracleInternal.Common.ConfigBaseClass' from assembly
'Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral,
PublicKeyToken=89b483f429c47342'.]
Oracle.ManagedDataAccess.EntityFramework.EntityFrameworkProviderSettings.Oracle.ManagedDataAccess.EntityFramework.EFProviderSettings.IEFProviderSettings.get_TracingEnabled()
+0 Oracle.ManagedDataAccess.EntityFramework.EFProviderSettings.InitializeProviderSettings()
+111 Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices..ctor()
+629 Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices..cctor()
+28
[TypeInitializationException: The type initializer for
'Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices'
threw an exception.]
Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices.get_Instance()
+24
The Web.Config has the following blocks in it:
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
AND
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="PVMDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pdxcludds108.pacificorp.us)(PORT=11086))(CONNECT_DATA=(SERVICE_NAME=DDS1086.PACIFICORP.US))) " />
</dataSources>
</version>
</oracle.manageddataaccess.client>
<connectionStrings>
<add name="OracleDbContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=USERID;Password=WORKINGPASSWORD;Data Source=PVMDataSource" />
<add name="PVMEntities" connectionString="metadata=res://*/Models.PVMModel.csdl|res://*/Models.PVMModel.ssdl|res://*/Models.PVMModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string="DATA SOURCE=pdxcludds108.pacificorp.us:11086/DDS1086.PACIFICORP.US;PASSWORD=XXXXXXX;PERSIST SECURITY INFO=True;USER ID=XXX"" providerName="System.Data.EntityClient" />
</connectionStrings>
NOTE: There are other projects working on this server, they're just using a different version of the Oracle client for .Net. None of the others is using only the Managed driver. I am looking for a way to dig into this error, some hint as to where that type is sourced and loaded from.
There is a conflict between Oracle.ManagedDataAccess from NuGet and the one that is installed (by Oracle client installation) on a server and that is registered in GAC.
Unregister Oracle.ManagedDataAccess from GAC and you will get rid of the error: Run command line and navigate to the directory:
{Oracle home}\product\{version}\client_64\ODP.NET\managed\x64
There you should find OraProvCfg.exe file. Run the following command to unregister Oracle.ManagedDataAccess from GAC:
OraProvCfg /action:ungac /providerPath:Oracle.ManagedDataAccess
You have to remove the Oracle.ManagedDataAccess assembly in your GAC (C:\Windows\Microsoft.NET\assembly...)
Use the command tool gacutil to remove the assembly:
C:\Program Files (x86)\Microsoft SDKs\Windows\YOUR_VERSION\bin\NETFX
4.6.1 Tools> gacutil /u Oracle.ManagedDataAccess
Was able to fix it by replacing references in the project to Oracle.ManagedDataAccess and Oracle.ManagedDataAccess.EntityFramework from those installed by the package manager to those installed by the oracle client installer. The versions are the same but the build number is different on those DLLs
As others said you need to remove Oracle.ManagedDataAccess from GAC.
I run {Oracle home}\product\12.1.0\dbhome_1\ODP.NET\managed\x64\unconfigure.bat and {Oracle home}\product\12.1.0\dbhome_1\ODP.NET\managed\x836\unconfigure.bat and it worked
We had the exact same problem as Dylan above. The issue appears to be with that specific Oracle version (4.121.2.0).
The solution was simple: Just go into Nuget and move up to the next version of your Nuget package for the Oracle.ManagedDataAccess.Client, 4.122.1.0.
Once we did that we could have mixed Oracle client or no-client environments or servers with or without the GAC Oracle installed, keep older apps that still use the GAC, and add new projects that use the Nuget packages. Its always a bad idea in these blogs to ask people to uninstall legacy stuff - like remove the Oracle dll in the GAC on a server - when you have environments with many legacy dependancies that still might reference it.
If removing the DLL from the GAC is not an option, consider getting the next version of oracle.managedData.access 12.2.1 and just put them on the server in the bin directory.
Afterwards you need to add an assemblyBinding to your web.config file.
This way you get arround pulling the 12.1.2 version from the GAC during runtime that will case the error.
You do not need to recompile your app against the new version.
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.1.2.0" newVersion="12.2.1.0" />
</dependentAssembly>
There is definitely something weird with this issue. I was developing an app on my local server which ran fine but got this error when I uploaded the app to our server. The server has oracle client installed. After looking at this thread I copied the two DLLs (Oracle.ManagedDataAccess.dll & Oracle.ManagedDataAccess.EntityFramework.dll) from within oracle client and replaced the versions in my app bin directory. That fixed the issue.
In my scenario, i have a console application consuming a class library database utility.
I had to reference the Oracle.ManagedDataAccess also on the console application so it can find the dll on runtime.
I don't know if this is the best approach, but worked for me.
good afternoon
I want to share how I solved this same error:
I started by starting visual studio 2019 cmd as administrator.
I ran the following command line in cmd: gacutil -u Oracle.ManagedDataAccess
Basically this command line will remove the Oracle reference from the GAC (Global Assembly Cache), this way it will only get the reference from the package that is in the project (which nuget installs) and not from the oracle client.
You need to install the Oracle Client drivers. The .NET packages don't contain them; they provide a translation from the managed world to the unmanaged. The drivers are in the unmanaged world and need to be installed properly.

Error about Single Signon using Azure AD

I tried to implement a single sign-on app following the tutorial here
http://geoffwebbercross.blogspot.com/2014/05/adding-azure-ad-single-sign-on-to.html
I added an active directory in azure and added a user for this tenant. Then I built a small app in VS2013. I used organizational accounts and typed in the domain name, logged in and created the project. While creating the project, there poped up a dialogue box said
Request_BadRequest: Invalid value found for property 'identifierUris' fo resource 'Application'
And I closed that. I tried to run the project on my local machine. It will have the information like this.
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information:
Module
IIS Web Core
Notification
Unknown
Handler
Not yet determined
Error Code
0x80070032
Config Error
The configuration section 'system.identityModel' cannot be read because it is missing a section declaration.
Config File
Requested URL
http:
Physical Path
Logon Method
Not yet determined
Logon User
Not yet determined
Request Tracing Directory
D:\My Documents\IISExpress\TraceLogFiles\
Config Source:
34: </system.web>
35: <system.identityModel>
36: <identityConfiguration>
More Information:
This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
If you see the text "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined", this error is because you are running a .NET Framework 3.5-based application in .NET Framework 4. If you are running WebMatrix, to resolve this problem, go to the Settings node to set the .NET Framework version to ".NET 2". You can also remove the extra sections from the web.config file.
View more information ยป
Any ideas of how to solve this issue?
I'm not sure what the root cause was (why you got the error while creating the project), but the following should resolve the error you're seeing when running the app.
In the the <configSections> section of your web.config you need to have the system.identityModel section defined. The entries should look something like this:
<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</configSections>

Configuring Enterprise Library 5.0 Data Access Application Block

I'm trying to figure out how to configure the enterprise library 5.0 Data Access Application Block.
When running my unittest, I get the following error:
Microsoft.Practices.ServiceLocation.ActivationException was caught
Message=Activation error occured while trying to get instance of type Database, key "PokerAdviserProvider"
InnerException: Microsoft.Practices.Unity.ResolutionFailedException
Message=Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "PokerAdviserProvider".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value.
The line of code where I get this:
var db = DatabaseFactory.CreateDatabase("PokerAdviserProvider");
App.config:
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
</configSections>
<dataConfiguration defaultDatabase="PokerAdviserProvider" />
<connectionStrings>
<add name="PokerAdviserProvider" connectionString="server=(localhost);Initial Catalog=PokerAdviser;uid=abc;pwd=xyz"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
I've been googling around a bit and found some answers that these settings should also be put in the app.Config of my unittest-project, but that didn't make a difference.
I'm a bit stuck here, so any help is highly appreciated.
Edit:
I referenced the correct dll's (the ones from Program Files, not from the source code), so that isn't the problemneither.
I finally fixed this problem:
Error: Activation error occured while trying to get instance of type Database, key "<database name>"
Inner Exception: Resolution of the dependency failed, type = Microsoft.Practices.EnterpriseLibrary.Data.Database
I was running VS 2010 on windows 7, Enlib 5.0. The following worked for me. Wanted to spread the word around
Make sure you have proper reference to Microsoft.Practices.Unity.dll
Get the latest service pack for VS 2010
Finally figured it out. I use the DAAB in a class-library of my webservice and thought I had to create an app.config in that library. Should have know that this could not work. My mind was probably far far away when doing this...
I did the configuration in the web.config of the webservice and all runs smoothly now.
Refer to these two good posts post1 & post2 about Enterprise Library Configuration

Categories

Resources