Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It was hard to solve, but finally I got there! The problem was I misused StructureMap: StructureMap, as far as I correctly grasped the intention of using it, is intended to dynamicaly load settings once, when application loads. In our project, we're switching profiles many times per seconds and trying to retrieve an instance based on that profile. We got many exceptions like it doesn't recognize the default instance although WhatDoIHave() showed the opposite. The problem was exactly that - calling the Container from many threads and switching profiles upon each request.</p> <p>So, for a reminder, when application starts, for each profile I added its settings to the only one Container:</p> <pre><code>var registry = new OurRegistry(settings parameters..., profileName); StructureMap.ObjectFactory.Configure(x =&gt; x.IncludeRegistry(registry)); </code></pre> <p>And in many places in code, I used to call StructureMap like that:</p> <pre><code> var container = StructureMap.ObjectFactory.Container; container.SetDefaultsToProfile(profileName); var adaptor = container.GetInstance&lt;ISomeInterface&lt;ConcreteType&gt;&gt;(); </code></pre> <p>This code was used parallel and each thread used another profile. </p> <p>So, as a fix I created a Container per profile!</p> <pre><code>var registry = new OurRegistry(settings parameters..., profileName); var container = new StructureMap.Container(registry); </code></pre> <p>And I stored each container in our code, not on StructureMap as before, so each profile-prone thread is using it's own profiled Container. That's even faster then before because you don't have to switch profiles so much, only once!</p> <p>And no more #$@!@ 202 exception :)</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      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