簡體   English   中英

在Windows 2003 Server上運行C#應用程序時出錯

[英]Error while running C# application on windows 2003 server

我已經用C#開發了Windows應用程序。 使用部署和設置項目,我創建了該應用程序的設置。 應用程序使用.NET 4.0 Client profile 在Windows XP和Windows 7機器上,應用程序運行良好,但是在Windows Server 2003上,應用程序未打開。 在事件查看器中查看后,列出了兩個錯誤:

第一個錯誤:

應用程序:MyApp.exe框架版本:v4.0.30319說明:由於未處理的異常,進程已終止。 異常信息:System.IO.FileLoadException堆棧:在MyApp.Program.Main()

第二錯誤:

錯誤的應用程序MyApp.exe,版本1.0.0.0,標記5507c7af,錯誤的模塊kernel32.dll,版本5.2.3790.3959,標記45d70ad8,調試嗎? 0,故障地址0x0000bee7。

根據第一個錯誤,很明顯發生FileLoadException異常,但是我無法找到哪個文件,在這里Main()方法代碼:

static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static bool debuggingSubProcess = Properties.Settings.Default.debuggingSubProcess;
        [STAThread]
        static void Main()
        {
            SBMainForm mainForm = null;
            Init(out mainForm);
            if (!Cef.IsInitialized)
            {
                MessageBox.Show("Problem occured during initializing Exam Client software. Please close and retry.");
                System.Environment.Exit(0);
            }
            if (!mainForm.debugMode)
            {
                KeyboardBlocker.Block();
            }
            // 12 Feb 2015 :Set Keybord Layout to US 
            foreach (InputLanguage il in InputLanguage.InstalledInputLanguages)
            {
                if (il.LayoutName == "US")
                {
                    InputLanguage.CurrentInputLanguage = il;
                    break;
                }
            }
           Application.Run(mainForm);           
        }

        public static void Init(out SBMainForm mainForm)
        {
            var settings = new CefSettings();
            settings.UserAgent = "MOSB/1";
            if (debuggingSubProcess)
            {
                settings.RemoteDebuggingPort = 9484;
                settings.BrowserSubprocessPath = Application.StartupPath + "\\CefSharp.BrowserSubprocess.exe";
            }
            CefCustomScheme scheme = new CefCustomScheme();
            scheme.SchemeName = "typ";
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            mainForm = new SBMainForm();
            scheme.SchemeHandlerFactory = new SchemeFactory(mainForm);
            settings.RegisterScheme(scheme);

            if (!Cef.Initialize(settings))
            {
                if (Environment.GetCommandLineArgs().Contains("--type=renderer"))
                {
                    Environment.Exit(0);
                }
                else
                {
                    return;
                }
            }

        }
    }

CefSharp需要運行VS C ++可再發行文件。 您可以將“ Visual Studio C ++”可再發行文件設置為安裝程序的先決條件,也可以將該文件夾的內容復制到您的項目中:

C:\\ Program Files(x86)\\ Microsoft Visual Studio 11.0 \\ VC \\ redist \\ x86 \\ Microsoft.VC110.CRT

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM