最漂亮的解决方案似乎是RazorEngine,它依赖于Microsoft.AspNet.Razor。但是,当尝试通过Nuget安装Microsoft.AspNet.Razor时,会显示以下错误消息:
Installing ‘Microsoft.AspNet.Razor 3.0.0’.
Successfully
installed ‘Microsoft.AspNet.Razor 3.0.0’.
Adding
‘Microsoft.AspNet.Razor 3.0.0’ to EBulkDBSManagementApp.
Uninstalling ‘Microsoft.AspNet.Razor 3.0.0’.
Successfully
uninstalled ‘Microsoft.AspNet.Razor 3.0.0’.
Install Failed.
Rolling back…
Could not install package
‘Microsoft.AspNet.Razor 3.0.0’. You are trying to install this package
into a project that targets ‘.NETFramework,Version=v4.0’,but the
package does not contain any assembly references or content files that
are compatible with that framework. For more information,contact the
package author.
任何解决方案?
解决方法
如果您希望在4.5之前使用RazorEngine版本的.NET,那么您将需要使用RazorEngine 3.3.0 NuGet pacakage。
您可以使用以下命令使用软件包管理器控制台进行安装。
Install-Package RazorEngine -Version 3.3.0