Note that there are some explanatory texts on larger screens.

plurals
  1. POUnity, LoadConfiguration from alternative files and sectionExtension
    primarykey
    data
    text
    <p>Wish you all good mood! Please help me with Unity.</p> <p>My App.config file contains:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/&gt; &lt;/configSections&gt; &lt;system.diagnostics&gt; &lt;sources&gt; &lt;source name="TraceTest" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch" &gt; &lt;listeners&gt; &lt;add name="console" /&gt; &lt;remove name ="Default" /&gt; &lt;/listeners&gt; &lt;/source&gt; &lt;/sources&gt; &lt;switches&gt; &lt;add name="SourceSwitch" value="All" /&gt; &lt;/switches&gt; &lt;sharedListeners&gt; &lt;add name="console" type="System.Diagnostics.ConsoleTraceListener" initializeData="false"/&gt; &lt;/sharedListeners&gt; &lt;trace autoflush="true" indentsize="4"&gt; &lt;listeners&gt; &lt;add name="console" /&gt; &lt;/listeners&gt; &lt;/trace&gt; &lt;/system.diagnostics&gt; &lt;unity xmlns="http://schemas.microsoft.com/practices/2010/unity"&gt; &lt;assembly name="ContextDownloader"/&gt; &lt;namespace name="ContextDownloader.Log"/&gt; &lt;namespace name="System.Diagnostics"/&gt; &lt;sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration"/&gt; &lt;container&gt; &lt;extension type="Interception"/&gt; &lt;register type="ILogWorker" mapTo="FileLogWorker"&gt; &lt;interceptor type="InterfaceInterceptor"/&gt; &lt;interceptionBehavior type="TraceBehavior"/&gt; &lt;/register&gt; &lt;register type="TraceSource" name="interception"&gt; &lt;constructor&gt; &lt;param name="name" type="System.String" value="TraceTest" /&gt; &lt;/constructor&gt; &lt;/register&gt; &lt;register type="TraceBehavior"&gt; &lt;constructor&gt; &lt;param name="source" dependencyName="interception" /&gt; &lt;/constructor&gt; &lt;/register&gt; &lt;/container&gt; &lt;/unity&gt; &lt;/configuration&gt; </code></pre> <p>I load configuration from App.config in my code:</p> <pre><code>var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = "App.config" }; Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); var unitySection = (UnityConfigurationSection)configuration.GetSection("unity"); var container = new UnityContainer(); </code></pre> <p>So it throws exception </p> <blockquote> <p>Unhandled Exception: System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for unity: The type name or alias Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigu rationExtension, Microsoft.Practices.Unity.Interception.Configuration could not be resolved. Please check your configuration file and verify this type name.</p> </blockquote> <p>in line <code>var unitySection = (UnityConfigurationSection)configuration.GetSection("unity");</code>. How I can load Microsoft.Practices.Unity.Interception.Configuration assembly?</p> <p>More details about application. I have console application and library. I have just call one method in my console application and then all logic are in library.</p> <p>Thanks for your answer about copy this Microsoft.Practices.Unity.InterceptionExtension.Configuration.dll to output library. Can you help me to load system.diagnostic section too?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload