我正在尝试在 VB.NET MVC3 项目中使用 MVC Scaffolding,并遇到了设置 Option Strict 的后期绑定问题(我想要它)。
这在 C# 中有效:
public ActionResult Create()
{
ViewBag.PossibleTeams = context.Teams;
return View();
}
但在 VB.NET 中几乎相同的代码:
Public Function Create() As ActionResult
ViewBag.PossibleTeams = context.Teams
Return View()
End Function
导致编译器错误Option Strict On disallows late binding。我在这里查看了文档:http: //msdn.microsoft.com/en-us/library/system.web.mvc.controllerbase.viewbag (VS.98).aspx但它不是很有帮助。
我注意到 C# 中的一个新的空应用程序在ViewBag
VB.NETHomeController
版本中使用ViewData
,所以这可能是 VB.NET 的限制。