<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>patterns &amp; practices - Unity</title><link>http://unity.codeplex.com/project/feeds/rss</link><description>The Unity Application Block &amp;#40;Unity&amp;#41; is a lightweight extensible dependency injection container with support for constructor, property, and method call injection.      Unity addresses the issues faced by developers engaged in component-based software engineering. Modern business applications consist of custom business objects and components that perform specific or generic tasks within the application, in addition to components that individually address cross cutting concerns such as logging, authentication, authorization, caching, and exception handling.       The key to successfully building such applications is to achieve a decoupled or very loosely coupled design. Loosely coupled applications are more flexible and easier to maintain. They are also easier to test during development. You can mock up shims &amp;#40;lightweight mock implementations&amp;#41; of objects that have strong concrete dependencies&amp;#59; such as database connections, network connections, ERP connections, and rich user interface components.       Dependency injection is a prime technique for building loosely coupled applications. It provides ways to handle the dependencies between objects. For example, an object that processes customer information may depend on other objects that access the data store, validate the information, and check that the user is authorized to perform updates. Dependency injection techniques can ensure that the customer class correctly instantiates and populates all of these objects, especially where the dependencies may be abstract.</description><item><title>New Post: Unity 3.0 registration troubles</title><link>http://unity.codeplex.com/discussions/447315</link><description>&lt;div style="line-height: normal;"&gt;Thanks, Randy, that was it.&lt;br /&gt;
&lt;br /&gt;
Actually, the TestAndDebugLoggingInterceptor is in a different namespace, but the problem was just what you said: it was not fully qualified.  I did have the sectionExtension declaration in the app.config, but I missed the qualification on the TestAndDebugLoggingInterceptor.  Thanks!&lt;br /&gt;
&lt;/div&gt;</description><author>PeterHowe</author><pubDate>Mon, 17 Jun 2013 19:59:45 GMT</pubDate><guid isPermaLink="false">New Post: Unity 3.0 registration troubles 20130617075945P</guid></item><item><title>New Post: Unity 3.0 registration troubles</title><link>http://unity.codeplex.com/discussions/447315</link><description>&lt;div style="line-height: normal;"&gt;You didn't post the full config so I'll mention that you need to add the sectionExtension:&lt;br /&gt;
&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
&lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;sectionExtension&lt;/span&gt; &lt;span style="color:Red;"&gt;type&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;

&lt;/pre&gt;&lt;/div&gt;Also, the type TestAndDebugLoggingInterceptor needs to be qualified unless an alias is created or the assembly and namespace search tags added to the config file.&lt;br /&gt;
&lt;br /&gt;
The configuration should look something like this:&lt;br /&gt;
&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;

&lt;span style="color:Blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#A31515;"&gt;xml&lt;/span&gt; &lt;span style="color:Red;"&gt;version&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;1.0&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Red;"&gt;encoding&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;utf-8&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;?&amp;gt;&lt;/span&gt;
&lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;configuration&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;configSections&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;section&lt;/span&gt; &lt;span style="color:Red;"&gt;name&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;unity&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Red;"&gt;type&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style="color:Blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;configSections&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;unity&lt;/span&gt; &lt;span style="color:Red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;http://schemas.microsoft.com/practices/2010/unity&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;sectionExtension&lt;/span&gt; &lt;span style="color:Red;"&gt;type&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;container&lt;/span&gt; &lt;span style="color:Red;"&gt;name&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;InterceptTestContainer&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
      &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;extension&lt;/span&gt; &lt;span style="color:Red;"&gt;type&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Interception&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;register&lt;/span&gt; &lt;span style="color:Red;"&gt;type&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Paychex.IP.Common.TestObjects.TestClass, TestObjects&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Red;"&gt;mapTo&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Paychex.IP.Common.TestObjects.TestClass, TestObjects&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
        &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;interceptor&lt;/span&gt; &lt;span style="color:Red;"&gt;type&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;VirtualMethodInterceptor&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;interceptionBehavior&lt;/span&gt; &lt;span style="color:Red;"&gt;type&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;Paychex.IP.Common.TestObjects.TestAndDebugLoggingInterceptor, TestObjects&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span style="color:Blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;register&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:Blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;container&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;    
  &lt;span style="color:Blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;unity&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
&lt;span style="color:Blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;configuration&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;~~&lt;br /&gt;
Randy Levy&lt;br /&gt;
&lt;a href="m&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#116;o&amp;#58;&amp;#101;&amp;#110;&amp;#116;&amp;#x6c;i&amp;#x62;&amp;#x2e;&amp;#x73;&amp;#117;&amp;#x70;&amp;#x70;o&amp;#114;&amp;#x74;&amp;#64;&amp;#x6c;&amp;#105;v&amp;#101;&amp;#x2e;&amp;#99;&amp;#x6f;&amp;#109;"&gt;&amp;#x65;n&amp;#x74;&amp;#108;&amp;#105;&amp;#x62;&amp;#46;&amp;#115;&amp;#x75;&amp;#112;&amp;#112;&amp;#x6f;&amp;#x72;&amp;#x74;&amp;#x40;&amp;#x6c;&amp;#x69;&amp;#118;&amp;#x65;&amp;#x2e;c&amp;#x6f;&amp;#x6d;&lt;/a&gt;&lt;br /&gt;
Enterprise Library support engineer&lt;br /&gt;
&lt;a href="entlib.codeplex.com/wikipage?title=Support%20How-to" rel="nofollow"&gt;Support How-to&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</description><author>randylevy</author><pubDate>Mon, 17 Jun 2013 19:28:34 GMT</pubDate><guid isPermaLink="false">New Post: Unity 3.0 registration troubles 20130617072834P</guid></item><item><title>New Post: Unity 3.0 registration troubles</title><link>http://unity.codeplex.com/discussions/447315</link><description>&lt;div style="line-height: normal;"&gt;My bad, I said the parameter passed to container.LoadConfiguration was the type being intercepted, but it is actually the container name from the app.config file (&amp;quot;InterceptTestContainer.&amp;quot;)  It would seem that the code is finding that container name in the app.config file, but doesn't like the assemblies or paths being specified.  The relevant section from the app.config file is:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;container name=&amp;quot;InterceptTestContainer&amp;quot;&amp;gt;
   &amp;lt;extension type=&amp;quot;Interception&amp;quot; /&amp;gt;
   &amp;lt;register type=&amp;quot;Paychex.IP.Common.TestObjects.TestClass, TestObjects&amp;quot; mapTo=&amp;quot;Paychex.IP.Common.TestObjects.TestClass, TestObjects&amp;quot;&amp;gt;
      &amp;lt;interceptor type=&amp;quot;VirtualMethodInterceptor&amp;quot;/&amp;gt;
      &amp;lt;interceptionBehavior type=&amp;quot;TestAndDebugLoggingInterceptor&amp;quot; /&amp;gt;
   &amp;lt;/register&amp;gt;
