falahati / WindowsFirewallHelper

A class library to manage the Windows Firewall as well as adding your program to the Windows Firewall Exception list.
MIT License
276 stars 72 forks source link

.Net 8 NativeAOT Error #66

Open KFKMan opened 4 months ago

KFKMan commented 4 months ago

.Net 8, NativeAOT, Windows 10 10.0.19045, WindowsFirewallHelper 2.2.0.86

Publish Code; dotnet publish -r win-x64 -c Release

Code;

var rule = FirewallManager.Instance.CreateApplicationRule(name, FirewallAction.Block, AppPath, FirewallProtocol.Any);
rule.Direction = direction;
FirewallManager.Instance.Rules.Add(rule);

[Error] System.NotSupportedException: Specified method is not supported. at WindowsFirewallHelper.FirewallManager.get_Instance() + 0x58

.csproj;

  <PropertyGroup>
      <TargetFramework>net8.0</TargetFramework>
      <ImplicitUsings>enable</ImplicitUsings>
      <Nullable>enable</Nullable>
      <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
      <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
      <IncludeSymbolsInSingleFile>true</IncludeSymbolsInSingleFile>
      <PublishAot>true</PublishAot>
      <StripSymbols>true</StripSymbols>
      <RootNamespace>KavisPlus</RootNamespace>
          <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
  </PropertyGroup>