Home > Uncategorized > Activation error occurred while trying to get instance of type Database, key “KEYNAME”

Activation error occurred while trying to get instance of type Database, key “KEYNAME”

In my case  providerName=”System.Data.SqlClient” tag is missing from connection string

<add name=”KEYNAME” connectionString=”Data Source=.\SQLEXPRESSR2;Initial Catalog=DBNAME;Integrated Security=False; User ID=userid;Password=password; Max Pool Size=500″ providerName=”System.Data.SqlClient“/>

Below is from more error log

Type :Microsoft.Practices.ServiceLocation.ActivationException
Original Message : Activation error occured while trying to get instance of type Database, key “<KEYNAME>”
Source :Microsoft.Practices.ServiceLocation
Stack Trace : at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key)
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.InnerCreateDatabase(String name)
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase(String name)

Inner Exception Message is :Resolution of the dependency failed, type = “Microsoft.Practices.EnterpriseLibrary.Data.Database”, name = “<KEYNAME>”.
Exception occurred while: while resolving.
Exception is: InvalidOperationException – The type Database cannot be constructed. You must configure the container to supply this value.
———————————————–
At the time of the exception, the container was:

Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,<KEYNAME>

Inner Exception Stack Trace is : at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
at Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)

Comments:2

Leave a Reply
  1. Reply Ihsan Malik 13/11/21

    it was really helpful i am able to resolve my issue with this help….

Leave a Reply to Ihsan Malik Cancel reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

TOP