node-clr
node-clr copied to clipboard
Produce the equivalent of adding a reference
Some things require that you add a reference to a namespace in Visual Studio. What exactly is that reference internally and how do I produce the equivalent of it here using clr?
The following shows a dialogue.
using Microsoft.VisualBasic;
Microsoft.VisualBasic.Interaction.InputBox("Question?","Title","Default Text");
Without reference: CS0234: The type or namespace does not exist in the namespace 'Microsoft.VisualBasic' . Are you missing an assembly reference?
require('clr').init({ assemblies: [ 'Microsoft.VisualBasic' ] })
Microsoft.VisualBasic.Interaction.InputBox("Question?","Title","Default Text")
TypeError: Cannot read property 'InputBox' of undefined
Can you try Microsoft.VisualBasic.InputBox
instead of Microsoft.VisualBasic.Interaction.InputBox
?
It seems that the namespace is changed on .NET 4.0, but clr
uses .NET 3.5.
https://msdn.microsoft.com/ja-jp/library/microsoft.visualbasic.interaction.inputbox(v=vs.90).aspx
I have questions for you.
- Do you have any real-world usecase of this library?
- Why do you prefer this over edge.js, for nodejs/.net interop?
I tried what you suggested and Microsoft.VisualBasic.InputBox
is also undefined
. It requires a reference either way. This is not the only library in the world that requires a reference so also for in the future I would like to learn exactly what this reference in reality means internally to hopefully produce an equivalent here.
I prefer this any day because Edge lets you type a C# lambda function wrapped in a comment block inside a JavaScript method (?!) and your clr neatly exposes everything to the JavaScript context, allowing me to debug and inspect entire namespaces in the developer tools of Google Chrome, iterate namespaces and very easily load additional assemblies programmatically.
var clr = require("clr");
clr.init({ assemblies: ["Microsoft.VisualBasic"]});
Microsoft.VisualBasic.Interaction.InputBox("Question?", "Title", "Default Text", 0, 0);
I tried and it seems to be working. With node.js 7.10.1.