I have a problem. I'm learning from MTaulty's video: http://channel9.msdn.com/blogs/mtaulty/prism--silverlight-part-2-dependency-injection-with-unity. And I have a problem with .config file which he creates at 18:00 min. There is no possibility to see what is in
<section type=".."
I wrote:
type="Microsoft.Practises.Unity.Configuration.UnityConfigurationSection, Microsoft.Practises.Unity.Configuration" />
but it does not work. I don't have idea what is wrong. I have a mistake that VisualStudio can't load file'Microsoft.Practises.Unity.Configuration and find a file.
thanks for help!
Declaring a configuration section handler in the Machine.config file enables you to use the configuration section in any application configuration file on that computer, unless the allowDefinition attribute specifies otherwise. The following example shows how to define a configuration section and define settings for that section:
The app.config file is a basic piece of the .NET Framework, yet I’ve seen several projects putting their configuration in other places (like plain text files or the registry). Unless you have a very good reason to do so, it’s more convenient and familiar to use the app.config file.
ConfigSections is the name of the namespace. Then the section is declared in App.config file as follows: To read companyAddress settings from App.config, we have to use the ConfigurationSettings.GetConfig as follows: ConfigurationSettings.GetConfig - Returns configuration settings for a user-defined configuration section.
The .NET Framework provides a predefined configuration section called appSettings. This section is declared in the Machine.config file as follows: The sample declaration of the appSettings is: Application settings are defined in an external file, which should be in the application bin folder.
If you want to specify modules via config file the Prism Guide on MSDN does a good job explaining that.
Quote from the Guide
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="modules"
type="Microsoft.Practices.Prism.Modularity.ModulesConfigurationSection, Microsoft.Practices.Prism"/>
</configSections>
<modules>
<module assemblyFile="ModularityWithUnity.Desktop.ModuleE.dll" moduleType="ModularityWithUnity.Desktop.ModuleE, ModularityWithUnity.Desktop.ModuleE, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="ModuleE" startupLoaded="false" />
<module assemblyFile="ModularityWithUnity.Desktop.ModuleF.dll" moduleType="ModularityWithUnity.Desktop.ModuleF, ModularityWithUnity.Desktop.ModuleF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="ModuleF" startupLoaded="false">
<dependencies>
<dependency moduleName="ModuleE"/>
</dependencies>
</module>
</modules>
</configuration>
For Prism 6.0 section type has changed to Prism.Modularity.ModulesConfigurationSection, Prism.Wpf
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="modules" type="Prism.Modularity.ModulesConfigurationSection, Prism.Wpf" />
</configSections>
<modules>
*** register your modules here ****
</modules>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With