Exemple #1
0
        public static void Main(string[] args)
        {
            // Must be fully safe
            try
            {
                // See if debugger attached
                Tools.EnableTracing = Debugger.IsAttached;
                Tools.DomainName    = "VCR.NET";

                // Dump environment
                //foreach (System.Collections.DictionaryEntry env in Environment.GetEnvironmentVariables())
                //    Tools.ExtendedLogging( "Environment {0}={1}", env.Key, env.Value );

                // Load configuration into main application domain
                VCRConfiguration.Startup();

                // Cleanup mess from earlier version
                try
                {
                    // Clear
                    var target = Path.Combine(Path.Combine(Tools.ApplicationDirectory.Parent.FullName, "bin"), "JMS.DVB.SourceManagement.dll");
                    if (File.Exists(target))
                    {
                        File.Delete(target);
                    }
                }
                catch (Exception e)
                {
                    // Report
                    VCRServer.LogError("DVB.NET Cleanup failed: {0}", e.Message);
                }

                // Show startup
                Tools.ExtendedLogging("Starting Service");

                // Run
                Service.Startup(args);

                // Show termination
                Tools.ExtendedLogging("Terminating Service");
            }
            catch (Exception e)
            {
                // Report
                Tools.LogException("Main", e);

                // Re-Throw
                throw e;
            }
        }
        /// <summary>
        /// Aktiviert eine bestimmte Konfiguration in der aktuellen <see cref="AppDomain"/>.
        /// </summary>
        /// <param name="configuration">Die gewünschte Konfiguration.</param>
        internal static void Register(VCRConfiguration configuration)
        {
            // Validate
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (Current != null)
            {
                throw new InvalidOperationException();
            }

            // Remember
            Current = configuration;
        }