Skip to content

Commit

Permalink
fixed バグ
Browse files Browse the repository at this point in the history
  • Loading branch information
anoyetta committed Sep 3, 2021
1 parent 6c6a7fd commit 39f7b87
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
32 changes: 19 additions & 13 deletions source/CeVIOAIProxy/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public App()
this.Exit += this.App_Exit;

this.DispatcherUnhandledException += this.App_DispatcherUnhandledException;
TaskScheduler.UnobservedTaskException += this.TaskScheduler_UnobservedTaskException;
AppDomain.CurrentDomain.UnhandledException += this.CurrentDomain_UnhandledException;
}

Expand Down Expand Up @@ -95,6 +96,14 @@ private void CloseServer()
private void App_DispatcherUnhandledException(
object sender,
DispatcherUnhandledExceptionEventArgs e)
{
e.Handled = true;
this.DumpUnhandledException(e.Exception);
}

private void TaskScheduler_UnobservedTaskException(
object sender,
UnobservedTaskExceptionEventArgs e)
{
this.DumpUnhandledException(e.Exception);
}
Expand All @@ -106,30 +115,27 @@ private void CurrentDomain_UnhandledException(
this.DumpUnhandledException(e.ExceptionObject as Exception);
}

private async void DumpUnhandledException(
private void DumpUnhandledException(
Exception ex)
{
await Task.Run(() =>
if (!Directory.Exists(Config.AppData))
{
if (!Directory.Exists(Config.AppData))
{
Directory.CreateDirectory(Config.AppData);
}

File.WriteAllText(
Path.Combine(Config.AppData, @".\CeVIOAIProxy.error.log"),
$"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}\n{ex}",
new UTF8Encoding(false));
});
Directory.CreateDirectory(Config.AppData);
}

File.WriteAllText(
Path.Combine(Config.AppData, @".\CeVIOAIProxy.error.log"),
$"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}\n{ex}",
new UTF8Encoding(false));
this.CloseServer();

CeVIOAIProxy.MainWindow.Instance?.HideNotifyIcon();
Config.Instance.Save();

MessageBox.Show(
"予期しない例外を検知しました。アプリケーションを終了します。\n\n" +
ex,
"Fatal",
"Fatal - CeVIO AI Proxy",
MessageBoxButton.OK,
MessageBoxImage.Error);

Expand Down
6 changes: 3 additions & 3 deletions source/CeVIOAIProxy/CeVIOAIProxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
<AssemblyOriginatorKeyFile>CeVIOAIProxy.pfx</AssemblyOriginatorKeyFile>
<Authors>anoyetta</Authors>
<Copyright>(c) 2021 anoyetta</Copyright>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<AssemblyVersion>1.2.0.1</AssemblyVersion>
<PackageIcon>share.ico</PackageIcon>
<PackageIconUrl />
<PackageProjectUrl>https://github.com/anoyetta/CeVIOAIProxy</PackageProjectUrl>
<RepositoryUrl>https://github.com/anoyetta/CeVIOAIProxy.git</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<Version>1.0.4</Version>
<Version>1.2.0.1</Version>
<StartupObject>CeVIOAIProxy.App</StartupObject>
<FileVersion>1.2.0.0</FileVersion>
<FileVersion>1.2.0.1</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
2 changes: 1 addition & 1 deletion source/CeVIOAIProxy/Servers/BouyomiChanHttpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public BouyomiChanHttpServer(
int port)
{
this.server = new HttpListener();
this.server.Prefixes.Add($"http://+:{port}/");
this.server.Prefixes.Add($"http://localhost:{port}/");
this.server.Start();
this.server.BeginGetContext(this.GetContextCallback, null);
}
Expand Down
3 changes: 3 additions & 0 deletions source/CeVIOAIProxy/app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- 通常 -->
<!--
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />

<!-- 管理者権限 -->
Expand Down

0 comments on commit 39f7b87

Please sign in to comment.