StructureMap for IoC works with 4.5 .net framework, not with 4.0 framework in MVC 3 application

0

I have a mvc 3 project in which I have used Structure map for IoC. Structure map gives error:- structureMap Exception Code: 207 on Framework 4.0. But when I installed .net framework 4.5 it works fine. Here in this case I have been told to use only 4.0. Only I checked security related issue but it is not working. I have dll of structure map of version 2.6.4 Here is that exception details:-

Build Error on Instance '1399afab-f879-4987-91fe-b19ab65675bb' (Configured Instance of AutoMapper.TypeMapFactory, AutoMapper, Version=3.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005)
   for PluginType AutoMapper.ITypeMapFactory, AutoMapper, Version=3.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005

StructureMap.StructureMapException: StructureMap Exception Code:  207
Internal exception while creating Instance '1399afab-f879-4987-91fe-b19ab65675bb' of PluginType AutoMapper.ITypeMapFactory.  Check the inner exception for more details. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
  at AutoMapper.Internal.ProbingAdapterResolver.ProbeForPlatformSpecificAssembly()
  at AutoMapper.Internal.ProbingAdapterResolver.GetPlatformSpecificAssembly()
  at AutoMapper.Internal.ProbingAdapterResolver.Resolve(Type type)
  at AutoMapper.Internal.PlatformAdapter.Resolve[T](Boolean throwIfNotFound)
  at AutoMapper.TypeMapFactory..ctor()
  at lambda_method(Closure , IArguments )
  at StructureMap.Construction.BuilderCompiler.FuncCompiler`1.<>c__DisplayClass2.<CreateBuilder>b__0(IArguments args) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Construction\BuilderCompiler.cs:line 56
  at StructureMap.Construction.InstanceBuilder.BuildInstance(IArguments args) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Construction\InstanceBuilder.cs:line 34
  at StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ConstructorInstance.cs:line 233
  --- End of inner exception stack trace ---
  at StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ConstructorInstance.cs:line 245
  at StructureMap.Pipeline.ConstructorInstance.build(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ConstructorInstance.cs:line 218
  at StructureMap.Pipeline.SmartInstance`1.build(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\SmartInstance.cs:line 156
  at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\Instance.cs:line 101
  at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\Instance.cs:line 69
  at StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ObjectBuilder.cs:line 27
  at StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance) in c:\BuildAgent\work\767273992e840853\src\StructureMap\BuildSession.cs:line 176
  at StructureMap.Diagnostics.ValidationBuildSession.CreateInstance(Type pluginType, Instance instance) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Diagnostics\ValidationBuildSession.cs:line 59
  at StructureMap.BuildSession.<>c__DisplayClass3.<.ctor>b__1() in c:\BuildAgent\work\767273992e840853\src\StructureMap\BuildSession.cs:line 36
  at StructureMap.BuildSession.CreateInstance(Type pluginType) in c:\BuildAgent\work\767273992e840853\src\StructureMap\BuildSession.cs:line 215
  at StructureMap.Pipeline.DefaultInstance.build(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\DefaultInstance.cs:line 22
  at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\Instance.cs:line 101
  at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\Instance.cs:line 69
  at StructureMap.Pipeline.ConstructorInstance.Get[T](String propertyName, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ConstructorInstance.cs:line 79
  at StructureMap.Pipeline.Arguments.Get[T](String propertyName) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\Arguments.cs:line 18
  at lambda_method(Closure , IArguments )
  at StructureMap.Construction.BuilderCompiler.FuncCompiler`1.<>c__DisplayClass2.<CreateBuilder>b__0(IArguments args) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Construction\BuilderCompiler.cs:line 56
  at StructureMap.Construction.InstanceBuilder.BuildInstance(IArguments args) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Construction\InstanceBuilder.cs:line 34
  at StructureMap.Pipeline.ConstructorInstance.Build(Type pluginType, BuildSession session, IInstanceBuilder builder) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ConstructorInstance.cs:line 235
  at StructureMap.Pipeline.ConstructorInstance.build(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ConstructorInstance.cs:line 218
  at StructureMap.Pipeline.SmartInstance`1.build(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\SmartInstance.cs:line 156
  at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\Instance.cs:line 101
  at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\Instance.cs:line 69
  at StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Pipeline\ObjectBuilder.cs:line 27
  at StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance) in c:\BuildAgent\work\767273992e840853\src\StructureMap\BuildSession.cs:line 176
  at StructureMap.Diagnostics.ValidationBuildSession.CreateInstance(Type pluginType, Instance instance) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Diagnostics\ValidationBuildSession.cs:line 59
  at StructureMap.Diagnostics.ValidationBuildSession.validateInstance(Type pluginType, Instance instance) in c:\BuildAgent\work\767273992e840853\src\StructureMap\Diagnostics\ValidationBuildSession.cs:line 73
c#
asp.net-mvc-3
inversion-of-control
automapper
asked on Stack Overflow Jun 18, 2014 by Sarveshwar • edited Jun 19, 2014 by Sarveshwar

1 Answer

0

I am seeing this same problem with FxCop. The problem appears to be that with .Net 4.0 and above you link in System.Core 4.0.0.0, but for some reason StructureMap uses Version 2.0.5.0. I'm not sure why StructureMap would use the old version. I'm not sure of 2.0.5.0 needs to be installed.

answered on Stack Overflow Jul 9, 2014 by Michael Glasgow

User contributions licensed under CC BY-SA 3.0