Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MVC C#显示messagebox.show的应用程序错误 在VisualStudio 2015中运行MVC4应用程序时,她经常运行并在浏览器中运行所有的东西,ULTILIO MeaseBox。在代码中间显示,在一些地方使用相同的,通常不是问题。_C#_Asp.net_Visual Studio_Asp.net Mvc 4_Iis - Fatal编程技术网

MVC C#显示messagebox.show的应用程序错误 在VisualStudio 2015中运行MVC4应用程序时,她经常运行并在浏览器中运行所有的东西,ULTILIO MeaseBox。在代码中间显示,在一些地方使用相同的,通常不是问题。

MVC C#显示messagebox.show的应用程序错误 在VisualStudio 2015中运行MVC4应用程序时,她经常运行并在浏览器中运行所有的东西,ULTILIO MeaseBox。在代码中间显示,在一些地方使用相同的,通常不是问题。,c#,asp.net,visual-studio,asp.net-mvc-4,iis,C#,Asp.net,Visual Studio,Asp.net Mvc 4,Iis,我在开发Framework4.6时使用了它,也就是说,我在我的机器上安装了它,这将是服务器强制执行,我的IIS 7和我的UserAppPool只有Framework v4.0.30319 我不需要使用messageBox,但这是我找到的唯一解决方案,是否有其他选项为用户显示消息 在浏览器中打开应用程序时,单击按钮执行操作并生成消息框,它会生成以下错误: Erro de Servidor no Aplicativo '/'. Mostrar um formulário ou uma caixa

我在开发Framework4.6时使用了它,也就是说,我在我的机器上安装了它,这将是服务器强制执行,我的IIS 7和我的UserAppPool只有Framework v4.0.30319

我不需要使用messageBox,但这是我找到的唯一解决方案,是否有其他选项为用户显示消息

在浏览器中打开应用程序时,单击按钮执行操作并生成消息框,它会生成以下错误:

Erro de Servidor no Aplicativo '/'.

Mostrar um formulário ou uma caixa de diálogo restrita quando o aplicativo não está no modo UserInteractive não é uma operação válida. Especifique o estilo ServiceNotification ou DefaultDesktopOnly para exibir uma notificação de um aplicativo de serviços.

Descrição: Ocorreu uma exceção sem tratamento durante a execução da atual solicitação da Web. Examine o rastreamento de pilha para obter mais informações sobre o erro e onde foi originado no código. 

Detalhes da Exceção: System.InvalidOperationException: Mostrar um formulário ou uma caixa de diálogo restrita quando o aplicativo não está no modo UserInteractive não é uma operação válida. Especifique o estilo ServiceNotification ou DefaultDesktopOnly para exibir uma notificação de um aplicativo de serviços.

Erro de Origem: 


Linha 1:  @{
Linha 2:      ViewBag.Title = "Home Page";
Linha 3:  }
Linha 4:  <br />

Arquivo de Origem: C:\inetpub\wwwroot\mm_solution\Views\Home\Index.cshtml    Linha: 2 

Rastreamento de Pilha: 


[InvalidOperationException: Mostrar um formulário ou uma caixa de diálogo restrita quando o aplicativo não está no modo UserInteractive não é uma operação válida. Especifique o estilo ServiceNotification ou DefaultDesktopOnly para exibir uma notificação de um aplicativo de serviços.]
   System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp) +2994248
   MM_Solution_2.Controllers.HomeController.SendMessage(String test) +1609
   lambda_method(Closure , ControllerBase , Object[] ) +104
   System.Web.Mvc.<>c__DisplayClass1.<WrapVoidAction>b__0(ControllerBase controller, Object[] parameters) +14
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +157
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
   System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.Mvc.<>c__DisplayClassa.<EndProcessRequest>b__9() +22
   System.Web.Mvc.<>c__DisplayClass4.<Wrap>b__3() +10
   System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func`1 func) +27
   System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Action action) +64
   System.Web.Mvc.ServerExecuteHttpHandlerAsyncWrapper.EndProcessRequest(IAsyncResult result) +71
   System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +1556

[HttpException (0x80004005): Erro ao executar a solicitação filho do manipulador 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.]
   System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +3424518
   System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) +77
   System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +29
   System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +24
   System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) +463
   System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues) +83
   System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName) +9
   ASP._Page_Views_Home_Index_cshtml.Execute() in C:\inetpub\wwwroot\mm_solution\Views\Home\Index.cshtml:2
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105
   System.Web.WebPages.StartPage.RunPage() +17
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +64
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9711525
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

根据目前的评论线索

如果只想将“消息”从控制器发送到视图,可以将其设置为模型上的属性:

someModel.SomeProperty = "Some Message";
或者,在最坏的情况下,作为类似
ViewData
的一部分:

ViewData["SomeProperty"] = "Some Message";
然后,在视图中显示它。理想情况下,这将比
警报()更优雅。您可以将其包含在标记中:

@if(!string.IsNullOrEmpty(Model.SomeProperty)) {
    <div id="message">@Model.SomeProperty</div>
}

(将JavaScript代码放入Razor块时,您可能需要明智地使用
标记。有时语法会混淆呈现引擎。)

asp.net应用程序中不能有MessageBox如果您不理解问题,无法读取错误,并且您正试图在web应用程序中使用
MessageBox
。这里没有任何意义,对不起。@stuartd不,我不需要使用messageBox,但这是我找到的唯一解决方案,您有其他选项为用户显示消息吗?@David不,我不需要使用messageBox,但这是我找到的唯一解决方案,您还有其他选项可以向用户显示消息吗?@JhonnyPamponet:您必须显示您尝试过的内容,并解释它是如何无法按预期工作的。目前我给你的唯一建议是从一些关于web开发和ASP.NET MVC的入门教程开始
enviar

@if(!string.IsNullOrEmpty(Model.SomeProperty)){alert('@Model.SomeProperty');}但显示错误消息System.Core.dll中发生了“Microsoft.CSharp.RuntimeBinder.RuntimeBinderException”类型的异常,但未在用户代码中处理其他信息:Nãoépossível fazer associaço em tempo de execuço em uma referenceêncianula@JhonnyPamponet:嗯,您的模型是否有名为
SomeProperty
的属性?(或者随便你怎么称呼它。)另外,我看不懂那个错误信息,所以我只能猜测它说了什么。看起来您使用的
标记不正确,尽管我无法通过查看确定。
@if(!string.IsNullOrEmpty(Model.SomeProperty)) {
    <div id="message">@Model.SomeProperty</div>
}
@if(!string.IsNullOrEmpty(Model.SomeProperty)) {
    <script type="text/javascript">
        alert('@Model.SomeProperty');
    </script>
}