Does T4MVC work with Visual Studio 2010 Beta 2 and .Net 4?

末鹿安然 提交于 2019-12-24 06:01:58

问题


I cannot get the current build of T4MVC (2.6.02) to work with an ASP.NET MVC 2 project compiled against .NET 4 in VS2010 Beta 2.

There is one error:

  • The C# 2.0 and C# 3.5 compilers are no longer supported. Templates will always be compiled with the version 4 compiler instead of 'v3.5' as specified.

Which is easily fixed by changing

<#@ template language="C#v3.5" debug="true" hostspecific="true" #>

to

<#@ template language="C#" debug="true" hostspecific="true" #>

And then the .generated.cs files are created, however I get a compile error in T4MVC.cs which says

error CS0116: A namespace cannot directly contain members such as fields or methods.

Has anyone else experienced this?


回答1:


Apparently you have to do a build first :) The compile message seems to go away afterwards.




回答2:


Note that the message about compiler version is just a warning and not an error. I'm not 100% why you were getting this error before the build, though. If you get it again, please try to capture more details about it (e.g. line number, ...) and let me know.



来源:https://stackoverflow.com/questions/1867329/does-t4mvc-work-with-visual-studio-2010-beta-2-and-net-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!