&amp;lt;/container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

Again, the syntax is based on what I have read in MSDN.&lt;br /&gt;
&lt;/div&gt;</description><author>PeterHowe</author><pubDate>Mon, 17 Jun 2013 19:04:08 GMT</pubDate><guid isPermaLink="false">New Post: Unity 3.0 registration troubles 20130617070408P</guid></item><item><title>New Post: Unity 3.0 registration troubles</title><link>http://unity.codeplex.com/discussions/447315</link><description>&lt;div style="line-height: normal;"&gt;Thanks in advance for your help...&lt;br /&gt;
&lt;br /&gt;
I am struggling with Unity 3.0 trying to get types and interception registered correctly.  The problem begins with Unity not liking the app.config file.  Here is a snippet from a test program:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;       try
        {
            container.LoadConfiguration(interceptedName);
        }
        catch (Exception ex)
        {
            Console.Write(&amp;quot;Exception:&amp;quot;); // just so we can break and examine the exception
            Console.WriteLine(ex.Message);
            // This should not be necessary in Code!
            container.RegisterType&amp;lt;TestClass&amp;gt;(
                new Interceptor&amp;lt;VirtualMethodInterceptor&amp;gt;(),
                new InterceptionBehavior&amp;lt;TestAndDebugLoggingInterceptor&amp;gt;());
        }
&lt;/code&gt;&lt;/pre&gt;

&amp;quot;interceptedName&amp;quot; is equal to &amp;quot;TestAndDebugLoggingInterceptor.&amp;quot;  It throws an InvalidOperationException:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt; The type name or alias 
      TestAndDebugLoggingInterceptor 
 could not be resolved. Please check your configuration file and verify this type name.
&lt;/code&gt;&lt;/pre&gt;

The call to container.RegisterType proceeds without an exception.  However, when I trace through the code, the interceptor (TestAndDebugLoggingInterceptor) is registered twice, and it indeed calls it twice before calling the target method(s) in TestClass.  At first, I thought that perhaps the registration from the app.config file was succeeding despite the exception.  But, commenting out the call to container.RegisterType results in an exception that the type cannot be resolved.&lt;br /&gt;
&lt;br /&gt;
I can post the app.config file if anyone wants to see it, but I am guessing at this point that it is not relevant, because of the exception being thrown.  Aside from whatever syntax or path error there is in the app.config file, does anyone have any idea why RegisterType ends up wrapping the targets twice?  The syntax for that call is straight out of MSDN examples, so I am somewhat stumped at this point.&lt;br /&gt;
&lt;br /&gt;
Thanks again.&lt;br /&gt;
&lt;/div&gt;</description><author>PeterHowe</author><pubDate>Mon, 17 Jun 2013 18:14:17 GMT</pubDate><guid isPermaLink="false">New Post: Unity 3.0 registration troubles 20130617061417P</guid></item><item><title>New Post: Resolving interface dependency in Unity 3.0</title><link>http://unity.codeplex.com/discussions/447218</link><description>&lt;div style="line-height: normal;"&gt;Your code and configuration looks OK.  I can inject a PersonDao interface into my controller.&lt;br /&gt;
&lt;br /&gt;
Can you post a small sample project?&lt;br /&gt;
&lt;br /&gt;
~~&lt;br /&gt;
Randy Levy&lt;br /&gt;
&lt;a href="m&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#116;o&amp;#58;&amp;#101;&amp;#110;&amp;#116;&amp;#x6c;i&amp;#x62;&amp;#x2e;&amp;#x73;&amp;#117;&amp;#x70;&amp;#x70;o&amp;#114;&amp;#x74;&amp;#64;&amp;#x6c;&amp;#105;v&amp;#101;&amp;#x2e;&amp;#99;&amp;#x6f;&amp;#109;"&gt;&amp;#x65;n&amp;#x74;&amp;#108;&amp;#105;&amp;#x62;&amp;#46;&amp;#115;&amp;#x75;&amp;#112;&amp;#112;&amp;#x6f;&amp;#x72;&amp;#x74;&amp;#x40;&amp;#x6c;&amp;#x69;&amp;#118;&amp;#x65;&amp;#x2e;c&amp;#x6f;&amp;#x6d;&lt;/a&gt;&lt;br /&gt;
Enterprise Library support engineer&lt;br /&gt;
&lt;a href="entlib.codeplex.com/wikipage?title=Support%20How-to" rel="nofollow"&gt;Support How-to&lt;/a&gt; &lt;br /&gt;
&lt;/div&gt;</description><author>randylevy</author><pubDate>Mon, 17 Jun 2013 13:41:55 GMT</pubDate><guid isPermaLink="false">New Post: Resolving interface dependency in Unity 3.0 20130617014155P</guid></item><item><title>New Post: Resolving interface dependency in Unity 3.0</title><link>http://unity.codeplex.com/discussions/447218</link><description>&lt;div style="line-height: normal;"&gt;I'm actually loading the configuration in another method; I didn't realize that UnityConfig did that for me.  Still, I am loading the configuration.  I have no problem injecting concrete classes (PersonDaoImpl); I only have problems if I try to inject a concrete implementation of an interface (PersonDaoImpl for a PersonDao).&lt;br /&gt;
&lt;br /&gt;
Thanks...&lt;br /&gt;
&lt;/div&gt;</description><author>Netrider6</author><pubDate>Mon, 17 Jun 2013 13:06:01 GMT</pubDate><guid isPermaLink="false">New Post: Resolving interface dependency in Unity 3.0 20130617010601P</guid></item><item><title>New Post: Resolving interface dependency in Unity 3.0</title><link>http://unity.codeplex.com/discussions/447218</link><description>&lt;div style="line-height: normal;"&gt;Did you uncomment the line in the RegisterType method of the App_Start/UnityConfig.cs file to load the configuration?&lt;br /&gt;
&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt; &lt;span style="color:Gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style="color:Green;"&gt;Registers the type mappings with the Unity container.&amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt; &lt;span style="color:Gray;"&gt;&amp;lt;param name=&amp;quot;container&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:Green;"&gt;The unity container to configure.&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt; &lt;span style="color:Gray;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;&lt;span style="color:Green;"&gt;There is no need to register concrete types such as controllers or API controllers (unless you want to &lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt;&lt;span style="color:Green;"&gt; change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.&amp;lt;/remarks&amp;gt;&lt;/span&gt;
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;static&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; RegisterTypes(IUnityContainer container)
        {
            &lt;span style="color:Green;"&gt;// NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.&lt;/span&gt;
            container.LoadConfiguration();

            &lt;span style="color:Green;"&gt;// TODO: Register your types here&lt;/span&gt;
            &lt;span style="color:Green;"&gt;// container.RegisterType&amp;lt;IProductRepository, ProductRepository&amp;gt;();&lt;/span&gt;
        }

