[英]Error when using RazorTemplates library: 'CS0012: The type 'System.Attribute' is defined in an assembly that is not referenced'
On some machines, executing a razor template via RazorTemplates
works OK. 在某些计算机上,通过
RazorTemplates
执行剃刀模板可以RazorTemplates
工作。
On others, I receive the following message: 在其他情况下,我收到以下消息:
TemplateCompilationException
error CS0012: The type 'System.Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Info: 信息:
It seems the Attribute object exists in both System.Runtime and mscorlib. 似乎Attribute对象同时存在于System.Runtime和mscorlib中。
Looks like this is an underlying issue somewhere between win10 and the RazorTemplates library. 看起来这是win10和RazorTemplates库之间某个潜在的问题。
In the end i switched from RazorTemplates to RazorEngine: https://github.com/Antaris/RazorEngine 最后,我从RazorTemplates切换到RazorEngine: https : //github.com/Antaris/RazorEngine
And there is a page here that explains how to fix the problem via a Resolver: 这里有一个页面,说明如何通过解析器解决问题:
https://github.com/Antaris/RazorEngine/issues/416 https://github.com/Antaris/RazorEngine/issues/416
System.Runtime is part of the .Net Framework and is installed in the GAC during framework installation. System.Runtime是.Net Framework的一部分,并且在框架安装期间安装在GAC中。
This could happen for two possible reasons: 发生这种情况可能有两个原因:
For the machines this fails on check what version of the .Net runtime they have and/or inspect the GAC for this file and version. 对于机器,这无法检查它们具有的.Net运行时版本和/或检查GAC的文件和版本。
Missing the framework, install it. 缺少框架,请安装它。 :-)
:-)
If machines have a version but it's not the expected version do either: 如果计算机具有版本,但不是预期的版本,请执行以下任一操作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.