agracio / edge-js

Run .NET and Node.js code in-process on Windows, macOS, and Linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to resolve reference to System.

cosminonea opened this issue · comments

I am trying to run samples/203_x509store.js on an M3 Mac but I get the following error: Error: Unable to resolve reference to System.

I get a similar error with any other dll I try to reference.

Are the samples supposed to run on all platforms?

/oss/edge-js/lib/edge.js:178
    return edge.initializeClrFunc(options);
                ^
Error: Unable to resolve reference to System.
    at exports.func (/oss/edge-js/lib/edge.js:178:17)
    at Object.<anonymous> (/oss/edge-js/samples/203_x509store.js:5:29)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  TargetSite: {
    Name: '',
    DeclaringType: '',
    ReflectedType: '',
    MemberType: '',
    MetadataToken: '',
    Module: '',
    IsSecurityCritical: '',
    IsSecuritySafeCritical: '',
    IsSecurityTransparent: '',
    MethodHandle: '',
    Attributes: '',
    CallingConvention: '',
    ReturnType: '',
    ReturnTypeCustomAttributes: '',
    ReturnParameter: '',
    IsCollectible: '',
    IsGenericMethod: '',
    IsGenericMethodDefinition: '',
    ContainsGenericParameters: '',
    MethodImplementationFlags: '',
    IsAbstract: '',
    IsConstructor: '',
    IsFinal: '',
    IsHideBySig: '',
    IsSpecialName: '',
    IsStatic: '',
    IsVirtual: '',
    IsAssembly: '',
    IsFamily: '',
    IsFamilyAndAssembly: '',
    IsFamilyOrAssembly: '',
    IsPrivate: '',
    IsPublic: '',
    IsConstructedGenericMethod: '',
    CustomAttributes: ''
  },
  Message: 'Unable to resolve reference to System.',
  Data: {},
  InnerException: null,
  HelpLink: null,
  Source: 'edge-cs-coreclr',
  HResult: -2146233088,
  StackTrace: '   at EdgeCompiler.TryCompile(String source, List`1 references, IDictionary`2 compileAssemblies, String& errors, Assembly& assembly)\n' +
    '   at EdgeCompiler.CompileFunc(IDictionary`2 parameters, IDictionary`2 compileAssemblies)\n' +
    '   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)\n' +
    '   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)',
  Name: 'System.Exception',
  name: 'System.Exception'
}

Node.js v20.10.0

Process finished with exit code 1

Hi, I have not looked at samples in many years so perhaps they are outdated. If you are testing it on MacOs make sure you have EDGE_USE_CORECLR = 1 env variable set before running samples and have dotnet 6 or higher installed. Your command line should be EDGE_USE_CORECLR=1 node samples/203_x509store.js.
Having said that I can see that at least the sample you mentioned does not work in .NET Core so will take a look at that. I think you are the first person to mention samples since I have been working on this project 😄

But if you want to test your code, reference dlls etc I suggest looking at https://github.com/agracio/edge-js-quick-start. It works on Windows/Linux/MacOs with both Intel add M chips.

Added listCertificates method to https://github.com/agracio/edge-js-quick-start.