Esempio n. 1
0
        /// <summary>
        /// Main entry point into the Credentials Service Host
        /// </summary>
        internal static void Main(string[] args)
        {
            try
            {
                // read command-line arguments
                CommandOptions commandOptions = new CommandOptions(args);
                if (commandOptions.ShouldExit)
                {
                    return;
                }

                // turn on Verbose logging during early development
                // we need to switch to Normal when preparing for public preview
                Logger.Initialize(minimumLogLevel: LogLevel.Verbose, isEnabled: commandOptions.EnableLogging);
                Logger.Write(LogLevel.Normal, "Starting SqlTools Credentials Provider");

                // set up the host details and profile paths
                var hostDetails = new HostDetails(
                    name: "SqlTools Credentials Provider",
                    profileId: "Microsoft.SqlTools.Credentials",
                    version: new Version(1, 0));

                SqlToolsContext        sqlToolsContext = new SqlToolsContext(hostDetails);
                CredentialsServiceHost serviceHost     = HostLoader.CreateAndStartServiceHost(sqlToolsContext);

                serviceHost.WaitForExit();
            }
            catch (Exception e)
            {
                Logger.Write(LogLevel.Error, string.Format("An unhandled exception occurred: {0}", e));
                Environment.Exit(1);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Main entry point into the Credentials Service Host
        /// </summary>
        internal static void Main(string[] args)
        {
            try
            {
                // read command-line arguments
                CommandOptions commandOptions = new CommandOptions(args, ServiceName);
                if (commandOptions.ShouldExit)
                {
                    return;
                }

                string logFilePath = commandOptions.LogFilePath;
                if (string.IsNullOrWhiteSpace(logFilePath))
                {
                    logFilePath = "credentials";
                }
                if (!string.IsNullOrWhiteSpace(commandOptions.LoggingDirectory))
                {
                    logFilePath = Logger.GenerateLogFilePath(Path.Combine(commandOptions.LoggingDirectory, logFilePath));
                }

                Logger.Initialize(tracingLevel: commandOptions.TracingLevel, logFilePath: logFilePath, traceSource: "credentials");
                Logger.Write(TraceEventType.Information, "Starting SqlTools Credentials Provider");

                // set up the host details and profile paths
                var hostDetails = new HostDetails(
                    name: "SqlTools Credentials Provider",
                    profileId: "Microsoft.SqlTools.Credentials",
                    version: new Version(1, 0));

                SqlToolsContext    sqlToolsContext = new SqlToolsContext(hostDetails);
                UtilityServiceHost serviceHost     = HostLoader.CreateAndStartServiceHost(sqlToolsContext);

                serviceHost.WaitForExit();
            }
            catch (Exception e)
            {
                Logger.WriteWithCallstack(TraceEventType.Critical, $"An unhandled exception occurred: {e}");
                Environment.Exit(1);
            }
            finally
            {
                Logger.Close();
            }
        }