Skip to content
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

TypeError: edge.initializeClrFunc is not a function && CoreClrEmbedding::Initialize - Failed to initialize CoreCLR, HRESULT: 0x80070057 #238

Open
kskmeste opened this issue Dec 21, 2024 · 15 comments

Comments

@kskmeste
Copy link

Hello,

first sry for my english and I'm a beginner in the linux world und nodejs but I am developer in .NET.
I've the problem that i cant call a c# method in a .net dll with edge-js and i dont know how to fix this error.

This is the output after starting "pm2 log":
0|Example | CoreClrEmbedding::Initialize - Failed to initialize CoreCLR, HRESULT: 0x80070057 0|Example | TypeError: edge.initializeClrFunc is not a function 0|Example | at exports.func (/var/www/MySite/server/node_modules/edge-js/lib/edge.js:174:17) 0|Example | at Object.<anonymous> (/var/www/MySite/server/Example.js:4:30) 0|Example | at Module._compile (node:internal/modules/cjs/loader:1364:14) 0|Example | at Module._extensions..js (node:internal/modules/cjs/loader:1422:10) 0|Example | at Module.load (node:internal/modules/cjs/loader:1203:32) 0|Example | at Module._load (node:internal/modules/cjs/loader:1019:12) 0|Example | at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) 0|Example | at Module._compile (node:internal/modules/cjs/loader:1364:14) 0|Example | at Module._extensions..js (node:internal/modules/cjs/loader:1422:10) 0|Example | at Module.load (node:internal/modules/cjs/loader:1203:32) PM2 | App [Example:0] exited with code [1] via signal [SIGINT] PM2 | App [Example:0] starting in -fork mode- PM2 | App [Example:0] online

I've installed

  • dotnet 6.0
  • nodejs 18.20.5
  • edge 7.10.1

I've uninstall and install more times the 3 apps with diefferent versions/packages.
I've also reinstalled debian 12 because i tought that i do a mistake.
ChatGTP show me always the same solution and cant help at this point.

My goal is to call methods from a dll in nodejs with edge.
I would be very grateful for any help and support as I have not known what else to do for a week now.

Thanks and best regards
m.e.s.t.e

@agracio
Copy link
Owner

agracio commented Dec 21, 2024

edge NPM module is no longer supported, use edge-js. If the problem persists try creating a GitHub repo to reproduce.

My goal is to call methods from a dll in nodejs with edge.
I would be very grateful for any help and support as I have not known what else to do for a week now.

Take a look at https://github.com/agracio/edge-js-quick-start it has plenty of examples.
quick-start uses .NET Core dlls but same would be applicable to .NET Framework

@kskmeste
Copy link
Author

kskmeste commented Dec 26, 2024

Good morning!

At first I wish all a merry xmas.

An sry for my late.
About the link wich you post.
I've already doing that

This is the one baackend file
`import edge from 'edge-js';

var helloWorld = edge.func(function () {/*
async (input) => {
return ".NET Welcomes " + input.ToString();
}
*/});

helloWorld('JavaScript', function (error, result) {
if (error) throw error;
console.log(result);
});`

and here is another file with this content
`process.env.EDGE_USE_CORECLR=1
const edge = require('edge-js');

const getMessageAsync = edge.func({
assemblyFile: '/var/www/html/dll/Example.dll',
typeName: 'MyNamespace.MyClass',
methodName: 'GetMessageAsync'
});

getMessageAsync(null, function (error, result) {
if (error) throw error;
console.log(result); // "Hello from .NET after delay!"
});`

