开发者

T4MVC VB with Visual Studio 2010 Express Edition

I am having trouble using T4MVC VB with Visual Studio 2010 Express Edition.

I can reference the T4MVC classes in my controllers, but I cannot access them in my views (where I actually need them).

In the view, the following code is overwritten by intellisense as if the class MVC is invalid.

MVC.Home.GameBoard

It is replaced with

Mvc.Home.GameBoard

Which generates the error message 'Home' is not a member of 'Mvc'. It seems that in the view there is an Mvc namespace hiding the MVC class. This doesn't exist in the controller. How can I make this work?

Update: After playing with it some more, it seems the classes aren't available in the View no matter what they're named. What decides what classes and namespaces are available in the view? The classes continue to be available in the controller, regardless of naming as well. I presume there has to be some filter or limit on what is available in the views?

Update: I was just watching this excellent video from Phil Haack, and it game me a clue.

I need to modify the <pages> section in the web.config file. Now the question is, can 开发者_JAVA技巧I get that to use a class that's not in a namespace, as the MVC class is by default, otherwise I'll have to modify the T4 template to put it in a namespace and include that.


It seems like you're running into some kind of name conflict due to the fact that VB is case insensitive (unlike C#).

Please try going in T4MVC.settings.t4 and change HelpersPrefix from "MVC" to something else that doesn't conflict (e.g. "MyMvc"). Then change your code to use that prefix instead of MVC.

Hopefully that's all it'll take!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