使用 T4MVC 时出现命名空间错误
刚刚听说 T4MVC,但我无法让它在我的示例项目(ASP.NET MVC 2、Visual Studio 2008)中工作。
尝试构建项目时出现以下错误:
错误 1 命名空间“Northwind.Web.MVC”中不存在类型或命名空间名称“Account”(是否缺少程序集引用?)C:\Users\Bruno\Documents\My Dropbox\Projetos.NET \Northwind\Northwind.Web.MVC\AccountController. generated.cs 38 61 Northwind.Web.MVC
这是发生错误的地方:
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public AccountController Actions { get { return MVC.Account; } }
我真的很讨厌魔术字符串,所以请帮助我让它工作!
Just heard about T4MVC but i can't get it to work in my sample project (ASP.NET MVC 2, Visual Studio 2008).
I get the following erros when trying to build the project:
Error 1 The type or namespace name 'Account' does not exist in the namespace 'Northwind.Web.MVC' (are you missing an assembly reference?) C:\Users\Bruno\Documents\My Dropbox\Projetos.NET\Northwind\Northwind.Web.MVC\AccountController.generated.cs 38 61 Northwind.Web.MVC
This is where the error occurs:
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public AccountController Actions { get { return MVC.Account; } }
I really hate magic strings, so please help me to make it work!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 T4MVC 和您的代码之间存在命名空间冲突。转到 T4MVC.settings.t4 并找到此代码:
只需将“MVC”更改为其他内容即可开始工作:)
或者,如果您愿意,您可以重命名您的命名空间 (Northwind.Web.MVC< /强>)
Looks like a namespace conflict between T4MVC and your code. Go to T4MVC.settings.t4 and find this code:
Just change "MVC" to something else and you'll be on your way :)
Alternatively, you could rename your namespace if you prefer (Northwind.Web.MVC)