zoukankan      html  css  js  c++  java
  • 【Exception—WebForm】当应用程序不是以 UserInteractive 模式运行时显示模式对话框或窗体是无效操作。请指定 ServiceNotification 或 DefaultDesktopOnly 样式,以显示服务应用程序发出的通知。

      最近做的项目现在发布到服务器上开始测试了,本地好好的程序,到服务器上却报异常了:

      

    当应用程序不是以 UserInteractive 模式运行时显示模式对话框或窗体是无效操作。请指定 ServiceNotification 或 DefaultDesktopOnly 样式,以显示服务应用程序发出的通知。

     堆栈信息: 

    
    
    [InvalidOperationException: 当应用程序不是以 UserInteractive 模式运行时显示模式对话框或窗体是无效操作。请指定 ServiceNotification 或 DefaultDesktopOnly 样式,以显示服务应用程序发出的通知。]
       System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp) +2880696
       SPMS.student_info_ms._Default.btnRead_Click(Object sender, EventArgs e) in f:STLasp_net_web_seniorasp_net_web_seniorPluginsSPMS.student_info_msDefault.aspx.cs:66
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9633962
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

    可以看出问题出在MessageBox.Show()上,可以通过指定
    当然你可以指定MessageBoxOptions.ServiceNotifcation来解决这个问题:
    MessageBox.Show(msg, "Print Error", System.Windows.Forms.MessageBoxButtons.YesNo, 
       System.Windows.Forms.MessageBoxIcon.Error,     
       System.Windows.Forms.MessageBoxDefaultButton.Button1, 
       System.Windows.Forms.MessageBoxOptions.ServiceNotification);
    

      

    但是如果你的项目部署在IIS上或者服务器托管的进程上没有任何桌面,上述方法并不能如你所愿。你可以通过后台写入js脚本来处理:

    Response.Write(string.Fomate("<script>alert({0})</script>"),msg))
    
    
    

     转载请注明来源:http://www.cnblogs.com/caoming/p/4138601.html

     
  • 相关阅读:
    unexpected inconsistency;run fsck manually esxi断电后虚拟机启动故障
    centos 安装mysql 5.7
    centos 7 卸载mysql
    centos7 在线安装mysql5.6,客户端远程连接mysql
    ubuntu 14.04配置ip和dns
    centos7 上搭建mqtt服务
    windows eclipse IDE打开当前类所在文件路径
    git 在非空文件夹clone新项目
    eclipse中java build path下 allow output folders for source folders 无法勾选,该如何解决 eclipse中java build path下 allow output folders for source folders 无法勾选,
    Eclipse Kepler中配置JadClipse
  • 原文地址:https://www.cnblogs.com/caoming/p/4138601.html
Copyright © 2011-2022 走看看