electron-edge icon indicating copy to clipboard operation
electron-edge copied to clipboard

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))

Open Umplify opened this issue 8 years ago • 4 comments

I admit that this issue may sound a duplicate of issue #496, but I cannot overcome the problem. I guess either a point is missing in the documentation of edge / electron-edge or something is not clear to me.

I create a super simple C# library in .Net Core 1.1 with .Net Standard 1.6. I finished dotnet restore, dotnet build and dotnet release etc. .... per the documentation successfully. Things went on well and I moved all DLLs, json files, etc. from the publish folder to a folder called "dll" within the folder where node runs. So, it looks like this: C:\electron-quick-start\dll

var clrMethod = edge.func({
    assemblyFile: 'dll\\MyLibrary.dll',
    typeName: 'MyLibrary.Startup',
    methodName: 'Invoke'
});

clrMethod('This text comes from JavaScript!', function (error, result) {
    if (error) throw error;
    console.log(result);
});

When I run the js file, I receive the error message mentioned in the subject line. Then I set the following environment variables:

EDGE_USE_CORECLR=1
EDGE_APP_ROOT = C:\electron-quick-start\dll

But I received this error message / exception:

TypeError: edge.initializeClrFunc is not a function

Even I tried to put all contents of "dll" folder side by side where node is running and that resulted into no success. Also, I set app root to the exact publish folder generated by dotnet release and that was not conclusive either.

What is missing in this exercise or may have been done wrong?!

As a side note: I am using the recent version of electron-edge.

Umplify avatar Jan 26 '17 20:01 Umplify

I also have this problem, did anyone find a solution?

mhgamework avatar Mar 13 '17 11:03 mhgamework

Same problem. The problem still happening in most simple in line app. Anyone can help, please?

fgodoy avatar Apr 12 '17 21:04 fgodoy

I gave up trying to use electron-edge as having these kind of problems already when starting out is a big forebode for problems to come when it is actually being used. Combined with the fact that electron-edge does not really a have a proper way to communicate between node and C# on a architectural level, I would suggest to reconsider using electron-edge. You need to manually make almost untyped electron-edge specific wrappers for all you communication.

If we have to write the communication interface ourselves, we might aswel use something like websockets or plain tcp/ip to do the communication. I do not know what the exact performance difference will be but i am not even sure if electron-edge will be faster, because alot will depend on how you do the marshalling.

If you really, really need very high performance its probably better to just create a C++ binding for node, you can probably use C++/CLI bindings to directly communicate with C# managed code. This will give you the same benefits as electron-edge, but you dont need the additional dependency and you have control over what is happening.

mhgamework avatar Apr 13 '17 19:04 mhgamework

Using coreclr rather than using a dll according to here: https://github.com/tjanczuk/edge/issues/463 we need to create a nuget package for our pre-compiled netcore code and add a deps.json at the app root referencing out package and edge.js. After following those instructions though I still get the

TypeError: edge.initializeClrFunc is not a function

But the missing System.Runtime is resolved.

Syrus666 avatar Apr 21 '17 02:04 Syrus666