我在我的locahost上运行MVC3站点时出现此错误。它是新创建的新鲜MVC3网站,HomeController
Index
方法是从ViewBag.Message
分配中抛出的方法。“动态操作只能在同质AppDomain中执行”错误
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
堆栈跟踪:
at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at MVC3.Web.UI.Controllers.HomeController.Index() in C:\Users\mccarthy\Documents\Visual Studio 2010\Projects\MVC3\MVC3.Web.UI\Controllers\HomeController.cs:line 13
at lambda_method(Closure , ControllerBase , Object[])
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
我不知道这个错误是什么和以前没有见过它。当我启动一个新的MVC2项目(我一直使用到现在为止),该网站运行得很好。
Microsoft在处理MVC3和MVC2框架之间的安全方面存在一些差异吗?
这个[相关的问题](http://stackoverflow.com/questions/4230909/odd-exception-in-mvc-3-project)可能会揭开一些光线 – PHeiberg 2012-01-06 17:27:41
PHeiberg。感谢您指向我的链接。我的解决方法虽然有点不同。没有在我的web.config中,我明确地设置了' '。所以我查看了我的machine.config文件,然后看,那是!我评论说,现在MVC3应用程序运行。谢谢! –
2012-01-06 19:16:54