EDN Admin
Well-known member
I am getting this error
The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
My Web.Config sections looks like below
<pre class="prettyprint <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="true" />
<section name="unity"
type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
</configSections>
...
..
...
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity
<!-- Lifetime manager types should be inserted
if you need lifetime managers -->
<alias alias="singleton"
type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager,
Microsoft.Practices.Unity" />
<alias alias="external"
type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager,
Microsoft.Practices.Unity" />
<alias alias="ICategoryDataManagerA"
type="ComputingAdventures.DataAccess.ICategoryDataManager,
ComputingAdventures.DataAccess" />
<container name="MyContainer
<register type="ICategoryDataManagerA" mapTo="ComputingAdventures.DataAccess.SqlServer.CategoryDataManager,
ComputingAdventures.DataAccess.SqlServer
<lifetime type="singleton" />
</register>
</container>
</unity>
[/code]
<br/>
And my code looks like below
<pre class="prettyprint IUnityContainer container = new UnityContainer();
try
{
//Getting error here
container.LoadConfiguration("MyContainer");
}
catch (FileLoadException exc)
{
string msg = exc.Message;
}
T t = container.Resolve<T>();[/code]
<br/>
I am following this article: http://www.codeproject.com/Articles/143258/Revisiting-XML-Configurations-In-Unity http://www.codeproject.com/Articles/143258/Revisiting-XML-Configurations-In-Unity <hr class="sig Chintan
View the full article
The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
My Web.Config sections looks like below
<pre class="prettyprint <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="true" />
<section name="unity"
type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
</configSections>
...
..
...
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity
<!-- Lifetime manager types should be inserted
if you need lifetime managers -->
<alias alias="singleton"
type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager,
Microsoft.Practices.Unity" />
<alias alias="external"
type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager,
Microsoft.Practices.Unity" />
<alias alias="ICategoryDataManagerA"
type="ComputingAdventures.DataAccess.ICategoryDataManager,
ComputingAdventures.DataAccess" />
<container name="MyContainer
<register type="ICategoryDataManagerA" mapTo="ComputingAdventures.DataAccess.SqlServer.CategoryDataManager,
ComputingAdventures.DataAccess.SqlServer
<lifetime type="singleton" />
</register>
</container>
</unity>
[/code]
<br/>
And my code looks like below
<pre class="prettyprint IUnityContainer container = new UnityContainer();
try
{
//Getting error here
container.LoadConfiguration("MyContainer");
}
catch (FileLoadException exc)
{
string msg = exc.Message;
}
T t = container.Resolve<T>();[/code]
<br/>
I am following this article: http://www.codeproject.com/Articles/143258/Revisiting-XML-Configurations-In-Unity http://www.codeproject.com/Articles/143258/Revisiting-XML-Configurations-In-Unity <hr class="sig Chintan
View the full article