我在我的项目中添加了PostSharp (4.0.37)和PostSharp.Patterns.Model。然后编译并运行良好。
然后,我将NotifyPropertyChanged添加到我非常简单的缩小的示例类中(只包含一个int32自动属性)。该项目仍然编译,但它在启动时抛出一个TypeInitializationException:
在Microsoft.VisualStudio.HostingProcess.Utilities.dll中发生了“System.TypeInitializationException”类型的未处理异常 附加信息:“”的类型初始化引发异常。
VS 2012.4,Win7(x64),已经尝试了.net 4,4.5,4.51和3.5,同样的事情也发生了。有什么想法吗?
发布于 2014-12-09 13:38:38
我想我发现了:出于某种原因,NuGet首先安装了PostSharp的alpha版本(4.1.4.0),它对我不起作用(编译错误)。当我发现版本问题时,我卸载了它,并非常小心地安装了稳定的版本。然而,我刚刚意识到app.config文件中仍然有一个设置:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="PostSharp" publicKeyToken="b13fd38b8f9c99d7" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>我删除了整个部分,我的测试应用程序中有我的小类,现在运行!
https://stackoverflow.com/questions/27379182
复制相似问题