none
Unable to add a reference to a COM EXE to a C# project RRS feed

  • Question

  • I am trying to add a reference to a 64 bit and a 32 bit COM Exe to a C# 4.6.1 project. The reference to the 32 bit COM Exe gets added without problems but I get a "A reference to "ProcessMonitorLibX64,exe" could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component". I did not have problems with the 64 bit COM Exe earlier. This problem came up suddenly and I cant resolve it. Some setting has changed or the project has become corrupt

    When this problem happened some time ago previously, restoring from git worked. But this time it seems I have committed the corrupt version to git

    I tried the following steps, and then tried adding the exe after recompiling it

    a. Unloading and reloading the project 

    b. Cleaning the project

    c. Loading and unloading the solution [Restarting VS2019]

    d. Restoring the project from a git repository

    e. Trying /regserver from admin command prompt [By the way, the project name does not show in the list of COM components in the "Add Reference" dialog.]

    Please help.

    Thanks,

    Sagar

    Wednesday, May 22, 2019 9:14 AM

All replies

  • Have you used regedit to determine if the required keys and values exist after registering your x64 server from the elevated command prompt?

    Have you tried using the SDK utility oleview.exe to look at the type library embedded in the x64 server's resources?

    Can you successfully use the x64 server from a native C++ COM client?


    Wednesday, May 22, 2019 9:22 AM
  • ProcessMonitorLibX64.idl

    [
    	object,
    	uuid(0229F23D-D612-4220-9C7E-E9B0A568E9EB),
    	dual,
    	nonextensible,
    	pointer_default(unique)
    ]
    interface IProcessMonitorX64 : IDispatch{
    	[id(1), helpstring("Hook a process")] HRESULT HookProcess([in] LONG processId, [in] BSTR processName, [in] LONG idleTime);
    	[id(2), helpstring("Unhook Process")] HRESULT UnhookProcess([in] LONG processId);
    	[id(3), helpstring("Pause the Hooking Process")] HRESULT Pause();
    	[id(4), helpstring("Continue the Hook Process")] HRESULT Continue();
    	[id(5), helpstring("Shuts down the app")] HRESULT Shutdown();
    	[propget, id(6), helpstring("Get and Set the Idle Time")] HRESULT IdleTime([in] LONG idleTime, [out, retval] LONG* pVal);
    	[propput, id(6), helpstring("Get and Set the Idle Time")] HRESULT IdleTime([in] LONG idleTime, [in] LONG newVal);
    };
    [
    	uuid(135466FD-A2D8-47FD-B7D1-A01518ECF498),
    	version(1.0),
    ]
    library ProcessMonitorLibX64Lib
    {
    	importlib("stdole2.tlb");
    	[
    		uuid(B77984CA-8ED7-433A-90A5-99B9FC19E1BE)		
    	]
    	dispinterface _IProcessMonitorX64Events
    	{
    		properties:
    		methods:
    	};
    	[
    		uuid(4FE6D01C-7590-4E52-9303-0E66566C0CED)		
    	]
    	coclass ProcessMonitorX64
    	{
    		[default] interface IProcessMonitorX64;
    		[default, source] dispinterface _IProcessMonitorX64Events;
    	};
    };
    

    Oleview Results

    // Generated .IDL file (by the OLE/COM Object Viewer)
    // 
    // typelib filename: ProcessMonitorLibX64.exe
    
    [
      uuid(135466FD-A2D8-47FD-B7D1-A01518ECF498),
      version(1.0),
      custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 134283886),
      custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 2147483647),
      custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, "Created by MIDL version 8.01.0622 at Tue Jan 19 08:44:07 2038
    ")
    
    ]
    library ProcessMonitorLibX64Lib
    {
        // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
        importlib("stdole2.tlb");
    
        // Forward declare all types defined in this typelib
        dispinterface _IProcessMonitorX64Events;
        interface IProcessMonitorX64;
    
        [
          uuid(B77984CA-8ED7-433A-90A5-99B9FC19E1BE)
        ]
        dispinterface _IProcessMonitorX64Events {
            properties:
            methods:
        };
    
        [
          uuid(4FE6D01C-7590-4E52-9303-0E66566C0CED)
        ]
        coclass ProcessMonitorX64 {
            [default] interface IProcessMonitorX64;
            [default, source] dispinterface _IProcessMonitorX64Events;
        };
    
        [
          odl,
          uuid(0229F23D-D612-4220-9C7E-E9B0A568E9EB),
          dual,
          nonextensible,
          oleautomation
        ]
        interface IProcessMonitorX64 : IDispatch {
            [id(0x00000001), helpstring("Hook a process")]
            HRESULT HookProcess(
                            [in] long processId, 
                            [in] BSTR processName, 
                            [in] long idleTime);
            [id(0x00000002), helpstring("Unhook Process")]
            HRESULT UnhookProcess([in] long processId);
            [id(0x00000003), helpstring("Pause the Hooking Process")]
            HRESULT Pause();
            [id(0x00000004), helpstring("Continue the Hook Process")]
            HRESULT Continue();
            [id(0x00000005), helpstring("Shuts down the app")]
            HRESULT Shutdown();
            [id(0x00000006), propget, helpstring("Get and Set the Idle Time")]
            HRESULT idleTime(
                            [in] long idleTime, 
                            [out, retval] long* pVal);
            [id(0x00000006), propput, helpstring("Get and Set the Idle Time")]
            HRESULT idleTime(
                            [in] long idleTime, 
                            [in] long pVal);
        };
    };
    

    Registry Key

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Interface\{0229F23D-D612-4220-9C7E-E9B0A568E9EB}\TypeLib]
    @="{135466FD-A2D8-47FD-B7D1-A01518ECF498}"
    "Version"="1.0"

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\CLSID\{4FE6D01C-7590-4E52-9303-0E66566C0CED}]
    @="ProcessMonitorX64 Class"

    [HKEY_CLASSES_ROOT\CLSID\{4FE6D01C-7590-4E52-9303-0E66566C0CED}\LocalServer32]
    @="\"D:\\bizbrain-agent-v7\\x64\\Debug\\ProcessMonitorLibX64.exe\""
    "ServerExecutable"="D:\\bizbrain-agent-v7\\x64\\Debug\\ProcessMonitorLibX64.exe"

    [HKEY_CLASSES_ROOT\CLSID\{4FE6D01C-7590-4E52-9303-0E66566C0CED}\ProgID]
    @="MyTallyApp.ProcessMonitorX64.1"

    [HKEY_CLASSES_ROOT\CLSID\{4FE6D01C-7590-4E52-9303-0E66566C0CED}\Programmable]

    [HKEY_CLASSES_ROOT\CLSID\{4FE6D01C-7590-4E52-9303-0E66566C0CED}\TypeLib]
    @="{135466FD-A2D8-47FD-B7D1-A01518ECF498}"

    [HKEY_CLASSES_ROOT\CLSID\{4FE6D01C-7590-4E52-9303-0E66566C0CED}\Version]
    @="1.0"

    [HKEY_CLASSES_ROOT\CLSID\{4FE6D01C-7590-4E52-9303-0E66566C0CED}\VersionIndependentProgID]
    @="MyTallyApp.ProcessMonitorX64"

    All three seem to be OK. If necessary, I will paste each and every registry key I find

    I will check if I can use it from a native C++ client and post the results here.

    Wednesday, May 22, 2019 10:05 AM
  • What about the type library registration?

    • Edited by RLWA32 Wednesday, May 22, 2019 10:27 AM
    Wednesday, May 22, 2019 10:25 AM
  • Calling from native C++ client was also successful

    int main()
    {

    cout << "Hello" << endl;
    CoInitialize(NULL);
    CComPtr<IProcessMonitorX64>ptr;
    HRESULT hr = ptr.CoCreateInstance(__uuidof(ProcessMonitorX64), NULL, CLSCTX_ALL);
    switch (hr) {
    case REGDB_E_CLASSNOTREG:
    MessageBoxA(0, "REGDB_E_CLASSNOTREG", "Failed", MB_OK);
    break;
    case CLASS_E_NOAGGREGATION:
    MessageBoxA(0, "REGDB_E_NOAGGREGATION", "Failed", MB_OK);
    break;
    case CO_E_CLASSSTRING:
    MessageBoxA(0, "REGDB_E_CLASSSTRING", "Failed", MB_OK);
    break;
    case  E_NOINTERFACE:
    MessageBoxA(0, "NOINTERFACE", "Failed", MB_OK);
    break;
    default:
    cout << "Sucess";
    break;
    }
    CoUninitialize();
    }

    Output
    1>TestProcessMonitorX64Native.cpp
    1>TestProcessMonitorX64Native_i.c
    1>TestProcessMonitorX64Native.vcxproj -> D:\bizbrain-agent-v7\x64\Debug\TestProcessMonitorX64Native.exe
    1>Hello
    1>Sucess
    ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========


    Wednesday, May 22, 2019 10:26 AM
  • I opened the exe with oleview and pasted the contents in the reply above. Pasting it again.

    // Generated .IDL file (by the OLE/COM Object Viewer)
    // 
    // typelib filename: ProcessMonitorLibX64.exe

    [
      uuid(135466FD-A2D8-47FD-B7D1-A01518ECF498),
      version(1.0),
      custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 134283886),
      custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 2147483647),
      custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, "Created by MIDL version 8.01.0622 at Tue Jan 19 08:44:07 2038
    ")

    ]
    library ProcessMonitorLibX64Lib
    {
        // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
        importlib("stdole2.tlb");

        // Forward declare all types defined in this typelib
        dispinterface _IProcessMonitorX64Events;
        interface IProcessMonitorX64;

        [
          uuid(B77984CA-8ED7-433A-90A5-99B9FC19E1BE)
        ]
        dispinterface _IProcessMonitorX64Events {
            properties:
            methods:
        };

        [
          uuid(4FE6D01C-7590-4E52-9303-0E66566C0CED)
        ]
        coclass ProcessMonitorX64 {
            [default] interface IProcessMonitorX64;
            [default, source] dispinterface _IProcessMonitorX64Events;
        };

        [
          odl,
          uuid(0229F23D-D612-4220-9C7E-E9B0A568E9EB),
          dual,
          nonextensible,
          oleautomation
        ]
        interface IProcessMonitorX64 : IDispatch {
            [id(0x00000001), helpstring("Hook a process")]
            HRESULT HookProcess(
                            [in] long processId, 
                            [in] BSTR processName, 
                            [in] long idleTime);
            [id(0x00000002), helpstring("Unhook Process")]
            HRESULT UnhookProcess([in] long processId);
            [id(0x00000003), helpstring("Pause the Hooking Process")]
            HRESULT Pause();
            [id(0x00000004), helpstring("Continue the Hook Process")]
            HRESULT Continue();
            [id(0x00000005), helpstring("Shuts down the app")]
            HRESULT Shutdown();
            [id(0x00000006), propget, helpstring("Get and Set the Idle Time")]
            HRESULT idleTime(
                            [in] long idleTime, 
                            [out, retval] long* pVal);
            [id(0x00000006), propput, helpstring("Get and Set the Idle Time")]
            HRESULT idleTime(
                            [in] long idleTime, 
                            [in] long pVal);
        };
    };

    Wednesday, May 22, 2019 10:27 AM
  • Sorry, I didn't notice earlier that you posted the output from oleview as well as the idl.
    Wednesday, May 22, 2019 10:34 AM
  • Just in case you didn't notice earlier -- was the type library properly registered?
    Wednesday, May 22, 2019 10:40 AM
  • Registered meaning there are corresponding registry entries? There do appear to be registry entries corresponding to the type library. I pasted two above

    I could create an instance in a native c++ client. So I guess the type library is registered properly.

    Wednesday, May 22, 2019 10:48 AM
  • Registered meaning there are corresponding registry entries? There do appear to be registry entries corresponding to the type library. I pasted two above

    If the type library has been registered then its guid should appear under HKCR\TypeLIb.  I don't see any such postings. 

    You were probably referring to the entry under "Interface".  This is not the type library registration, its used for marshaling but I expect that the type library is registered if this entry exists.

    I could create an instance in a native c++ client. So I guess the type library is registered properly.

    A type library registration is not required to instantiate a COM object.



    • Edited by RLWA32 Wednesday, May 22, 2019 11:07 AM expanded comment
    Wednesday, May 22, 2019 11:00 AM
  • I found the following key

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}]

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0]
    @="ProcessMonitorLibX64Lib"

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0\0]

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0\0\win32]
    @="D:\\bizbrain-agent-v7\\Debug\\ProcessMonitorLibX64.exe"

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0\0\win64]
    @="D:\\bizbrain-agent-v7\\x64\\Debug\\ProcessMonitorLibX64.exe"

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0\FLAGS]
    @="0"

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0\HELPDIR]
    @="D:\\bizbrain-agent-v7\\Debug"

    Wednesday, May 22, 2019 11:39 AM
  • When you look in the COM section of the Add Reference dialog do you see ProcessMonitorLibX64Lib?
    Wednesday, May 22, 2019 11:54 AM
  • No, I can see only the x86 versionOnly the x86 version is shown in the "add reference" dialog
    Wednesday, May 22, 2019 12:02 PM
  • Are you using the same guid but giving the x86 and x64 type libraries different names?

    • Edited by RLWA32 Wednesday, May 22, 2019 12:25 PM
    Wednesday, May 22, 2019 12:24 PM
  • // Generated .IDL file (by the OLE/COM Object Viewer)
    // 
    // typelib filename: ProcessMonitorLibX64.exe
    
    [
      uuid(135466FD-A2D8-47FD-B7D1-A01518ECF498),
      version(1.0),
      custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 134283886),
      custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 2147483647),
      custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, "Created by MIDL version 8.01.0622 at Tue Jan 19 08:44:07 2038
    ")
    
    ]
    library ProcessMonitorLibX64Lib
    {
        // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
        importlib("stdole2.tlb");
    
        // Forward declare all types defined in this typelib
        dispinterface _IProcessMonitorX64Events;
        interface IProcessMonitorX64;
    
        [
          uuid(B77984CA-8ED7-433A-90A5-99B9FC19E1BE)
        ]
        dispinterface _IProcessMonitorX64Events {
            properties:
            methods:
        };
    
        [
          uuid(4FE6D01C-7590-4E52-9303-0E66566C0CED)
        ]
        coclass ProcessMonitorX64 {
            [default] interface IProcessMonitorX64;
            [default, source] dispinterface _IProcessMonitorX64Events;
        };
    
        [
          odl,
          uuid(0229F23D-D612-4220-9C7E-E9B0A568E9EB),
          dual,
          nonextensible,
          oleautomation
        ]
        interface IProcessMonitorX64 : IDispatch {
            [id(0x00000001), helpstring("Hook a process")]
            HRESULT HookProcess(
                            [in] long processId, 
                            [in] BSTR processName, 
                            [in] long idleTime);
            [id(0x00000002), helpstring("Unhook Process")]
            HRESULT UnhookProcess([in] long processId);
            [id(0x00000003), helpstring("Pause the Hooking Process")]
            HRESULT Pause();
            [id(0x00000004), helpstring("Continue the Hook Process")]
            HRESULT Continue();
            [id(0x00000005), helpstring("Shuts down the app")]
            HRESULT Shutdown();
            [id(0x00000006), propget, helpstring("Get and Set the Idle Time")]
            HRESULT idleTime(
                            [in] long idleTime, 
                            [out, retval] long* pVal);
            [id(0x00000006), propput, helpstring("Get and Set the Idle Time")]
            HRESULT idleTime(
                            [in] long idleTime, 
                            [in] long pVal);
        };
    };

    // Generated .IDL file (by the OLE/COM Object Viewer)
    // 
    // typelib filename: ProcessMonitorLibX86.exe
    
    [
      uuid(6B9DDD14-2452-42A3-A4FF-F119D0125AB1),
      version(1.0),
      custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 134283886),
      custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 2147483647),
      custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, "Created by MIDL version 8.01.0622 at Tue Jan 19 08:44:07 2038
    ")
    
    ]
    library ProcessMonitorLibX86Lib
    {
        // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
        importlib("stdole2.tlb");
    
        // Forward declare all types defined in this typelib
        dispinterface _IProcessMonitorX86Events;
        interface IProcessMonitorX86;
    
        [
          uuid(F4A46F3D-2C9E-4DA3-A44B-E151A8F14005)
        ]
        dispinterface _IProcessMonitorX86Events {
            properties:
            methods:
        };
    
        [
          uuid(67C49CB5-6D93-4891-9B59-AA1E89D48F32)
        ]
        coclass ProcessMonitorX86 {
            [default] interface IProcessMonitorX86;
            [default, source] dispinterface _IProcessMonitorX86Events;
        };
    
        [
          odl,
          uuid(77CC3384-E204-4BC4-BAEE-534315B9130F),
          dual,
          nonextensible,
          oleautomation
        ]
        interface IProcessMonitorX86 : IDispatch {
            [id(0x00000001), helpstring("Hooks a Process")]
            HRESULT HookProcess(
                            [in] long processId, 
                            [in] BSTR processName, 
                            [in] long idleTime);
            [id(0x00000002), helpstring("Unhooks the Process")]
            HRESULT UnhookProcess([in] long processId);
            [id(0x00000003), helpstring("Pauses the Hook")]
            HRESULT Pause();
            [id(0x00000004), helpstring("Continue the Hook Process")]
            HRESULT Continue();
            [id(0x00000005), helpstring("Shuts down the app")]
            HRESULT Shutdown();
            [id(0x00000006), propget, helpstring("Get and Set the Idle Time")]
            HRESULT idleTime(
                            [in] long idleTime, 
                            [out, retval] long* pVal);
            [id(0x00000006), propput, helpstring("Get and Set the Idle Time")]
            HRESULT idleTime(
                            [in] long idleTime, 
                            [in] long pVal);
        };
    };
    I dont think so.  I created the two projects separately, they have similar but not identical code.
    • Edited by Sagar R. Kapadia Wednesday, May 22, 2019 12:31 PM Additional Information
    Wednesday, May 22, 2019 12:30 PM
  • I also created another c# project and tried to add the references. X86 gets added but X64 does not, the same as in the other project. I did this to check if there is something wrong with the c# project to which I am trying to add the reference.

    Wednesday, May 22, 2019 12:36 PM
  • I don't think you can add project references for a COM exe server.  I always added a reference to the type library.  If your managed code is running as 32 bit then it should find the 32 bit server and if running as 64 bit it should find the 64 bit server.
    Wednesday, May 22, 2019 12:42 PM
  • Add Reference Dialog

    Reference added successfully to the projectSuccessfully added to another project

    Wednesday, May 22, 2019 12:50 PM
  • The type library registration you found was for the x64 type library according to the guid -

    uuid(135466FD-A2D8-47FD-B7D1-A01518ECF498)


    • Edited by RLWA32 Wednesday, May 22, 2019 12:54 PM
    Wednesday, May 22, 2019 12:53 PM
  • The screenshots show the x86 version added to a new project and the x64 version added to an older project. I have not yet removed it from the old project and tried to add the new version, so it is still there. I think when we add a COM exe or dll, an interop file is created for it. Thats how I have been adding references all the time.

    The screenshot shows the interop files generated 

    interop files

    Wednesday, May 22, 2019 12:53 PM
  • I think you are correct. But I found the following entry in the registry entry, which I pasted above

    I found the following key

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}]

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0]
    @="ProcessMonitorLibX64Lib"

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0\0]

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0\0\win32]
    @="D:\\bizbrain-agent-v7\\Debug\\ProcessMonitorLibX64.exe"

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0\0\win64]
    @="D:\\bizbrain-agent-v7\\x64\\Debug\\ProcessMonitorLibX64.exe"

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0\FLAGS]
    @="0"

    [HKEY_CLASSES_ROOT\TypeLib\{135466FD-A2D8-47FD-B7D1-A01518ECF498}\1.0\HELPDIR]
    @="D:\\bizbrain-agent-v7\\Debug"

    Wednesday, May 22, 2019 12:54 PM
  • I tried to add a reference to the type library in the obj folder too. But I got the same error message.

    Wednesday, May 22, 2019 12:56 PM
  • Also ProcessMonitorLibX64 /regserver does not give any error message [neither does /unregserver]

    Wednesday, May 22, 2019 12:58 PM
  • I have to leave now, will catch up soon [a few hours later]

    Wednesday, May 22, 2019 1:01 PM
  • I don't use VS2019.

    You shouldn't need to use different guids for your x86 and x64 COM servers.

    The x86 servers are registered in the 32 bit view of the registry and x64 servers are registered in the 64 bit view.

    I'm guessing that if Visual Studio is running as a 32 bit application it only sees the 32 bit registry view when collecting type libraries to display in the Add Reference dialog.


    • Edited by RLWA32 Wednesday, May 22, 2019 1:09 PM corrected 32/64 bit typo
    Wednesday, May 22, 2019 1:02 PM
  • I didnt know that. Thanks. But I did not do it deliberately. The two projects were created separately and so they have different GUIDs

    I have faced this problem [unable to add references] in the past too. But it was resolved by restoring from a git backup.Unfortunately, it does not work this time. In the worst case, I will have to recreate the project

    Wednesday, May 22, 2019 1:04 PM
  • Are the COM servers identical except for their guids?

    The same interfaces/methods/parameters?

    • Edited by RLWA32 Wednesday, May 22, 2019 1:10 PM
    Wednesday, May 22, 2019 1:09 PM
  • Using VS2015 I created a solution that contained two separate out of process COM servers.  One was built as a 32 bit server and the other was built as a 64 bit server.  Each server had its own set of unique guids and was registered.

    Then I added two C# projects.  One was built as a 32 bit project and the other as a 64 bit project.  To each of them I was able to add references to the 32 bit and the 64 bit COM servers.  The type libraries for both the 32 bit and the 64 bit servers were present in the COM section of the Add Reference dialog.  I was also able to add references by browsing to the locations of the executable servers and selecting them.

    Each of the two C# console application was able to instantiate and use the 32 bit and the 64 bit COM servers.

    Wednesday, May 22, 2019 6:10 PM
  • Mostly yes, there will be differences of spaces and tabs and perhaps order of methods
    Friday, May 24, 2019 4:12 AM
  • Another thought.  As a sanity check you can use oleview.exe to see if both the 32 bit and 64 bit servers have registered their type libraries.  If they are both registered they should be visible in oleview's list of registered libraries.  If oleview can see both but Visual Studio cannot then at least you know that the problem is with Visual Studio.

    For example, oleview showed the type library for my 32 bit server (ComSrv86Lib) and 64 bit server (ComSrv64Lib) as follows -

    Friday, May 24, 2019 10:42 AM
  • Also, see the discussion at https://stackoverflow.com/questions/44019317/visual-studio-cant-reference-tlb-dll-anymore

    RLWA32, Thanks a lot for the suggestions, and especially this one. I used tlbimp to export the type library. This created a dll file, which I added as a reference. It  seems to  work exactly as if I had added the exe file directly as a reference.  However, I am getting a class not registered exception further down the line. I checked to see if the process was created as 64 bit or 32 bit  , but it seems to be 64 bit, which is ok. So now I am trying to figure out the reason for the class not registered issue. 


    Friday, May 24, 2019 10:48 AM
  • Another thought.  As a sanity check you can use oleview.exe to see if both the 32 bit and 64 bit servers have registered their type libraries.  If they are both registered they should be visible in oleview's list of registered libraries.  If oleview can see both but Visual Studio cannot then at least you know that the problem is with Visual Studio.

    For example, oleview showed the type library for my 32 bit server (ComSrv86Lib) and 64 bit server (ComSrv64Lib) as follows -

    I can see both the type libraries
    Friday, May 24, 2019 10:49 AM
  • So can we conclude that there seems to be a problem with Visual studio (2019)?

    Friday, May 24, 2019 10:50 AM
  • I'm not ready to conclude that VS2019 is the problem just yet.

    I noticed that you have registrations for  a 32 bit type library and a 64 bit type library for ProcessMonitorLibx64LIb. Perhaps you have done the same thing for ProcessMonitorLibx86Lib. 

    Do both 32 and 64 bit versions of the same server actually exist?

    I suggest you unregister everything.  For your 64 bit server only build and register for 64 bits.  For your 32 bit server only build and register for 32 bits.

    Oleview should only show one entry for each type library (e.g., win32 for the 32 bit server and win64 for the 64 bit server.



    • Edited by RLWA32 Friday, May 24, 2019 11:34 AM
    Friday, May 24, 2019 11:28 AM
  • So now I am trying to figure out the reason for the class not registered issue. 


    See my earlier comment questioning whether 32 bit and 64 bit versions of the same servers exist.

    Also, I suggest you unregister all versions of your COM servers, rebuild the x86 COM server only for 32 bits, rebuild the x64 COM server ony for 64 bits and then register the two servers.

    Check that both the 32 and 64 bit servers were completely and properly registered.

    Remove the references from your VS C# project(s).  Delete the interop dlls that were previously created.

    Start over with cleaned projects.

    • Edited by RLWA32 Friday, May 24, 2019 12:19 PM explicitly added "start over" suggestion
    Friday, May 24, 2019 12:02 PM
  • At present, using tlbimp, I have two dlls for each version, and I can add them both successfully as references. I got a class not registered further down the line for another COM component [DLL]. This was set to any CPU. The component got found when I changed it to X64. It seems to be working ok now ; I am testing

    However, I will definitely try out what you said [Unregister all versions and so on ]

    Friday, May 24, 2019 12:41 PM
  • At present, using tlbimp, I have two dlls for each version, and I can add them both successfully as references. I got a class not registered further down the line for another COM component [DLL]. This was set to any CPU. The component got found when I changed it to X64. It seems to be working ok now ; I am testing

    However, I will definitely try out what you said [Unregister all versions and so on ]

    If the class not registered error for the previously unmentioned COM DLL component is the same error you mentioned earlier then it is a separate issue and you should start a new thread.  I assume you are not talking about the Interop DLLs.

    This thread has been about two out of process (exe) servers.  Talking about the class not registered error just confuses things in this thread.


    • Edited by RLWA32 Friday, May 24, 2019 12:49 PM
    Friday, May 24, 2019 12:48 PM