C#动态类型的突破升级到Visual Studio的2012 [英] C# Dynamic Types Break When Upgrading to Visual Studio 2012
问题描述
我使用Visual Studio 2010与.NET 4.0,最初开发的一个项目。它是一个类库,它实现了一个自定义的MVC 3控制器和它采用的是动态类型。如果我打开在Visual Studio 2012 RTM的项目,而不进行任何更改到项目中,我得到以下错误的动态类型:
I have a project that was originally developed using Visual Studio 2010 with .Net 4.0. It is a class library that implements a custom MVC 3 controller and it uses a dynamic type. If I open the project in Visual Studio 2012 RTM, without making any changes to the project, I get the following error on the dynamic types:
编译一个动态的前pression所需的一个或多个类型不能被发现。是否缺少一个参考?的
One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?
我也越来越另一个错误,那就是:
I am also getting another error, which is:
缺少必需的编译成员Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember的
Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember'
他们似乎是相关的问题。我不知道为什么的Visual Studio 2012是混乱的。所述Microsoft.CSharp组件是在参考文献中。如果我在Visual Studio 2010中再次打开项目它编译就好了。有没有人碰到这个问题,并知道解决办法呢?
They seem to be related issues. I am not sure why Visual Studio 2012 is confused. The Microsoft.CSharp assembly is in the references. If I open the project again in Visual Studio 2010 it compiles just fine. Has anyone come across this issue and know a solution to it?
推荐答案
答案竟然是在任何VS编译时是present警告2010年和2012年的警告是:
The answer turned out to be in a warning that was present when compiling in either VS 2010 and 2012. The warning was:
的predefined型'System.Runtime.CompilerServices.CallSite'在在全球多个别名定义组件;使用定义从.. \\ IronJS.Core.0.2.0.1 \\ lib目录\\ net40 \\ Microsoft.Scripting.Core.dll的
The predefined type 'System.Runtime.CompilerServices.CallSite' is defined in multiple assemblies in the global alias; using definition from '..\IronJS.Core.0.2.0.1\lib\net40\Microsoft.Scripting.Core.dll'
该项目采用IronJS和它有一个Microsoft.Scripting和Microsoft.Dynamic在其包中的副本中被引用。我删除这些引用和参考,在全球组件版本,一切工作正常。不知道为什么VS 2012有这个问题时,VS 2010没有。或者为什么它造成的模糊的错误。
The project used IronJS and it had a a copy of Microsoft.Scripting and Microsoft.Dynamic in its package that were being referenced. I removed these references and referenced the versions in the global assemblies and everything works fine. Not sure why VS 2012 had a problem with this when VS 2010 did not. Or why it caused the obscure errors.
这篇关于C#动态类型的突破升级到Visual Studio的2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!