Tuesday 16 May 2017

How to access COM objects from NodeJS

How do I access COM objects from Node.

I have already tried an implementation using Edge and a simple DLL using C#. When I call the invoke function everything works as expected in the DLL, but the DLL cannot find the COM object specified. Yet, if I build a test program in the same VS Solution, and run it from there it works just fine.

So here is my code (that's the first actual use of the COM object in my code, before that is just types):

using QBXMLRP2Lib;
...
try { rp = new RequestProcessor2(); } catch (Exception e) { return e }

And it returns this error:

{ Error: Retrieving the COM class factory for component with CLSID {45F5708E-3B43-4FA8-BE7E-A5F1849214CB} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
    at Error (native)
  ErrorCode: -2147221164,
  Message: 'Retrieving the COM class factory for component with CLSID {45F5708E-3B43-4FA8-BE7E-A5F1849214CB} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).',
  Data: {},
  InnerException: null,
  TargetSite: {},
  StackTrace: 
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Startup.DoQBQuery(Object options) in c:\path\to\my\source\code\Startup.cs:line 35
  HelpLink: null,
  Source: 'mscorlib',
  HResult: -2147221164,
  message: 'Retrieving the COM class factory for component with CLSID {45F5708E-3B43-4FA8-BE7E-A5F1849214CB} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).',
  name: 'System.Runtime.InteropServices.COMException' }



via Arlen Beiler

No comments:

Post a Comment