&lt;/pre&gt;&lt;/div&gt;~~&lt;br /&gt;
Randy Levy&lt;br /&gt;
&lt;a href="m&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#116;o&amp;#58;&amp;#101;&amp;#110;&amp;#116;&amp;#x6c;i&amp;#x62;&amp;#x2e;&amp;#x73;&amp;#117;&amp;#x70;&amp;#x70;o&amp;#114;&amp;#x74;&amp;#64;&amp;#x6c;&amp;#105;v&amp;#101;&amp;#x2e;&amp;#99;&amp;#x6f;&amp;#109;"&gt;&amp;#x65;n&amp;#x74;&amp;#108;&amp;#105;&amp;#x62;&amp;#46;&amp;#115;&amp;#x75;&amp;#112;&amp;#112;&amp;#x6f;&amp;#x72;&amp;#x74;&amp;#x40;&amp;#x6c;&amp;#x69;&amp;#118;&amp;#x65;&amp;#x2e;c&amp;#x6f;&amp;#x6d;&lt;/a&gt;&lt;br /&gt;
Enterprise Library support engineer&lt;br /&gt;
&lt;a href="entlib.codeplex.com/wikipage?title=Support%20How-to" rel="nofollow"&gt;Support How-to&lt;/a&gt; &lt;br /&gt;
&lt;/div&gt;</description><author>randylevy</author><pubDate>Mon, 17 Jun 2013 06:01:43 GMT</pubDate><guid isPermaLink="false">New Post: Resolving interface dependency in Unity 3.0 20130617060143A</guid></item><item><title>New Post: Resolving interface dependency in Unity 3.0</title><link>http://unity.codeplex.com/discussions/447218</link><description>&lt;div style="line-height: normal;"&gt;I'm trying to get dependency injection working on a MVC 4 web application using Unity 3.0.  I have the Unity bootstrapper for MVC 4 applications installed, and I've set up my web.config file and Global.asax files to start up the Unity configuration.  If I use concrete objects, it works without problems, but I start getting exceptions if I start to try to inject concrete implementations of interfaces instead.&lt;br /&gt;
&lt;br /&gt;
For example, my PersonController looks like this:&lt;br /&gt;
&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
&lt;span style="color:Blue;"&gt;namespace&lt;/span&gt; RebuildingSite.Controllers
{
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; PersonController : Controller
    {
        &lt;span style="color:Blue;"&gt;private&lt;/span&gt; &lt;span style="color:Blue;"&gt;static&lt;/span&gt; &lt;span style="color:Blue;"&gt;readonly&lt;/span&gt; LogWriter log = LoggingFactory.GetLogWriter();

        [Dependency]
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; PersonDao ThePersonDao { &lt;span style="color:Blue;"&gt;get&lt;/span&gt;; &lt;span style="color:Blue;"&gt;set&lt;/span&gt;; }

        &lt;span style="color:Green;"&gt;//&lt;/span&gt;
        &lt;span style="color:Green;"&gt;// GET: /Person/&lt;/span&gt;
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; ActionResult Index(&lt;span style="color:Blue;"&gt;string&lt;/span&gt; sortOrder, &lt;span style="color:Blue;"&gt;string&lt;/span&gt; currentFilter, &lt;span style="color:Blue;"&gt;string&lt;/span&gt; searchString, &lt;span style="color:Blue;"&gt;int&lt;/span&gt;? page)
        {
            ViewBag.CurrentSort = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? &lt;span style="color:#A31515;"&gt;&amp;quot;Name desc&amp;quot;&lt;/span&gt; : &lt;span style="color:#A31515;"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;
            ViewBag.CitySortParm = sortOrder == &lt;span style="color:#A31515;"&gt;&amp;quot;City&amp;quot;&lt;/span&gt; ? &lt;span style="color:#A31515;"&gt;&amp;quot;City desc&amp;quot;&lt;/span&gt; : &lt;span style="color:#A31515;"&gt;&amp;quot;City&amp;quot;&lt;/span&gt;;

            &lt;span style="color:Blue;"&gt;if&lt;/span&gt; (Request.HttpMethod == &lt;span style="color:#A31515;"&gt;&amp;quot;GET&amp;quot;&lt;/span&gt;)
            {
                searchString = currentFilter;
            }
            &lt;span style="color:Blue;"&gt;else&lt;/span&gt;
            {
                page = 1;
            }

            ViewBag.CurrentFilter = searchString;

            page = page == &lt;span style="color:Blue;"&gt;null&lt;/span&gt; ? 1 : page;

            &lt;span style="color:Blue;"&gt;var&lt;/span&gt; people = ThePersonDao.GetPeopleByName(searchString, sortOrder, 10, (&lt;span style="color:Blue;"&gt;int&lt;/span&gt;)page);

            &lt;span style="color:Blue;"&gt;return&lt;/span&gt; View(people);
        }
}
&lt;/pre&gt;&lt;/div&gt;And the Unity section of my web.config looks like this:&lt;br /&gt;
&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
  &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;unity&lt;/span&gt; &lt;span style="color:Red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;http://schemas.microsoft.com/practices/2010/unity&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
    &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;namespace&lt;/span&gt; &lt;span style="color:Red;"&gt;name&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;RebuildingModel.Dao&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;namespace&lt;/span&gt; &lt;span style="color:Red;"&gt;name&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;RebuildingModel.Dao.Impl&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;namespace&lt;/span&gt; &lt;span style="color:Red;"&gt;name&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;RebuildingSite.Controllers&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
    
    &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;assembly&lt;/span&gt; &lt;span style="color:Red;"&gt;name&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;RebuildingModel&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;assembly&lt;/span&gt; &lt;span style="color:Red;"&gt;name&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;RebuildingSite&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
    
    &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;container&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
      &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;register&lt;/span&gt; &lt;span style="color:Red;"&gt;type&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;PersonDao&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Red;"&gt;mapTo&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;PersonDaoImpl&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span style="color:Blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#A31515;"&gt;register&lt;/span&gt; &lt;span style="color:Red;"&gt;type&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;PersonController&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Red;"&gt;mapTo&lt;/span&gt;&lt;span style="color:Blue;"&gt;=&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:Blue;"&gt;PersonController&lt;/span&gt;&lt;span style="color:Black;"&gt;&amp;quot;&lt;/span&gt; &lt;span style="color:Blue;"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style="color:Blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;container&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
  &lt;span style="color:Blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#A31515;"&gt;unity&lt;/span&gt;&lt;span style="color:Blue;"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;My PersonDaoImpl does implement PersonDao:&lt;br /&gt;
&lt;br /&gt;
PersonDao:&lt;br /&gt;
&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
&lt;span style="color:Blue;"&gt;namespace&lt;/span&gt; RebuildingModel.Dao
{
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;interface&lt;/span&gt; PersonDao : StandardDaoInterface&amp;lt;&lt;span style="color:Blue;"&gt;int&lt;/span&gt;, Person&amp;gt;
    {
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt; &lt;span style="color:Gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt;&lt;span style="color:Green;"&gt; Search for a person by first or last name, sorting and sizing the resultant list as appropriate.&lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt; &lt;span style="color:Gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt; &lt;span style="color:Gray;"&gt;&amp;lt;param name=&amp;quot;name&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:Green;"&gt;Any search string that would be contained in the first or last name.&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt; &lt;span style="color:Gray;"&gt;&amp;lt;param name=&amp;quot;sort&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:Green;"&gt;The Person field on which to sort&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt; &lt;span style="color:Gray;"&gt;&amp;lt;param name=&amp;quot;pageSize&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:Green;"&gt;The size of the page&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt; &lt;span style="color:Gray;"&gt;&amp;lt;param name=&amp;quot;pageNumber&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color:Green;"&gt;What page number is being returned&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt; &lt;span style="color:Gray;"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="color:Green;"&gt;A list of people with a first or last name containing &amp;quot;name&amp;quot;, sorted by &amp;quot;sort&amp;quot;, &lt;/span&gt;
        &lt;span style="color:Gray;"&gt;///&lt;/span&gt;&lt;span style="color:Green;"&gt; on &amp;quot;pageNumber&amp;quot; page number, with no more than &amp;quot;pageSize&amp;quot; people returned.&amp;lt;/returns&amp;gt;&lt;/span&gt;
        IPagedList&amp;lt;Person&amp;gt; GetPeopleByName(&lt;span style="color:Blue;"&gt;string&lt;/span&gt; name, &lt;span style="color:Blue;"&gt;string&lt;/span&gt; sortOrder, &lt;span style="color:Blue;"&gt;int&lt;/span&gt; pageSize, &lt;span style="color:Blue;"&gt;int&lt;/span&gt; pageNumber);
    }
}
&lt;/pre&gt;&lt;/div&gt;PersonDaoImpl:&lt;br /&gt;
&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
&lt;span style="color:Blue;"&gt;namespace&lt;/span&gt; RebuildingModel.Dao.Impl
{
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; PersonDaoImpl : PersonDao
    {
        &lt;span style="color:Blue;"&gt;private&lt;/span&gt; &lt;span style="color:Blue;"&gt;static&lt;/span&gt; &lt;span style="color:Blue;"&gt;readonly&lt;/span&gt; LogWriter log = LoggingFactory.GetLogWriter();

        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; PersonDaoImpl()
        {
        }

        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; PagedList.IPagedList&amp;lt;Person&amp;gt; GetPeopleByName(&lt;span style="color:Blue;"&gt;string&lt;/span&gt; name, &lt;span style="color:Blue;"&gt;string&lt;/span&gt; sortOrder, &lt;span style="color:Blue;"&gt;int&lt;/span&gt; pageSize, &lt;span style="color:Blue;"&gt;int&lt;/span&gt; pageNumber)
        {
            log.Write(&lt;span style="color:#A31515;"&gt;&amp;quot;Searching for person name containing &amp;quot;&lt;/span&gt; + name + &lt;span style="color:#A31515;"&gt;&amp;quot; sorting by &amp;quot;&lt;/span&gt; + sortOrder +
                      &lt;span style="color:#A31515;"&gt;&amp;quot; page size &amp;quot;&lt;/span&gt; + pageSize + &lt;span style="color:#A31515;"&gt;&amp;quot;, page number &amp;quot;&lt;/span&gt; + pageNumber);

            &lt;span style="color:Blue;"&gt;using&lt;/span&gt; (&lt;span style="color:Blue;"&gt;var&lt;/span&gt; db = &lt;span style="color:Blue;"&gt;new&lt;/span&gt; RebuildingTogetherEntities())
            {
                &lt;span style="color:Blue;"&gt;var&lt;/span&gt; people = &lt;span style="color:Blue;"&gt;from&lt;/span&gt; p &lt;span style="color:Blue;"&gt;in&lt;/span&gt; db.People
                             &lt;span style="color:Blue;"&gt;select&lt;/span&gt; p;

                &lt;span style="color:Blue;"&gt;if&lt;/span&gt; (!String.IsNullOrEmpty(name))
                {
                    people = people.Where( p =&amp;gt; p.LastName.ToUpper().Contains(name) ||
                                                p.FirstName.ToUpper().Contains(name) );
                }

                &lt;span style="color:Blue;"&gt;switch&lt;/span&gt; (sortOrder)
                {
                    &lt;span style="color:Blue;"&gt;case&lt;/span&gt; &lt;span style="color:#A31515;"&gt;&amp;quot;Name desc&amp;quot;&lt;/span&gt;:
                        people = people.OrderByDescending(p =&amp;gt; p.LastName);
                        &lt;span style="color:Blue;"&gt;break&lt;/span&gt;;
                    &lt;span style="color:Blue;"&gt;case&lt;/span&gt; &lt;span style="color:#A31515;"&gt;&amp;quot;City desc&amp;quot;&lt;/span&gt;:
                        people = people.OrderByDescending(p =&amp;gt; p.City);
                        &lt;span style="color:Blue;"&gt;break&lt;/span&gt;;
                    &lt;span style="color:Blue;"&gt;case&lt;/span&gt; &lt;span style="color:#A31515;"&gt;&amp;quot;City&amp;quot;&lt;/span&gt;:
                        people = people.OrderBy(p =&amp;gt; p.City);
                        &lt;span style="color:Blue;"&gt;break&lt;/span&gt;;
                    &lt;span style="color:Blue;"&gt;default&lt;/span&gt;:
                        people = people.OrderBy(p =&amp;gt; p.LastName);
                        &lt;span style="color:Blue;"&gt;break&lt;/span&gt;;
                }

                &lt;span style="color:Blue;"&gt;return&lt;/span&gt; people.ToPagedList(pageNumber, pageSize);
            }
        }
}
&lt;/pre&gt;&lt;/div&gt;But, when I start the app, I get this error:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;6/16/2013 3:02:07 PM|System.InvalidOperationException: An error occurred when trying to create a controller of type 'RebuildingSite.Controllers.PersonController'. Make sure that the controller has a parameterless public constructor. ---&amp;gt; Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = &amp;quot;RebuildingSite.Controllers.PersonController&amp;quot;, name = &amp;quot;(none)&amp;quot;.
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type PersonDao does not have an accessible constructor.
-----------------------------------------------
At the time of the exception, the container was:

  Resolving RebuildingSite.Controllers.PersonController,(none)
  Resolving value for property PersonController.ThePersonDao
    Resolving RebuildingModel.Dao.PersonDao,(none)
 ---&amp;gt; System.InvalidOperationException: The type PersonDao does not have an accessible constructor.
   at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForNullExistingObject(IBuilderContext context)
   at lambda_method(Closure , IBuilderContext )
   at Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.&amp;lt;&amp;gt;c__DisplayClass1.&amp;lt;GetBuildMethod&amp;gt;b__0(IBuilderContext context)
   at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
...&lt;/code&gt;&lt;/pre&gt;

How do I inject an implementation of PersonDao rather than a concrete class like PersonDaoImpl?&lt;br /&gt;
&lt;br /&gt;
Thanks!&lt;br /&gt;
&lt;/div&gt;</description><author>Netrider6</author><pubDate>Sun, 16 Jun 2013 20:17:45 GMT</pubDate><guid isPermaLink="false">New Post: Resolving interface dependency in Unity 3.0 20130616081745P</guid></item><item><title>New Post: Unit3 LoadConfiguration() deprecated?</title><link>http://unity.codeplex.com/discussions/447163</link><description>&lt;div style="line-height: normal;"&gt;You're welcome, and tools like Resharper and others would have helped you, they do suggest such modifications&lt;br /&gt;
&lt;/div&gt;</description><author>homelchenko</author><pubDate>Sun, 16 Jun 2013 15:24:53 GMT</pubDate><guid isPermaLink="false">New Post: Unit3 LoadConfiguration() deprecated? 20130616032453P</guid></item><item><title>New Post: Unit3 LoadConfiguration() deprecated?</title><link>http://unity.codeplex.com/discussions/447163</link><description>&lt;div style="line-height: normal;"&gt;D'oh!  That was simple!  Thanks homelchenko, it works now.  I wish VS would suggest using statements for extension methods...&lt;br /&gt;
&lt;/div&gt;</description><author>Netrider6</author><pubDate>Sun, 16 Jun 2013 14:34:52 GMT</pubDate><guid isPermaLink="false">New Post: Unit3 LoadConfiguration() deprecated? 20130616023452P</guid></item><item><title>New Post: Unit3 LoadConfiguration() deprecated?</title><link>http://unity.codeplex.com/discussions/447163</link><description>&lt;div style="line-height: normal;"&gt;Please, make sure there is a 'using Microsoft.Practices.Unity.Configuration;' wherever you're going to use that extension method.&lt;br /&gt;
&lt;/div&gt;</description><author>homelchenko</author><pubDate>Sun, 16 Jun 2013 08:27:51 GMT</pubDate><guid isPermaLink="false">New Post: Unit3 LoadConfiguration() deprecated? 20130616082751A</guid></item><item><title>New Post: Unit3 LoadConfiguration() deprecated?</title><link>http://unity.codeplex.com/discussions/447163</link><description>&lt;div style="line-height: normal;"&gt;If it makes any difference, I'm using Visual Studio 2012 Express.&lt;br /&gt;
&lt;/div&gt;</description><author>Netrider6</author><pubDate>Sat, 15 Jun 2013 22:10:33 GMT</pubDate><guid isPermaLink="false">New Post: Unit3 LoadConfiguration() deprecated? 20130615101033P</guid></item><item><title>New Post: Unit3 LoadConfiguration() deprecated?</title><link>http://unity.codeplex.com/discussions/447163</link><description>&lt;div style="line-height: normal;"&gt;I do see the reference to Microsoft.Practices.Unity.Configuration in the references section, but the compilation still fails.  I tried uninstalling and reinstalling the Unity package from NuGet, and also tried adding an assembly reference by browsing.  I still can't get the thing to compile.&lt;br /&gt;
&lt;br /&gt;
I'd upload a screenshot if there were an easy way to do so...&lt;br /&gt;
&lt;/div&gt;</description><author>Netrider6</author><pubDate>Sat, 15 Jun 2013 21:30:05 GMT</pubDate><guid isPermaLink="false">New Post: Unit3 LoadConfiguration() deprecated? 20130615093005P</guid></item><item><title>New Post: Unit3 LoadConfiguration() deprecated?</title><link>http://unity.codeplex.com/discussions/447163</link><description>&lt;div style="line-height: normal;"&gt;It should be downloaded from NuGet.  The assembly is in the packages\Unity.3.0.1304.0\lib\Net45\ directory.  It should be added to the project's References automatically.&lt;br /&gt;
&lt;br /&gt;
~~&lt;br /&gt;
Randy Levy&lt;br /&gt;
&lt;a href="m&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#116;o&amp;#58;&amp;#101;&amp;#110;&amp;#116;&amp;#x6c;i&amp;#x62;&amp;#x2e;&amp;#x73;&amp;#117;&amp;#x70;&amp;#x70;o&amp;#114;&amp;#x74;&amp;#64;&amp;#x6c;&amp;#105;v&amp;#101;&amp;#x2e;&amp;#99;&amp;#x6f;&amp;#109;"&gt;&amp;#x65;n&amp;#x74;&amp;#108;&amp;#105;&amp;#x62;&amp;#46;&amp;#115;&amp;#x75;&amp;#112;&amp;#112;&amp;#x6f;&amp;#x72;&amp;#x74;&amp;#x40;&amp;#x6c;&amp;#x69;&amp;#118;&amp;#x65;&amp;#x2e;c&amp;#x6f;&amp;#x6d;&lt;/a&gt;&lt;br /&gt;
Enterprise Library support engineer&lt;br /&gt;
&lt;a href="entlib.codeplex.com/wikipage?title=Support%20How-to" rel="nofollow"&gt;Support How-to&lt;/a&gt; &lt;br /&gt;
&lt;/div&gt;</description><author>randylevy</author><pubDate>Sat, 15 Jun 2013 21:18:29 GMT</pubDate><guid isPermaLink="false">New Post: Unit3 LoadConfiguration() deprecated? 20130615091829P</guid></item><item><title>New Post: Unit3 LoadConfiguration() deprecated?</title><link>http://unity.codeplex.com/discussions/447163</link><description>&lt;div style="line-height: normal;"&gt;That assembly doesn't seem to be present; I installed the Unity Framework with NuGet... do I need to get something else too?&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;
&lt;/div&gt;</description><author>Netrider6</author><pubDate>Sat, 15 Jun 2013 21:07:49 GMT</pubDate><guid isPermaLink="false">New Post: Unit3 LoadConfiguration() deprecated? 20130615090749P</guid></item><item><title>New Post: Unit3 LoadConfiguration() deprecated?</title><link>http://unity.codeplex.com/discussions/447163</link><description>&lt;div style="line-height: normal;"&gt;The LoadConfiguration is an extension method in the Microsoft.Practices.Unity.Configuration assembly.  You need to add a reference to Microsoft.Practices.Unity.Configuration.dll.&lt;br /&gt;
&lt;br /&gt;
~~&lt;br /&gt;
Randy Levy&lt;br /&gt;
&lt;a href="m&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#116;o&amp;#58;&amp;#101;&amp;#110;&amp;#116;&amp;#x6c;i&amp;#x62;&amp;#x2e;&amp;#x73;&amp;#117;&amp;#x70;&amp;#x70;o&amp;#114;&amp;#x74;&amp;#64;&amp;#x6c;&amp;#105;v&amp;#101;&amp;#x2e;&amp;#99;&amp;#x6f;&amp;#109;"&gt;&amp;#x65;n&amp;#x74;&amp;#108;&amp;#105;&amp;#x62;&amp;#46;&amp;#115;&amp;#x75;&amp;#112;&amp;#112;&amp;#x6f;&amp;#x72;&amp;#x74;&amp;#x40;&amp;#x6c;&amp;#x69;&amp;#118;&amp;#x65;&amp;#x2e;c&amp;#x6f;&amp;#x6d;&lt;/a&gt;&lt;br /&gt;
Enterprise Library support engineer&lt;br /&gt;
&lt;a href="entlib.codeplex.com/wikipage?title=Support%20How-to" rel="nofollow"&gt;Support How-to&lt;/a&gt; &lt;br /&gt;
&lt;/div&gt;</description><author>randylevy</author><pubDate>Sat, 15 Jun 2013 21:00:23 GMT</pubDate><guid isPermaLink="false">New Post: Unit3 LoadConfiguration() deprecated? 20130615090023P</guid></item><item><title>New Post: Unit3 LoadConfiguration() deprecated?</title><link>http://unity.codeplex.com/discussions/447163</link><description>&lt;div style="line-height: normal;"&gt;I am new to Unity (version 3.0.1304.0) and am trying to set up my first web application with dependency injection.  I have a web.config file that looks like this:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;
&amp;lt;!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  --&amp;gt;
&amp;lt;configuration&amp;gt;
  &amp;lt;configSections&amp;gt;
    &amp;lt;section name=&amp;quot;unity&amp;quot; type=&amp;quot;Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration&amp;quot;/&amp;gt;
  &amp;lt;/configSections&amp;gt;
&amp;lt;!--Irrelevant stuff omitted--&amp;gt;
  &amp;lt;unity xmlns=&amp;quot;http://schemas.microsoft.com/practices/2010/unity&amp;quot;&amp;gt;
    &amp;lt;alias alias=&amp;quot;ILogger&amp;quot; type=&amp;quot;MyApp.ILogger, MyApp&amp;quot; /&amp;gt;
    &amp;lt;namespace name=&amp;quot;MyApp.Implementations&amp;quot; /&amp;gt;
    &amp;lt;assembly name=&amp;quot;MyApp&amp;quot; /&amp;gt;
    
    &amp;lt;container&amp;gt;
      &amp;lt;register type=&amp;quot;ILogger&amp;quot; name=&amp;quot;special&amp;quot; mapTo=&amp;quot;SpecialLogger&amp;quot; /&amp;gt;    
    &amp;lt;/container&amp;gt;
  &amp;lt;/unity&amp;gt;

&amp;lt;/configuration&amp;gt;&lt;/code&gt;&lt;/pre&gt;

From the documentation, it says, &amp;quot;Adding a Unity configuration section to a configuration file neither create an actual container nor configures it. You must create a Unity container instance, read the configuration file, and load the configuration file information into the container. &amp;quot;&lt;br /&gt;
&lt;br /&gt;
But the code it references:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;IUnityContainer container = new UnityContainer();

container.LoadConfiguration();&lt;/code&gt;&lt;/pre&gt;

seems to be incorrect...&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;Error   14  'Microsoft.Practices.Unity.UnityContainer' does not contain a definition for 'LoadConfiguration' and no extension method 'LoadConfiguration' accepting a first argument of type 'Microsoft.Practices.Unity.UnityContainer' could be found (are you missing a using directive or an assembly reference?) C:\Users\Brad\Documents\Visual Studio 2012\Projects\RebuildingSite\RebuildingSite\Global.asax.cs    34  23  RebuildingSite&lt;/code&gt;&lt;/pre&gt;

Am I doing something wrong, or do I not need that method anymore?&lt;br /&gt;
&lt;/div&gt;</description><author>Netrider6</author><pubDate>Sat, 15 Jun 2013 20:40:52 GMT</pubDate><guid isPermaLink="false">New Post: Unit3 LoadConfiguration() deprecated? 20130615084052P</guid></item><item><title>New Post: ASP.NET Web API - Inject Dependencies Into ActionFilterAttribute</title><link>http://unity.codeplex.com/discussions/446780</link><description>&lt;div style="line-height: normal;"&gt;Sorry, my post was about ASP.NET MVC and &lt;em&gt;not&lt;/em&gt; ASP.NET Web API.  Oops, my bad.&lt;br /&gt;
&lt;br /&gt;
What version of ASP.NET MVC are you using?  I'm using version 4.&lt;br /&gt;
&lt;br /&gt;
Also, based on your code sample it looks like you may be using another NuGet package?  Perhaps &lt;a href="http://nuget.org/packages/Unity.Mvc4/" rel="nofollow"&gt;Unity.Mvc4&lt;/a&gt; or &lt;a href="http://nuget.org/packages/Unity.Mvc3/" rel="nofollow"&gt;Unity.MVC3&lt;/a&gt;?&lt;br /&gt;
&lt;br /&gt;
When I install the official &lt;a href="http://nuget.org/packages/Unity.AspNet.WebApi/" rel="nofollow"&gt;Unity bootstrapper for ASP.NET Web API&lt;/a&gt; two files are added to App_Start: UnityConfig.cs and UnityWebApiActivator.cs.&lt;br /&gt;
&lt;br /&gt;
To get injection working for an instance of &lt;code&gt;System.Web.Http.Filters.ActionFilterAttribute&lt;/code&gt; I had to create a custom &lt;code&gt;IFilterProvider&lt;/code&gt;.  To do this I extended ActionFilterDescriptorFilterProvider:&lt;br /&gt;
&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; UnityActionFilterProvider : ActionDescriptorFilterProvider, IFilterProvider
    {
        &lt;span style="color:Blue;"&gt;private&lt;/span&gt; &lt;span style="color:Blue;"&gt;readonly&lt;/span&gt; IUnityContainer container;

        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; UnityActionFilterProvider(IUnityContainer container)
        {
            &lt;span style="color:Blue;"&gt;this&lt;/span&gt;.container = container;
        }

        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;new&lt;/span&gt; IEnumerable&amp;lt;FilterInfo&amp;gt; GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor)
        {
            &lt;span style="color:Blue;"&gt;var&lt;/span&gt; filters = &lt;span style="color:Blue;"&gt;base&lt;/span&gt;.GetFilters(configuration, actionDescriptor);
            List&amp;lt;FilterInfo&amp;gt; filterInfoList = &lt;span style="color:Blue;"&gt;new&lt;/span&gt; List&amp;lt;FilterInfo&amp;gt;();

            &lt;span style="color:Blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color:Blue;"&gt;var&lt;/span&gt; filter &lt;span style="color:Blue;"&gt;in&lt;/span&gt; filters)
            {
                container.BuildUp(filter.Instance.GetType(), filter.Instance);
            }

            &lt;span style="color:Blue;"&gt;return&lt;/span&gt; filters;
        }
    }

