【问题标题】:WCF with StructureMap: Operation could destabilize the runtime带有 StructureMap 的 WCF:操作可能会破坏运行时的稳定性
【发布时间】:2014-12-01 10:11:52
【问题描述】:

我在将 WCF 与 StructureMap 结合使用时遇到了这个奇怪的错误。

我也尝试搜索堆栈,有一些答案建议安装修补程序:Operation could destabilize the runtime in StructureMap

但由于"Software Update KB2748645 Installation Wizard does not apply, or is blocked by another condition on your computer. Please click the link below for more details.",我无法安装修补程序

public class StructureMapInstanceProvider : IInstanceProvider
{
    private readonly Type _serviceType;
    public StructureMapInstanceProvider(Type serviceType)
    {
        _serviceType = serviceType;
    }
    public object GetInstance(InstanceContext instanceContext, Message message)
    {
        return ObjectFactory.GetInstance(_serviceType); // error thrown here
    }
}

An exception of type 'StructureMap.StructureMapConfigurationException' occurred in StructureMap.dll but was not handled in user code. 
Operation could destabilize the runtime.

Additional information:
Attempting to create a build plan for concrete type ProfileService
1.) Attempting to create a BuildPlan for Instance of ProfileService -- ProfileService
2.) Container.GetInstance(ProfileService)

堆栈跟踪

   at StructureMap.Building.ConcreteType.SourceFor(String ctorOrSetter, String name, Type dependencyType, Object value) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Building\ConcreteType.cs:line 200
   at StructureMap.Building.ConcreteType.<>c__DisplayClass4.<BuildConstructorStep>b__3(ParameterInfo x) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Building\ConcreteType.cs:line 112
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at StructureMap.StringExtensions.Each[T](IEnumerable`1 enumerable, Action`1 action) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Extensions.cs:line 10
   at StructureMap.Building.ConstructorStep.Add(IEnumerable`1 dependencies) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Building\ConstructorStep.cs:line 79
   at StructureMap.Building.ConcreteType.BuildConstructorStep(Type pluggedType, ConstructorInfo constructor, DependencyCollection dependencies, Policies policies) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Building\ConcreteType.cs:line 115
   at StructureMap.Building.ConcreteType.BuildSource(Type pluggedType, ConstructorInfo constructor, DependencyCollection dependencies, Policies policies) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Building\ConcreteType.cs:line 27

我真的不明白这个错误,我也找不到它来自哪里。 所以我愿意接受建议。

【问题讨论】:

    标签: c# wcf ioc-container structuremap structuremap3


    【解决方案1】:

    经过一天的折腾,这是解决方法(实际上不是解决方案):

    在 Visual Studio(我使用的是 2013)中,转到:

    工具 -> 选项 -> IntelliTrace -> 常规 -> 取消选择 IntelliTrace events and call information (或选择IntelliTrace events only

    我不知道为什么这个选项会导致问题。但是这种解决方法对我来说效果很好。 你可以在这里找到同样的问题: https://www.devexpress.com/Support/Center/Question/Details/Q512306

    引用

    outro56 2 years ago
    Ok, I think I may have found a workaround as per Q262635, it has to do with IntelliTrace; 
    simply changing the IntelliTrace settings to "IntelliTrace events only" was able to get 
    around this problem (i.e. Tools->Options->IntelliTrace->General)
    

    【讨论】:

      猜你喜欢
      • 2010-09-27
      • 1970-01-01
      • 2010-12-25
      • 1970-01-01
      • 2012-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多