utapyngo / icsmanager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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!

I have a fix: snd3r@bbb39ad

@TheObliterator could you please check this fix?
@snd3r will you create a pull request?

@utapyngo no problem. I need some more time to test this fix.

@utapyngo @snd3r Unfortunately that proposed fix doesn't resolve the problem. :(
I tried something similar myself based on a posting I found elsewhere about the error.
I've tested your fix directly and that doesn't work either.

@utapyngo @snd3r Just realised the logic around your call to CleanupWMISharingEntries() prevents it ever being called. If I force CleanupWMISharingEntries() function to be called - it works perfectly!

@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?

@utapyngo my pull request is pending : #18
This is my first pull request, please tell my if I'm doing something wrong.

@snd3r It needs to be tested.
@TheObliterator could you please test #18?

commented

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.