T4MVC VB 与 Visual Studio 2010 Express 版

发布于 2024-10-04 11:23:29 字数 876 浏览 12 评论 0原文

我在将 T4MVC VB 与 Visual Studio 2010 Express Edition 一起使用时遇到问题。

我可以在控制器中引用 T4MVC 类,但无法在视图中访问它们(我实际需要它们的地方)。

在视图中,以下代码被智能感知覆盖,就好像类 MVC 无效一样。

MVC.Home.GameBoard

它被替换为

Mvc.Home.GameBoard

Which generated the error message 'Home' is not a member of 'Mvc'.视图中似乎有一个 Mvc 命名空间隐藏了 MVC 类。这在控制器中不存在。我怎样才能做到这一点?

更新:再玩几次后,似乎这些类在视图中不可用,无论它们的名称是什么。什么决定了视图中哪些类和命名空间可用?无论命名如何,这些类在控制器中仍然可用。我认为必须对视图中可用的内容进行一些过滤或限制?

更新:我刚刚观看了这段精彩的视频,来自Phil Haack,它为我提供了一条线索。

我需要修改 web.config 文件中的 部分。现在的问题是,我是否可以使用不在命名空间中的类(默认情况下是 MVC 类),否则我必须修改 T4 模板以将其放入命名空间中并包含该类。

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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陪我终i 2024-10-11 11:23:29

由于 VB 不区分大小写(与 C# 不同),您似乎遇到了某种名称冲突。

请尝试进入 T4MVC.settings.t4 并将 HelpersPrefix 从“MVC”更改为其他不冲突的内容(例如“MyMvc”)。然后更改代码以使用该前缀而不是 MVC。

希望这就是全部!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文