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
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net4.8</TargetFramework>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ApplicationIcon>Resources\app.ico</ApplicationIcon>
|
||||
<AssemblyTitle>Starface Outlook Sync</AssemblyTitle>
|
||||
<Company>HackerSoft - Hacker-Net Telekommunikation</Company>
|
||||
<Product>Starface Outlook Sync</Product>
|
||||
@@ -13,21 +12,14 @@
|
||||
<FileVersion>0.0.0.1</FileVersion>
|
||||
<Description>Synchronisiert Outlook-Kontakte mit Starface Telefonanlage</Description>
|
||||
<Copyright>Stefan Hacker - HackerSoft</Copyright>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<SelfContained>false</SelfContained>
|
||||
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Office.Interop.Outlook">
|
||||
<HintPath>$(ProgramFiles)\Microsoft Office\root\Office16\ADDINS\Microsoft.Office.Interop.Outlook.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\app.ico" />
|
||||
<PackageReference Include="Microsoft.Office.Interop.Outlook" Version="15.0.4797.1004" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -228,17 +228,17 @@ namespace StarfaceOutlookSync.UI
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SyncSelectedProfile()
|
||||
private Task SyncSelectedProfile()
|
||||
{
|
||||
if (_profileList.SelectedItems.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Bitte ein Profil auswaehlen.", "Sync",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var profile = _profileList.SelectedItems[0].Tag as SyncProfile;
|
||||
if (profile == null) return;
|
||||
if (profile == null) return Task.CompletedTask;
|
||||
|
||||
using (var syncForm = new SyncProgressForm(profile))
|
||||
{
|
||||
@@ -246,6 +246,7 @@ namespace StarfaceOutlookSync.UI
|
||||
}
|
||||
|
||||
RefreshProfileList();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task RunSync(SyncProfile profile)
|
||||
|
||||
Reference in New Issue
Block a user