static void Main() { string _commandLine = Environment.CommandLine; if ((ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun) || _commandLine.ToLower().Contains("installic")) { try { LibInstaller.InstallLicense(true); } catch (Exception ex) { MessageBox.Show("Unable to install license: " + ex.Message); } } try { AssemblyTraceEvent.Tracer.TraceMessage(TraceEventType.Verbose, 53, $"Starting the application DataProvider.DPDiagnostics"); Application.Run(new Program()); AssemblyTraceEvent.Tracer.TraceMessage(TraceEventType.Verbose, 53, $"Finishing the application DataProvider.DPDiagnostics"); } catch (Exception ex) { TraceException(ex); MessageBox.Show("There is unexpected exception while executing the application" + ex.Message); } }
static void Main() { string _commandLine = Environment.CommandLine; #if DEBUG if (_commandLine.ToLower().Contains("debugstop")) { MessageBox.Show("Attach debug point", "Debug entry point", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } #endif if (_commandLine.ToLower().Contains("installic")) { try { LibInstaller.InstallLicense(false); } catch (Exception ex) { MessageBox.Show("License installation has failed, reason: " + ex.Message); } } MainForm _form = new MainForm(); try { Application.Run(_form); } catch (Exception) { } }
internal static void DoInstallLicense(bool loadLicenseFromDefaultContainer) { try { LibInstaller.InstallLicense(loadLicenseFromDefaultContainer); } catch (Exception ex) { MessageBoxShow(string.Format(Resources.MainProgram_LicenseInstalation_Failure, ex.Message)); } }
internal static void DoInstallLicense(bool loadLicenseFromDefaultContainer) { try { LibInstaller.InstallLicense(loadLicenseFromDefaultContainer); AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 113, "Installed the License without errors"); } catch (Exception ex) { MessageBoxShow(string.Format(Resources.MainProgram_LicenseInstalation_Failure, ex.Message)); } }
public static void InstallLicense(TestContext testContext) { try { LibInstaller.InstallLicense(false); CommServerComponent = new CommServerComponent(); SettingsBaseFixture _settings = new SettingsBaseFixture(); CommServerComponent.Initialize("DefaultConfig.xml", _settings); } catch (System.Exception _ex) { m_InstallLicenseError = _ex.ToString(); Debug.WriteLine(m_InstallLicenseError); throw; } }
public void InstallLicenseFromContainerAllParametersTest() { try { LibInstaller.InstallLicense("user", "company", "email", true, "", "", Assembly.GetExecutingAssembly()); Assert.Fail(); } catch (Exception ex) { DeployManifest _manifest = FileNames.ProductManifest(); Assert.IsNotNull(_manifest); Assert.AreEqual <string>("CAS.CodeProtect.UnitTests", _manifest.Product); Assert.IsFalse(ex.Message.Contains("CAS.CodeProtect.UnitTests")); Assert.IsTrue(ex.Message.Contains("CodeProtect.UnitTests")); ManifestManagement.DeleteDeployManifest(); } }
public void InstallLicenseFromContainerDefaultParametersTest() { try { LibInstaller.InstallLicense(true); Assert.Fail(); } catch (Exception ex) { DeployManifest _manifest = FileNames.ProductManifest(); Assert.IsNotNull(_manifest); Assert.AreEqual <string>("CAS.CodeProtect.UnitTests", _manifest.Product); Assert.IsFalse(ex.Message.Contains("CAS.CodeProtect.UnitTests")); Assert.IsTrue(ex.Message.Contains("CodeProtect.UnitTests")); ManifestManagement.DeleteDeployManifest(); } }
static void Main() { try { AssemblyTraceEvent.Tracer.TraceMessage(TraceEventType.Verbose, 32, "Starting application CAS.CommServer.ProtocolHub.ConfigurationEditor"); string m_CommandLine = Environment.CommandLine; if (m_CommandLine.ToLower().Contains("installic")) { try { LibInstaller.InstallLicense(false); } catch (LicenseFileException ex) { MessageBox.Show("Cannot install license, error:" + ex.Message); } } Application.Run ( new ConfigTreeView(ConfigurationManagement.ProtocolHubConfiguration, new ConfigIOHandler(ConfigurationManagement.ReadConfiguration), new ConfigIOHandler(ConfigurationManagement.SaveProc), new ConfigIOHandler(ConfigurationManagement.ClearConfig), Settings.Default.ToolsMenu) ); AssemblyTraceEvent.Tracer.TraceMessage(TraceEventType.Verbose, 32, "Finishing application CAS.CommServer.ProtocolHub.ConfigurationEditor"); } catch (Exception _ex) { string _message = $"The application has been finished by the exception {_ex.Message} call the vendor for assistance"; AssemblyTraceEvent.Tracer.TraceMessage(TraceEventType.Error, 36, _message); AssemblyTraceEvent.Tracer.TraceMessage(TraceEventType.Error, 36, $"Stock for the exception {_ex.StackTrace}"); MessageBox.Show(_message, "Application error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { AssemblyTraceEvent.Tracer.TraceSource.Flush(); } }
static void Main() { string m_cmmdLine = Environment.CommandLine; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (m_cmmdLine.ToLower().Contains(str_debug_install_argument)) { CASApplicationInstance.InstallServer(Assembly.GetExecutingAssembly().Location); } if (m_cmmdLine.ToLower().Contains(str_debug_uninstall_argument)) { CASApplicationInstance.UnInstallServer(Assembly.GetExecutingAssembly().Location); } CASApplicationInstance application = new CASApplicationInstance(); ConfigurationEditorMain config = new ConfigurationEditorMain(); try { if (!Environment.UserInteractive) { Directory.SetCurrentDirectory(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName); if (application.ProcessCommandLine()) { return; } application.StartAsService(new UAServer()); return; } } catch (Exception e) { Utils.Trace(e, "Unexpected error starting service."); return; } #if DEBUG MessageBox.Show("Attach debug point"); #endif if (m_cmmdLine.ToLower().Contains(str_installic_argument)) { try { LibInstaller.InstallLicense(true); } catch (Exception ex) { MessageBox.Show("License installation has failed, reason: " + ex.Message); } } UAServer server = new UAServer(); try { FileInfo configFI = RelativeFilePathsCalculator.GetAbsolutePathToFileInApplicationDataFolder(Settings.Default.ConfigurationFilePath); config.ReadConfiguration(configFI); if (config.Configuration == null) { throw new ArgumentNullException("Cannot read configuration"); } BaseDirectoryHelper.Instance.SetBaseDirectoryProvider(new BaseDirectoryProvider(configFI.DirectoryName)); ApplicationCertificate.CheckApplicationInstanceCertificate(config.Configuration, 1024, (x, y) => true, true); //TODO add logging function or user interface. ApplicationCertificate.OverrideUaTcpImplementation(config.Configuration); server.Start(config.Configuration); Application.Run(new ServerForm(server, config.Configuration, application)); } catch (Exception e) { HandleException("UA Server", e); } finally { server.Stop(); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 39, "Starting application."); string _commandLine = Environment.CommandLine; #if DEBUG if (_commandLine.ToLower().Contains("debugstop")) { MessageBox.Show("Attach debug point"); } #endif bool _isDebugRun = _commandLine.ToLower().Contains(m_InstallLicenseDebugerArgument); if (IsFirstRun() || _isDebugRun) { try { AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 49, $"Installing license because IsFirstRun={IsFirstRun()}, and debug={_isDebugRun}."); LibInstaller.InstallLicense(false); } catch (Exception _ex) { string _message = $"Installing license has failed, reason: {_ex.Message}: {_ex.StackTrace}."; AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Error, 55, _message); MessageBox.Show(_message, "License Installation error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } try { SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); if (!SecurityManager.IsGranted(permission)) { string msg = ""; msg += "This application requires permission to access unmanaged code "; msg += "in order to connect to COM-DA servers directly.\r\n\r\n"; msg += "Connections to XML-DA servers will not be affected."; MessageBox.Show(msg, "CAS OPCViewer Data Access Client"); } MainFormV2008 mainForm; string[] args = GetArguments(); if (args == null || args.Length < 2 || string.IsNullOrEmpty(args[1]) || args[1].Contains(m_InstallLicenseDebugerArgument) || args[1].Contains("http://")) { mainForm = new MainFormV2008(); } else { mainForm = new MainFormV2008(args[1]); //args[ 0 ] - is application file name , args[ 1 ] - is first argument } if (ApplicationDeployment.IsNetworkDeployed) { mainForm.DoNotShowUnlockCodeToolStrip(); } Application.Run(mainForm); } catch (Exception e) { string _message = $"An unexpected exception occurred. Application exiting with error:\r\n\r\n {e.Message}"; AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Error, 84, _message); MessageBox.Show(_message, "OPCViewer - Data Access Client", MessageBoxButtons.OK, MessageBoxIcon.Error); } }