-
Notifications
You must be signed in to change notification settings - Fork 640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Referencing a nuget package in dotnetcore #463
Comments
What's the actual command line that you're using to invoke your application? Are you using EDGE_USE_CORECLR=1 and EDGE_APP_ROOT=/path/to/dir/containing/depsjson as environment variables when doing so? Can you include the Node.js code where you use edge.func() to load the function? |
I am not using those env vars. For sure I am doing something wrong, but I could not find any small sample to follow. |
Hi @lstratman sorry for the delay.
Questions:
If only there was a single simple example with the steps to follow, everything would not be so frustrating... |
The documentation definitely needs some work and will be improved. If you have a pre-existing .NET Core library that you want to make use of through node, you'll need to do the following:
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Edge.js": "6.5.0",
"Your.NuGet.Library": "1.2.3"
}
}
I hope this helps. Again, we will be improving the documentation so that this is easier to pick up going forward, but this should get you started. |
Great explanation, thank you @lstratman |
Hi @lstratman I still can't make it work. When I run the node app (the plain hello world) the result is:
The env vars of the cmd are:
and the deps.json is there:
This is the bridge\project.json:
And this is the app:
|
Raf, the problem is that you have the EDGE_NATIVE environment variable set explicitly and you have it pointing to the non-.NET core Node.js native extension for Edge. This causes Edge to use the desktop CLR instead of .NET Core. Once you take out that environment variable, Edge will then load the proper native extension based on the EDGE_USE_CORECLR environment variable and you should be good to go. From: Raf Sent: Saturday, September 17, 6:05 AM Subject: Re: [tjanczuk/edge] Referencing a nuget package in dotnetcore (#463) To: tjanczuk/edge Cc: Luke Stratman, Mention Hi @lstratman I still can't make it work. I've done all the described steps ... dotnet restore, build and all the rest with no errors. It is still looking for the file on the current folder instead of the package referenced by the 'bridge' app. Using Process Monitor I can see the failed attempt to open "H:\dev.node\HelloEdge\NetCoreLibrary" When I run the node app (the plain hello world) the result is: H:\dev.node\HelloEdge>node Edge3.js Load edge native library from: H:\Samples\NodeEdge2\edge\lib The env vars of the cmd are: H:\dev.node\HelloEdge>set | find "EDGE" EDGE_APP_ROOT=H:\dev.node\HelloEdge\bridge\bin\Debug and the deps.json is there: Directory of H:\dev.node\HelloEdge\bridge\bin\Debug This is the bridge\project.json: { "version": "1.0.0-*", "buildOptions": { "debugType": "portable", "emitEntryPoint": true }, "dependencies": {}, "frameworks": { "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0" }, "Edge.js": "6.5.0", "NetCoreLibrary": "1.0.0" }, "imports": "dnxcore50" } } } And this is the app: var edge = require('edge'); var helloWorld = edge.func({ assemblyFile: 'NetCoreLibrary', typeName: 'NetCoreLibrary.NetDemo', methodName: 'Greet' }); helloWorld('JavaScript', function (error, result) { if (error) throw error; console.log(result); }); — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread. |
Thank you again @lstratman But out of my curiosity, how can I use netcore when I have to rebuild edge locally? It may happen in the future whenever I need to use edge with a node release that is not supported yet ... |
If you need to use EDGE_NATIVE with .NET Core, just make sure that the path On Sat, Sep 17, 2016 at 11:02 AM, Raf notifications@github.com wrote:
|
@lstratman yes, it finally worked, thank you very much. I believe all these "details" are worth the docs with some deep-dive for people willing to experiment. |
I followed the readme.md instructions and wrote the nuget package name in the "assemblyFile" field.
When I run the node app, I get the following error:
Error: Could not load file or assembly 'file:///H:\DemoNode\ExpressApp1\Plugin2\NetCoreLibrary' or one of its dependencies. The system cannot find the file specified.
If instead I reference the dll directly, I get this other error:
Error: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))
Hints? Pointers?
P.S. If the dll is compiled in net46 everything works fine. I am testing on Windows.
Thank you
The text was updated successfully, but these errors were encountered: