unitycontainer / configuration

Unity.Configuration package
Apache License 2.0
13 stars 13 forks source link

Unity.Configuration.UnityConfigurationSection is wrong? #18

Open 273299007 opened 5 years ago

273299007 commented 5 years ago

I used Unity(5.10.2) and Unity.Configuration(5.10.0) .

I coppied the below setting to my app.config file(.net core2.0 console application) from https://github.com/unitycontainer/configuration/wiki/Format-of-the-Unity-Configuration-File

<section name="unity" type="Unity.Configuration.UnityConfigurationSection, Unity.Configuration"/>

1.I run the console application, and throw below exception at line of var section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");

System.Configuration.ConfigurationErrorsException HResult=0x80131902 Message=An error occurred creating the configuration section handler for unity: Could not load type 'Unity.Configuration.UnityConfigurationSection' from assembly 'Unity.Configuration'. (*****bin\Debug\netcoreapp2.0\***.dll.config line 4) Source=System.Configuration.ConfigurationManager StackTrace: at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Configuration.ConfigurationManager.GetSection(String sectionName)

2. After I changed the setting to below: <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,Unity.Configuration"/> below code will not throw above exception var section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");

So the setting of "type" in section tag is wrong in https://github.com/unitycontainer/configuration/wiki/Format-of-the-Unity-Configuration-File ? Thank you so much!

ENikS commented 4 years ago

This namespace will be implemented in 6.0