8000 Logger creation fails when there is no terminal · Issue #282 · unosquare/swan · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Logger creation fails when there is no terminal #282
Open
@katjoek

Description

@katjoek

Describe the bug
I've created a webserver using EmbedIO. That webserver is to be started by another application without the user seeing that it is running. So no console window should be present. I'm starting the application using this process definition:

        return new Process
        {
            EnableRaisingEvents = true,
            StartInfo = new ProcessStartInfo
            {
                WorkingDirectory = workingDirectory,
                FileName = fileName,
                CreateNoWindow = true,
                UseShellExecute = false,
                RedirectStandardInput = true,
                RedirectStandardOutput = true,
            },
        };

When the webserver application is started, the application fails. In the EventViewer we see this:

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.IOException
   at System.IO.__Error.WinIOError(Int32, System.String)
   at System.Console.set_CursorVisible(Boolean)
   at Swan.Terminal..cctor()

Exception Info: System.TypeInitializationException
   at Swan.Terminal.get_IsConsolePresent()
   at Swan.Logging.Logger..cctor()

Exception Info: System.TypeInitializationException
   at Swan.Logging.Logger.Info(System.String, System.String, System.Object, System.String, System.String, Int32)
   at EmbedIO.WebServer.CreateHttpListener()
   at EmbedIO.WebServer..ctor(System.Action`1<EmbedIO.WebServerOptions>)
   at Luxexcel.LensRecognition.Server.Program.CreateWebServer(System.String)
   at Luxexcel.LensRecognition.Server.Program.RunWebserver(Luxexcel.LensDiscovery.Shared.CommandLineOptions)
   at CommandLine.ParserResultExtensions.WithParsed[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](CommandLine.ParserResult`1<System.__Canon>, System.Action`1<System.__Canon>)
   at Luxexcel.LensRecognition.Server.Program.Main(System.String[])

It fails in Logger's class constructor on IsConsolePresent.

I'm using Swan 3.1.0

Expected behavior
It should not throw an exception and not try to add the terminal as a sink when it isn't there.

Desktop (please complete the following information):

  • OS: Windows 10
  • .NET Framework 4.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0