Switch to .NET 8 for cross-platform build support
- Target net8.0-windows instead of net4.8 - EnableWindowsTargeting for Linux build - Replace Marshal.GetActiveObject with P/Invoke (not in .NET 8) - Use NuGet package for Outlook Interop instead of local DLL ref - Update Inno Setup script for .NET 8 runtime check - Builds successfully on Linux, runs on Windows Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,17 @@ namespace StarfaceOutlookSync.Services
|
||||
private Outlook.Application _outlookApp;
|
||||
private bool _weStartedOutlook;
|
||||
|
||||
// Marshal.GetActiveObject existiert nicht in .NET 8, daher P/Invoke
|
||||
[DllImport("oleaut32.dll", PreserveSig = false)]
|
||||
private static extern void GetActiveObject([MarshalAs(UnmanagedType.LPStruct)] Guid rclsid, IntPtr pvReserved, [MarshalAs(UnmanagedType.IUnknown)] out object ppunk);
|
||||
|
||||
private static object GetActiveComObject(string progId)
|
||||
{
|
||||
var clsid = Type.GetTypeFromProgID(progId, true).GUID;
|
||||
GetActiveObject(clsid, IntPtr.Zero, out var obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
private Outlook.Application GetOutlookApp()
|
||||
{
|
||||
if (_outlookApp != null) return _outlookApp;
|
||||
@@ -18,7 +29,7 @@ namespace StarfaceOutlookSync.Services
|
||||
try
|
||||
{
|
||||
// Versuche laufende Outlook-Instanz zu finden
|
||||
_outlookApp = (Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
|
||||
_outlookApp = (Outlook.Application)GetActiveComObject("Outlook.Application");
|
||||
_weStartedOutlook = false;
|
||||
}
|
||||
catch
|
||||
|
||||
Reference in New Issue
Block a user