Show office exception instead of crash

This commit is contained in:
ema
2025-06-12 15:31:28 +08:00
parent e2e5885fd5
commit f897ce46ea
3 changed files with 17 additions and 11 deletions

View File

@@ -102,9 +102,7 @@ public class PreviewHandlerHost : Control
CurrentPreviewHandler = guid;
var o = Activator.CreateInstance(Type.GetTypeFromCLSID(CurrentPreviewHandler, true));
var fileInit = o as IInitializeWithFile;
if (fileInit == null)
if (o is not IInitializeWithFile fileInit)
return false;
fileInit.Initialize(path, 0);