For both files i got the same error like this
[ 5|Example | CoreClrEmbedding::Initialize - Failed to initialize CoreCLR, HRESULT: 0x80070057 5|Example | TypeError: edge.initializeClrFunc is not a function 5|Example | at exports.func (/var/www/html/server/node_modules/edge-js/lib/edge.js:174:17) 5|Example | at file:///var/www/html/server/Example.js:4:30 5|Example | at ModuleJob.run (node:internal/modules/esm/module_job:195:25) 5|Example | at async ModuleLoader.import (node:internal/modules/esm/loader:337:24) 5|Example | at async importModuleDynamicallyWrapper (node:internal/vm/module:432:15) ]

I've created a console app on .NET and thats work fine with nodejs and without edge-js but the performance is not so good.
This dll can be called in production 5-10 times per sec.

Thanks and best regards
m.e.s.t.e

@agracio
Copy link
Owner

agracio commented Dec 26, 2024

Can you create a GitHub repo that reproduces the error?

@kskmeste
Copy link
Author

kskmeste commented Jan 2, 2025

Hello,

here is a test project.
https://github.com/kskmeste/EdgeSample.git

I put also the csharp file to se how the methods declared.

thx in advance and best regards

@agracio
Copy link
Owner

agracio commented Jan 2, 2025

Example uses edge package as I said previously it needs to use edge-js

@kskmeste
Copy link
Author

kskmeste commented Jan 2, 2025

In this solution i tried with edge instead of edge-js.
All my tests and the error msg was with edge-js.

@agracio
Copy link
Owner

agracio commented Jan 2, 2025

I do not have a functioning Linux VM right now but have you tried running https://github.com/agracio/edge-js-quick-start? Take a look to see if it runs on your system.

There are many inconsistencies in your code for example calling Method1 which does not have a supported signature only Method3 has supported code.
Path to dll is not correct but that would have resulted in different error.

Try enabling EDGE_DEBUG=1 env variable in terminal to see if there is any meaningful debug output.

In server.js you have not set process.env.EDGE_USE_CORECLR=1

And as per my previous comment edge module will not work only edge-js will work.

@kskmeste
Copy link
Author

kskmeste commented Jan 3, 2025

Hello,

I've created more methods with diffenrent signature because i was not sure wich signature supports edge-js.
As i said i tried the last weeks only with edge-js, just the git project i use edge because i saw another solution in internet and want to try that before uploading to git.
All my previous tries and the error msg was with edge-js.
And yes, i've compiled on linux after installibg .NET 6 and 8 and the result (Message) was the same.

If you say the "Method3" have the right signature then i will try the next test with this.

thx and best regards

@agracio
Copy link
Owner

agracio commented Jan 3, 2025

Have you tried running https://github.com/agracio/edge-js-quick-start on your machine?

@kskmeste
Copy link
Author

kskmeste commented Jan 12, 2025

Hallo,

I've tried yesterday again on a clean image but failed again.
After installing and setup edge-js i get always this message

TypeError: edge.initializeClrFunc is not a function
at exports.func (/var/www/test/server/node_modules/edge-js/lib/edge.js:174:17)
at Object.<anonymous> (/var/www/test/server/server.js:4:23)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49

Node.js v18.20.5

and im using this basic function

process.env.EDGE_USE_CORECLR=1
var edge = require('edge-js');

var helloWorld = edge.func(function () {/*
    async (input) => {
        return ".NET Welcomes " + input.ToString();
    }
*/});

helloWorld('JavaScript', function (error, result) {
    if (error) throw error;
    console.log(result);
});

If i tried with docker then i get this warning:
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

So do edge-js supports arm64 (raspberry pi4)?

@agracio
Copy link
Owner

agracio commented Jan 13, 2025

Edge.js supports ARM in main Linux distros on PC and maybe other devices but don't think it will work on Raspberry Pi.
Try setting export EDGE_DEBUG=1 in terminal to see detailed output and figure out errors.

@kskmeste
Copy link
Author

I've removed edge-js and solved it with gRPC combined with dotnet. It tooks to long for a simple call.
if you ever trying to test edge-js on an arm64 or if you can reproduce the same error then I would be very grateful if you would inform me about it

Thx and best regards

@agracio
Copy link
Owner

agracio commented Jan 14, 2025

edge-js does work on arm64 both on Linux and macOS, but devices like Raspberry Pie are not always supported.
https://app.circleci.com/pipelines/github/agracio/edge-js/407/workflows/cc1b67eb-7168-450f-ab36-6244845623e6.

Did you try running https://github.com/agracio/edge-js-quick-start or enabling debug to diagnose the problem?

@agracio
Copy link
Owner

agracio commented Jan 18, 2025

I am curious to see debug output that might pinpoint to the underlying issue.

@kskmeste
Copy link
Author

Hello,

Thank you for your response.

I'm writing to inform you that I'm currently behind schedule on the project, as I've spent more time than anticipated implementing edge-js.
This is largely attributable to my current knowledge gap with Node.js and edge-js.
Consequently, I'm unable to dedicate further time to this at the moment.
However, I plan to revisit this in the coming weeks and will thoroughly re-evaluate all approaches, documenting the process as I go.

Thank you again for your contribution and prompt responses.

Best Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants