Exception when enabling ICS: An event was unable to invoke any of the subscribers (HRESULT: 0x80040201)
TheObliterator opened this issue · comments
When I try to enable ICS sharing I get an exception:
System.Runtime.InteropServices.COMException: An event was unable to invoke any of the subscribers (Exception from HRESULT: 0x80040201) at NETCONLib.INetSharingConfiguration.EnableSharing(tagSHARINGCONNECTIONTYPE Type) at IcsManagerLibrary.IcsManager.ShareConnection(INetConnection connectionToShare, INetConnection homeConnection)
I'm running the console app as admin and have tried registering hnetcfg.dll. Running Win 7 x64.
If I manually enable ICS in Windows, then this library is able to enable/disable ICS subsequently. My problem is I'm trying to automate this process and don't want to rely on the user having enabled ICS manually first.
Any ideas how to resolve this error? Really useful library otherwise!
Does this pure PowerShell solution result in the same error?
I have a fix: snd3r@bbb39ad
@TheObliterator could you please check this fix?
@snd3r will you create a pull request?
@TheObliterator You did as I expected to use.
I can make a request to merge without conditions, then the cleaning will be done every time. The only thing I'm not sure about, maybe the situation where more than one connection is shared.
@snd3r I'm wasn't aware you can share more than one connection at a time.
How about calling CleanUpWMISharingEntries function if an exception occurs whilst enabling a new ICS, then retrying?
@snd3r It needs to be tested.
@TheObliterator could you please test #18?
the same error message when I ran it in win10
It is awesome that though I have not used Windows for seven years, people still use my project. I am sorry I cannot fix it myself.
@pscj if you manage to fix it, please open a pull request.
This issue is the first link in Google and I found these very useful. I thought I would post as @pscj received the same issue and it might be related.
I had a 100% repeatable error path that caused this error. After trying to work out why the example app in ICS Manager worked and mine didn't I discovered that changing my app from 64 bit to 32 bit resolved the error.