title: GetObject with edge.js
body: <p>I'm currently working to replace my ActiveX-Implementation in IE through a REST-API based on node.js with running edge.js</p>
  
  <p>So far the basic examples from the page implementing worked pretty well. I have my index.js set up to</p>
  
  <pre><code>var edge = require('edge');
  var edgeVb = require('edge-vb');
  var path = require('path');
  
  var helloVb = edge.func('vb', path.join(__dirname, 'simpleVbFunction.vb'));
  
  helloVb('Testing with String', (err, res) =&gt; {
      if(err) throw err;
      console.log(res);
  });
  </code></pre>
  
  <p>And the simpleVbFunction.vb as</p>
  
  <pre><code>Async Function(Input As Object) As Task(Of Object)
      Return Await Task.Run(Function()
          Return "NodeJS Welcomes: " &amp; Input.ToString()
      End Function)
  End Function
  </code></pre>
  
  <p>So far so good. Now i want to be able to access an application running on the machine running node.js. In this case Catia (could as well be Excel though)</p>
  
  <p>Usually for this I'd use a simpleVbFunction.vb like this</p>
  
  <pre><code>Async Function(Input As Object) As Task(Of Object)
      Return Await Task.Run(Function()
          Dim CATIA as Object
          set CATIA = GetObject(, "CATIA.Application")
          Return CATIA.ActiveDocument.Application.FullName
      End Function)
  End Function
  </code></pre>
  
  <p>However this does not work. I'm getting the following error.</p>
  
  <blockquote>
    <p>Error: Unable to compile VB code.
        ----> Errors when compiling as a CLR library:
        C:\Users\xxxxxx\AppData\Local\Temp\4hf2uw3z.0.vb(1,0) : error BC30203: Bezeichner erwartet.
        ----> Errors when compiling as a CLR async lambda expression:
        C:\Users\xxxxxx\AppData\Local\Temp\cypj4ltp.0.vb(7,0) : error BC30451: "GetObject" ist nicht deklariert. Auf das Objekt kann
    aufgrund der Schutzstufe möglicherweise nicht zugegriffen werden.
        at Error (native)
        at Object.exports.func (C:\Users\xxxxxx\coding\node\tst_win32ole\node_modules\edge\lib\edge.js:169:17)
        at Object. (C:\Users\xxxxxx\coding\node\tst_win32ole\index.js:6:20)
        at Module._compile (module.js:570:32)
        at Object.Module._extensions..js (module.js:579:10)
        at Module.load (module.js:487:32)
        at tryModuleLoad (module.js:446:12)
        at Function.Module._load (module.js:438:3)
        at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
        at ontimeout (timers.js:386:14)</p>
  </blockquote>
  
  <p>Now I have to admin my VB.NET skills are a little bit rusty and this might just be an error in my VB-Code but I think it's something else. Has anyone of you been able to access a COM-Object via edge.js and if yes how was this possible?</p>
  
  <p>[edit]
  OK. I came a little further by switching to C# from VB (At least the code commented out to access the name of the Excel Application works). But this opened another problem. My code here looks like this</p>
  
  <pre><code>using System.Threading.Tasks;
  using System;
  using System.Runtime.InteropServices;
  // using INFITF;
  
     public class Startup
     {
         public async Task&lt;object&gt; Invoke(object input)
         {
              // dynamic xl = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application"));
              // return xl.Name;
             object CATIA0 = Marshal.GetActiveObject("CATIA.Application");
             INFITF.Application CATIA = CATIA0 as INFITF.Application;
         }
     }    
  </code></pre>
  
  <p>Now the problem is, that when working with Visual Studio and compiling the dlls get included automatically (when setting CATIA as INFITF.Application). But with edge.js I'd get the error that the namespace INFITF could not be found. Any ideas how to get that working?</p>
  
  <p>Sorry for the long question. I'll tidy this up after this is solved.</p>
  
  <p>[/edit]</p>