Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App.config file and section type

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!

like image 996
Andrzej Avatar asked Aug 12 '12 10:08

Andrzej


People also ask

How do I use the configuration section in a configuration file?

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:

What is the app config file?

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.

How to read companyaddress settings from 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.

How to define application settings in the machine config file?

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.


2 Answers

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>
like image 151
shriek Avatar answered Oct 20 '22 14:10

shriek


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>
like image 41
alhpe Avatar answered Oct 20 '22 12:10

alhpe