patterns & practices - Unity - Discussions - separate config file path issue: "I have created a unity.config file & placed it in my website bin folder. I have used following code to configure the container.
var assembly = Assembly.GetExecutingAssembly();
Uri uriPath = new Uri(assembly.CodeBase);
string path = Path.Combine(Path.GetDirectoryName(uriPath.AbsolutePath.Replace('%20',' ')), 'unity.config');
var map = new ExeConfigurationFileMap() { ExeConfigFilename = path };
var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
var section = (UnityConfigurationSection)config.GetSection('unity');
var container = new UnityContainer();
section.Containers['container'].Configure(container);
return container;
A typical thing happened in my code. The uriPath.AbsolutePath returns following path which is the location of my machine
E:\Working%20Folder\IocUnity\IocUnity.Website\bin\
Now if I go with this path, the config file didn't load but if I replace %20 with a space, it worked fine. I could not sort why it is behaving like this. If you look at my code, you can see I used Replace function to get rid of this problem.
Any idea....."
Sunday, January 31, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment