c# - 编译转换 : The type 'Object' is defined in an assembly that is not referenced

标签 c# asp.net asp.net-mvc typescript typelite

我正在对一个 asp.Net MVC5 网络应用程序进行一些更改,我在其中使用了 typelite从 C# 类创建 .ts 定义(非常方便)。出于某种原因,现在我在执行 T4 时遇到了这个错误:

Compiling transformation: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

和这个警告:

Compiling transformation: Assuming assembly reference 'mscorlib, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' used by 'EnvDTE' matches identity 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' of 'mscorlib', you may need to supply runtime policy Mair.Tracking.Web

我猜这与 TypeLite 使用的 EnvDTE 版本和对 mscorlib EnvDTE 使用的引用有关。我应该在 web.config 中添加 bindingRedirect 吗?

我正在使用 VS2015 和 Update2 CTP。

最佳答案

我可以确认 Portable 类库与 T4 模板的结合导致了 Visual Studio 2015 Update 2 中的这个问题。我无法找到更好的解决方案,然后将 TypeLITE 重新定位到完整的 .NET 框架。

从版本 1.8.0 开始,TypeLITE nuget 包包含一个针对完整 .NET 框架的库副本。如果您的项目以完整的 .NET 框架为目标,则在安装过程中会选择正确的 TypeLITE 程序集,并且在 Visual Studio 2015 Update 2 中一切正常。不幸的是,如果您的项目以 PCL 为目标,那么您在 Visual Studio 2015 Update 2 中就不走运了。我寻找更好的解决方案。

关于c# - 编译转换 : The type 'Object' is defined in an assembly that is not referenced,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35412460/

相关文章:

c# - Ref & out 重载方法

c# - 使用 ServiceStack.Redis 对高容量场景的意外回复

asp.net - 是否可以在 asp.net 之外使用 Razor View Engine

javascript - 如何在模态窗口中自动调整 Kendo UI 网格的大小

c# - 错误 : "DataGridViewComboBoxCell value is not valid." DataSource is list of basic type

javascript - 从 Javascript 使用 Web 服务

asp.net - 如何计算我在页面中拥有的用户控件的数量?

javascript - "是 JSON 字符串

html - 无法使用 Chrome 在我的 ASP.NET ZERO MVC 应用程序中使用 border-radius

c# - 反序列化 Json 对象时出现 "because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly"错误