microsoft/node-api-dotnet

Error: NoMetadataInPeImage

Closed this issue · 2 comments

I tried to extract types from the UnityPlayer.dll in the build output of a Unity sample project, but received a strange error.

Command executed:

npx node-api-dotnet-generator --assembly UnityPlayer.dll --typedefs ExampleAssembly.d.ts

Received error:

D:\unity-demo\My project\Build\node_modules\node-api-dotnet-generator\index.js:18
Generator.Program.Main(args);
                  ^

Error: NoMetadataInPeImage
    at System.Reflection.MetadataLoadContext.LoadFromStreamCore(Stream peStream)
    at System.Reflection.MetadataLoadContext.LoadFromAssemblyPath(String assemblyPath)
    at Microsoft.JavaScript.NodeApi.Generator.TypeDefinitionsGenerator.GenerateTypeDefinitions(String assemblyPath, IEnumerable`1 referenceAssemblyPaths, IEnumerable`1 systemReferenceAssemblyDirectories, String typeDefinitionsPath, IDictionary`2 modulePaths, Boolean isSystemAssembly, Boolean suppressWarnings)
    at Microsoft.JavaScript.NodeApi.Generator.Program.Main(String[] args)
    at Microsoft_JavaScript_NodeApi_Generator_Program_Main(Closure, JSCallbackArgs)
    at Microsoft.JavaScript.NodeApi.Interop.JSCallbackOverload.Invoke(JSCallbackOverload overload, JSCallbackArgs args)
    at Microsoft.JavaScript.NodeApi.Interop.JSCallbackOverload.ResolveAndInvokeDeferred(JSCallbackArgs args)
    at Microsoft.JavaScript.NodeApi.JSValue.InvokeCallback[TDescriptor](napi_env env, napi_callback_info callbackInfo, JSValueScopeType scopeType, Func`2 getCallbackDescriptor)
    at Object.<anonymous> (D:\unity-demo\My project\Build\node_modules\node-api-dotnet-generator\index.js:18:19)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47

My dotnet version: 8.0.302
Operating system: Windows 11

How was UnityPlayer.dll built? Are you sure it is a valid .NET assembly?

Closing due to lack of response. Feel free to re-open this issue if you are still experiencing the problem or have more information.