Note that there are some explanatory texts on larger screens.

plurals
  1. POUnity (in PRISM) does (not) weird resolving...??!!
    primarykey
    data
    text
    <p>I 'm using PRISM and in the Bootstrapper class i did override the ConfigureContainer() method. There is nothing fancy in it just these lines:</p> <pre><code>protected override void ConfigureContainer() { Container.RegisterType&lt;IDataContext, SQLDataContext&gt;(new InjectionConstructor(@"Server=localhost\SQLExpress;User Id=sa;Password=xxxxx;Database=MyDatabase")); base.ConfigureContainer(); } </code></pre> <p>At "debug-time" i try to call Container.Resolve() but this gives me the following error:</p> <blockquote> <p>{"Resolution of the dependency failed, type = \"Photo.DAL.Abstract.IDataContext\", name = \"\". Exception message is: The current build operation (build key Build Key[Photo.DAL.Concrete.SQLDataContext, null]) failed: Value cannot be null.\r\nParameter name: stream (Strategy type BuildPlanStrategy, index 3)"} System.Exception {Microsoft.Practices.Unity.ResolutionFailedException}</p> </blockquote> <p>But when i do </p> <pre><code>Container.IsTypeRegistered(typeof(IDataContext)) </code></pre> <p>I get true!!!</p> <ul> <li>What am I missing???</li> </ul> <hr> <p><strong>Info which published as answer below, which should be an edit to the question:</strong></p> <p>This is the full stack:</p> <pre><code>Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Photo.DAL.Abstract.IDataContext", name = "". Exception message is: The current build operation (build key Build Key[Photo.DAL.Concrete.SQLDataContext, null]) failed: Value cannot be null. Parameter name: stream (Strategy type BuildPlanStrategy, index 3) ---&gt; Microsoft.Practices.ObjectBuilder2.BuildFailedException: The current build operation (build key Build Key[Photo.DAL.Concrete.SQLDataContext, null]) failed: Value cannot be null. Parameter name: stream (Strategy type BuildPlanStrategy, index 3) ---&gt; System.ArgumentNullException: Value cannot be null. Parameter name: stream at System.Data.Linq.Mapping.XmlMappingSource.FromStream(Stream stream) at Photo.DAL.Mapping.GetMapping() in C:\Users\Savvas\Documents\Visual Studio 2008\Projects\Photo\Photo.DAL\Mapping.cs:line 18 at Photo.DAL.Concrete.SQLDataContext..ctor(String connectionString) in C:\Users\Savvas\Documents\Visual Studio 2008\Projects\Photo\Photo.DAL\Concrete\SQLDataContext.cs:line 52 at BuildUp_Photo.DAL.Concrete.SQLDataContext(IBuilderContext ) at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) --- End of inner exception stack trace --- at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing) at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name) --- End of inner exception stack trace --- at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name) at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name) at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name) at Microsoft.Practices.Unity.UnityContainerBase.Resolve(Type t) at Microsoft.Practices.Unity.UnityContainerBase.Resolve[T]() at Photo.Desktop.Bootstrapper.ConfigureContainer() in C:\Users\Savvas\Documents\Visual Studio 2008\Projects\Photo\Photo.Desktop\Bootstrapper.cs:line 42 </code></pre> <p>I noticed that the error is not coming from actually resolving the class, but from the calling method GetMapping() which is defined as</p> <pre><code>public static class Mapping { public static XmlMappingSource GetMapping() { XmlMappingSource mapping; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Photo.DAL.Entities.Entities.map")) { mapping = XmlMappingSource.FromStream(stream); } return mapping; } } </code></pre> <ul> <li>Is Unity incapable of doing this? (it worked well with Windsor!!)</li> </ul>
    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.
 

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