&lt;/pre&gt;&lt;/div&gt;Next I created a helper method, RegisterFilterProviders, to register the provider:&lt;br /&gt;
&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;static&lt;/span&gt; &lt;span style="color:Blue;"&gt;void&lt;/span&gt; RegisterFilterProviders()
    {
        &lt;span style="color:Blue;"&gt;var&lt;/span&gt; providers = GlobalConfiguration.Configuration.Services.GetFilterProviders().ToList();
        GlobalConfiguration.Configuration.Services.Add(&lt;span style="color:Blue;"&gt;typeof&lt;/span&gt;(System.Web.Http.Filters.IFilterProvider),
                                                        &lt;span style="color:Blue;"&gt;new&lt;/span&gt; UnityActionFilterProvider(UnityConfig.GetConfiguredContainer()));

        &lt;span style="color:Blue;"&gt;var&lt;/span&gt; defaultprovider = providers.First(p =&amp;gt; p &lt;span style="color:Blue;"&gt;is&lt;/span&gt; ActionDescriptorFilterProvider);
        GlobalConfiguration.Configuration.Services.Remove(&lt;span style="color:Blue;"&gt;typeof&lt;/span&gt;(System.Web.Http.Filters.IFilterProvider), defaultprovider);
    }

&lt;/pre&gt;&lt;/div&gt;The above method can be called from within &lt;code&gt;Application_Start&lt;/code&gt; in Global.asax or some other place during Unity bootstrapping.&lt;br /&gt;
&lt;br /&gt;
Once that is set up, the System.Web.Http.Filters.ActionFilterAttribute has it's properties injected.&lt;br /&gt;
&lt;br /&gt;
~~&lt;br /&gt;
Randy Levy&lt;br /&gt;
&lt;a href="m&amp;#x61;&amp;#x69;&amp;#x6c;&amp;#116;o&amp;#58;&amp;#101;&amp;#110;&amp;#116;&amp;#x6c;i&amp;#x62;&amp;#x2e;&amp;#x73;&amp;#117;&amp;#x70;&amp;#x70;o&amp;#114;&amp;#x74;&amp;#64;&amp;#x6c;&amp;#105;v&amp;#101;&amp;#x2e;&amp;#99;&amp;#x6f;&amp;#109;"&gt;&amp;#x65;n&amp;#x74;&amp;#108;&amp;#105;&amp;#x62;&amp;#46;&amp;#115;&amp;#x75;&amp;#112;&amp;#112;&amp;#x6f;&amp;#x72;&amp;#x74;&amp;#x40;&amp;#x6c;&amp;#x69;&amp;#118;&amp;#x65;&amp;#x2e;c&amp;#x6f;&amp;#x6d;&lt;/a&gt;&lt;br /&gt;
Enterprise Library support engineer&lt;br /&gt;
&lt;a href="entlib.codeplex.com/wikipage?title=Support%20How-to" rel="nofollow"&gt;Support How-to&lt;/a&gt; &lt;br /&gt;
&lt;/div&gt;</description><author>randylevy</author><pubDate>Fri, 14 Jun 2013 18:53:11 GMT</pubDate><guid isPermaLink="false">New Post: ASP.NET Web API - Inject Dependencies Into ActionFilterAttribute 20130614065311P</guid></item><item><title>New Post: ASP.NET Web API - Inject Dependencies Into ActionFilterAttribute</title><link>http://unity.codeplex.com/discussions/446780</link><description>&lt;div style="line-height: normal;"&gt;All of the types are registered correctly - they are used by many of the controllers and that all works. It doesn't work for the filter attributes though.&lt;br /&gt;
&lt;br /&gt;
As a potentially interesting side note, Unity added Bootstrapper.cs to the root folder, but not UnityConfig or UnityMvcActivator in the app_start. Maybe this is because I installed the Web API Nuget package?&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;    public static class Bootstrapper
    {
        public static void Initialise()
        {
            var container = BuildUnityContainer();

            GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);
        }

        private static IUnityContainer BuildUnityContainer()
        {
            var container = new UnityContainer();

            container.RegisterType&amp;lt;IApiUserService, ApiUserService&amp;gt;();
            // Others...

            return container;
        }
    }&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;</description><author>Sohnee</author><pubDate>Fri, 14 Jun 2013 09:39:57 GMT</pubDate><guid isPermaLink="false">New Post: ASP.NET Web API - Inject Dependencies Into ActionFilterAttribute 20130614093957A</guid></item><item><title>New Post: ASP.NET Web API - Inject Dependencies Into ActionFilterAttribute</title><link>http://unity.codeplex.com/discussions/446780</link><description>&lt;div style="line-height: normal;"&gt;All of the types are registered correctly - they are used by many of the controllers and that all works. It doesn't work for the filter attributes though.&lt;br /&gt;
&lt;br /&gt;
As a potentially interesting side note, Unity added Bootstrapper.cs to the root folder, but not UnityConfig or UnityMvcActivator in the app_start. Maybe this is because I installed the Web API Nuget package?&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;    public static class Bootstrapper
    {
        public static void Initialise()
        {
            var container = BuildUnityContainer();

            GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);
        }

        private static IUnityContainer BuildUnityContainer()
        {
            var container = new UnityContainer();

            container.RegisterType&amp;lt;IApiUserService, ApiUserService&amp;gt;();
            // Others...

            return container;
        }
    }&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;</description><author>Sohnee</author><pubDate>Fri, 14 Jun 2013 09:39:57 GMT</pubDate><guid isPermaLink="false">New Post: ASP.NET Web API - Inject Dependencies Into ActionFilterAttribute 20130614093957A</guid></item></channel></rss>