Skip to content

Commit 3e10ba8

Browse files
committed
Ignore console encoding error when not in console mode
1 parent eef4120 commit 3e10ba8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

PasteIntoFile/Main.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,14 @@ class ArgsTray {
113113
/// </summary>
114114
[STAThread]
115115
static int Main(string[] args) {
116-
// redirect console output to parent process, for command line help etc.
117-
// not perfect, but probably as good as it can be: https://stackoverflow.com/a/11058118
118-
AttachConsole(ATTACH_PARENT_PROCESS);
119-
Console.OutputEncoding = Encoding.UTF8;
116+
try {
117+
// redirect console output to parent process, for command line help etc.
118+
// not perfect, but probably as good as it can be: https://stackoverflow.com/a/11058118
119+
AttachConsole(ATTACH_PARENT_PROCESS);
120+
Console.OutputEncoding = Encoding.UTF8;
121+
} catch {
122+
// ignored (probably non-console mode)
123+
}
120124

121125
#if PORTABLE
122126
// Portable settings

0 commit comments

Comments
 (0)