Search code examples
c++.netwindowscomdcom

InvokeHelper() throws Access is denied exception


Community, I have quite interesting and in the same time heavy problem. I have VB .NET application + Service + C++ application. C++ application generates some data and makes callbacks using InvokeHelper() method:

InvokeHelper(0x60030000, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
     eventType, eventValue);

The first parameter is the dispid of method which should be called. Strange approach, but this is not my code and I can not change this way.

In service I have method marked by dispid attribute to get this callback from C++ application.

<DispId(&H60030000)>
Public Sub ServerEvent(ByVal vEventType As Integer, ByVal vEventValue As Object)
    RaiseEvent ControlPanelStateChange(vEventType, vEventValue)
End Sub

This code works correctly if I logged on as admin. But if windows user has not administrator permissions, right after calling InvokeHelper() method the next exception occurs:

First-chance exception at 0x75B7C42D (KernelBase.dll) in application.exe: 0x80070005: Access is denied

Do you have any ideas? I have played with DCOM permissions, but result is the same.

Any help would be fantastic!


Solution

  • The solution of the problem is:

    DCOMCNFG, right click on the My Computer and select properties -> COM Securities tab -> Access Permissions -> click Edit Defaults and add Network Service to it and give it Allow local access permission. Do the same for < Machine_name >\Users.

    Then -> Launch and Activation Permissions, click Edit Defaults and add Network Service to it and give it Local launch and Local Activation permission. Do the same for < Machine_name >\Users.