Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meaning of FirewallManager.IsServiceRunning and FirewallManager.Version #55

Open
Wenski opened this issue Jan 20, 2022 · 8 comments
Open
Assignees
Labels

Comments

@Wenski
Copy link

Wenski commented Jan 20, 2022

Hi,

at first a big thanks for wrapping nicer code around the windows firewall!
I tried to use WindowsFirewallHelper to add a rule at program start to my computers firewall. After a while and with your example code I found that IsServiceRunning returns false and Version returns None. I tried on two machines running Windows 11 with same results.
On both machines "Domain Networks" is disabled, private and public networks are enabled.
Do the results refer to the disabled "Domain Networks" firewall or does it mean something different?

Thanks,
Christian

@falahati
Copy link
Owner

Version shows what version of Windows Firewall is detected on the system.
IsServiceRunning tries to check and see if the Windows Firewall Service is running.

None of these should break your code. Can you post the code used to create the rule here?

Also, on what platform are you using this library? There might be some limitations with new UI frameworks.

I did not have the time or courage to try Win11 yet, probably late 2022 or next year when it is more mature; so, unfortunately, I can not provide specific support for Win11 but I try to point you in the right direction if I suspect something.

@falahati
Copy link
Owner

make sure you are running the app as admin btw

@Wenski
Copy link
Author

Wenski commented Jan 20, 2022

Although I am pretty sure it is running with elevated right I am going to perform a test tomorrow again.
It is a net6.0 console project running on Windows 10, Windows 11 is not a topic yet (and maybe never).
I will post code tomorrow.
Thanks for your quick response.

@Wenski
Copy link
Author

Wenski commented Jan 21, 2022

So after comparing with your example code and playing around I found that my net6.0 publish single configuration is the culprit. I was able to reproduce the problem with WindowsFirewallHelper.NetCoreSample by changing the csproj as below. You might have to do a clean build.
It seems like this is an issue in combination with net6.0. Changing TargetFramework to net5.0 works fine and that is what I am going to do.

cpsroj content:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>
	<PropertyGroup>
		<RuntimeIdentifier>win-x64</RuntimeIdentifier>
		<PublishSingleFile Condition="'$(Configuration)' == 'Release'">true</PublishSingleFile>
		<PublishTrimmed>true</PublishTrimmed>
		<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
	</PropertyGroup>

  <ItemGroup>
    <PackageReference Include="BasicConsoleUtilities" Version="1.0.0.6" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\WindowsFirewallHelper\WindowsFirewallHelper.csproj" />
  </ItemGroup>

</Project> 

@falahati
Copy link
Owner

falahati commented Jan 21, 2022

so this problem is with our latest release for .net6 probably or with the prior version; can you check the v2.2.0.86 and v2.1.4.81 separately? the only difference between the two is the net6 separate builds in v2.2.0.86. v2.1.4.81 however uses netstandard for forward compatibility.

Windows 11 is not a topic yet

I misunderstood the initial comment then. thought it is a win11 issue.

@bmueller84
Copy link

Could this one be related to a general trimming incompatibilities?

@bmueller84
Copy link

Looked a little more into this, and it appears that the problem really is related to the combination of trimming and COM interop. I was able to get it to work by adding
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
to csproj (see here) but the option is marked as risky.

@simonmurdock
Copy link

Bumped into an issue today where module trimming / single assembly was also to blame. worked fine once I put it back to a normal self-contained build.

@falahati falahati self-assigned this Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants