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:
2026-04-03 10:33:21 +02:00
parent 84ba78a1c5
commit ad649ad319
4 changed files with 41 additions and 28 deletions
@@ -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