“动态操作只能在同构AppDomain中执行”错误

发布于 2024-12-25 04:43:58 字数 1475 浏览 3 评论 0原文

在我的 locahost 上运行 MVC3 站点时出现此错误。这是一个刚刚创建的新 MVC3 站点,HomeController Index 方法是从 ViewBag.Message 赋值中抛出它的地方。

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 框架安全性的方式是否存在差异?

I'm getting this error when running an MVC3 site on my locahost. It is a fresh MVC3 site just newly created, the HomeController Index method is where it's being thrown from, on the ViewBag.Message assignment.

public ActionResult Index()
{
    ViewBag.Message = "Welcome to ASP.NET MVC!";
    return View();
}

Stack trace:

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)

I have no idea what this error is and haven't seen it before. When I start up a new MVC2 project (what I've been using up until this point), the site runs just fine.

Is there some difference in how Microsoft treats security between the MVC3 and MVC2 frameworks?

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

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

发布评论

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

评论(1

与他有关 2025-01-01 04:43:58

好的,如果您的 web.config 中有以下行:

可能会发生这种类型的错误。然而,在 PHeiberg 提供给我的链接中,它说该行可能位于 web.config 中。我的 web.config 没有它。

所以我查看了 machine.config,发现了代码行!我将其注释掉,现在可以运行我的 MVC3 应用程序。

我不太确定它是如何出现在 machine.config 中的,或者由于我将其注释掉而可能破坏了其他什么内容,但这个迫在眉睫的问题已得到解决。

Okay, it seems that if you have the following line in your web.config:

<trust legacyCasModel="true" level="Full" />

this type of error could happen. Yet in the link that PHeiberg provided to me, it said the line could be in web.config. My web.config did not have it.

So I looked in machine.config, and there was the code line! I commented it out, and I can now run my MVC3 app.

I'm not too sure how it ended up in machine.config, or what else I might have broken as a result of me commenting it out, but this immediate problem is fixed.

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