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

     
  • 相关阅读:
    数据包发送
    linux 进程调度3
    linux 进程调度2
    linux 进程调度1
    进程间通信:信号
    fork vfork clone学习
    跳表
    【转】Linux内存管理综述
    如何优雅的写出链表代码
    This function or variable may be unsafe Consider using xxx instead
  • 原文地址:https://www.cnblogs.com/caoming/p/4138601.html
Copyright © 2011-2022 走看看