Amogh
Amogh

Reputation: 4573

Error while running C# application on windows 2003 server

I have developed windows application in C#. Using deployment and setup project I created setup of that application. Application uses .NET 4.0 Client profile. On Windows XP and Windows 7 machine application is running very well, but on Windows server 2003 application is not opening. After looking in Event Viewer two errors are listed that are :

First Error :

Application: MyApp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileLoadException Stack: at MyApp.Program.Main()

Second Error :

Faulting application MyApp.exe, version 1.0.0.0, stamp 5507c7af, faulting module kernel32.dll, version 5.2.3790.3959, stamp 45d70ad8, debug? 0, fault address 0x0000bee7.

According to first error it is clear that FileLoadException exception is occurred but I am not able to find which file, here Main() method code :

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;
                }
            }

        }
    }

Upvotes: 0

Views: 439

Answers (1)

Khatibzadeh
Khatibzadeh

Reputation: 470

CefSharp requires the VS C++ redistributables to run. You can either set the "Visual Studio C++" redistributables as pre-requisites of the installer or by copying over to your project the contents of this folder:

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

Upvotes: 0

Related Questions