error : Failed to load managed host assembly. In type generator 0.7.26+
camnewnham opened this issue · 1 comments
camnewnham commented
With version 0.7.19 this generates successfully for me (net4.8 and net7.0 as targetframework)
npx -y node-api-dotnet-generator@0.7.19 --nowarn --assembly <myAssembly> --typedefs <myAssembly.d.ts> --reference <assemblies> --module esm --framework <targetframework>
However with 0.7.26 and newer I get the exception:
15:11:52:169 1> Node.js v22.5.1
15:11:52:169 1> C:\Users\me\AppData\Local\npm-cache\_npx\e86bb904f8594fd8\node_modules\node-api-dotnet\init.js:78
15:11:52:169 1> dotnet = nativeHost.initialize(targetFramework, managedHostPath, require, importModule);
15:11:52:199 1> ^
15:11:52:199 1>
15:11:52:199 1> EXEC : error : Failed to load managed host assembly. HRESULT: 0x80070002
15:11:52:199 1> at initialize (C:\Users\me\AppData\Local\npm-cache\_npx\e86bb904f8594fd8\node_modules\node-api-dotnet\init.js:78:23)
15:11:52:199 1> at Object.<anonymous> (C:\Users\me\AppData\Local\npm-cache\_npx\e86bb904f8594fd8\node_modules\node-api-dotnet\index.js:2:18)
15:11:52:199 1> at Module._compile (node:internal/modules/cjs/loader:1504:14)
15:11:52:199 1> at Module._extensions..js (node:internal/modules/cjs/loader:1588:10)
15:11:52:199 1> at Module.load (node:internal/modules/cjs/loader:1282:32)
15:11:52:199 1> at Module._load (node:internal/modules/cjs/loader:1098:12)
15:11:52:199 1> at TracingChannel.traceSync (node:diagnostics_channel:315:14)
15:11:52:199 1> at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)
15:11:52:199 1> at Module.require (node:internal/modules/cjs/loader:1304:12)
15:11:52:199 1> at require (node:internal/modules/helpers:123:16)
camnewnham commented
Note, this only occurred when running via NPX. The latest generator works fine when invoked via msbuild so I am now doing that instead.