'Unable to compile C# code in Edge-js package npm

I met a problem like this below when I try to run 'yarn start' on my server like this:

return edge.initializeClrFunc(options);
                ^
Error: Unable to compile C# code.
----> Errors when compiling as a CLR library:
c:\Users\...\AppData\Local\Temp\nwoav5c3.0.cs(36,31) : warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
error CS0583: Internal Compiler Error (0xc0000005 at address 00007FF7506EBC91): likely culprit is 'CODEGEN'.
c:\Users\...\AppData\Local\Temp\nwoav5c3.0.cs(100,13) : error CS0585: Internal Compiler Error: stage 'CODEGEN'
c:\Users\...\AppData\Local\Temp\nwoav5c3.0.cs(91,32) : error CS0584: Internal Compiler Error: stage 'CODEGEN' symbol 'Startup.word(dynamic)'
c:\Users\...\AppData\Local\Temp\nwoav5c3.0.cs(91,32) : error CS0584: Internal Compiler Error: stage 'BIND' symbol 'Startup.word(dynamic)'
c:\Users\...\AppData\Local\Temp\nwoav5c3.0.cs(91,32) : error CS0584: Internal Compiler Error: stage 'COMPILE' symbol 'Startup.word(dynamic)'
c:\Users\...\AppData\Local\Temp\nwoav5c3.0.cs(91,32) : error CS0584: Internal Compiler Error: stage 'COMPILE' symbol 'Startup.word(dynamic)'
c:\Users\...\AppData\Local\Temp\nwoav5c3.0.cs(91,32) : error CS0584: Internal Compiler Error: stage 'COMPILE' symbol 'Startup.word(dynamic)'
c:\Users\...\AppData\Local\Temp\nwoav5c3.0.cs(17,14) : error CS0584: Internal Compiler Error: stage 'COMPILE' symbol 'Startup'
error CS0584: Internal Compiler Error: stage 'COMPILE' symbol '<global namespace>'
error CS0586: Internal Compiler Error: stage 'COMPILE'
error CS0587: Internal Compiler Error: stage 'COMPILE'
error CS0587: Internal Compiler Error: stage 'EMIT'
error CS0587: Internal Compiler Error: stage 'BEGIN'
----> Errors when compiling as a CLR async lambda expression:
c:\Users\duypn\AppData\Local\Temp\24phnmts.0.cs(18,56) : error CS1513: } expected
c:\Users\duypn\AppData\Local\Temp\24phnmts.0.cs(351,9) : error CS1519: Invalid token 'return' in class, struct, or interface member declaration
c:\Users\duypn\AppData\Local\Temp\24phnmts.0.cs(351,35) : error CS1001: Identifier expected
c:\Users\duypn\AppData\Local\Temp\24phnmts.0.cs(353,1) : error CS1022: Type or namespace definition, or end-of-file expected
c:\Users\duypn\AppData\Local\Temp\24phnmts.0.cs(21,14) : error CS0542: 'Startup': member names cannot be the same as their enclosing type
    at Object.exports.func (D:\Bagang\api\bgt-export-service\bgt-export-service\node_modules\edge-js\lib\edge.js:177:17)
    at Object.<anonymous> (D:\Bagang\api\bgt-export-service\bgt-export-service\node_modules\node-msoffice-pdf-js\lib.js:4:23)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (D:\Bagang\api\bgt-export-service\bgt-export-service\controllers\pdfServices.controller.js:8:14)
    "c:\\Users\\duypn\\AppData\\Local\\Temp\\24phnmts.0.cs(21,14) : error CS0542: 'Startup': member names cannot be the same as their enclosing type",
  Data: {},
  InnerException: null,  TargetSite: {},
  StackTrace: '   at EdgeCompiler.CompileFunc(IDictionary`2 parameters)',
  HelpLink: null,
  Source: 'edge-cs',
  HResult: -2146233079,
  name: 'System.InvalidOperationException'
}

I think the problem comes from lib "Edge-js" - miss the compiler, then I have installed all the .Net from here: https://dotnet.microsoft.com/en-us/download/dotnet/6.0/runtime. But after all it still not working... My server language is Javascript,nodejs v16.15.0, and my dotnet version 6.0.202. I hope somebody can help me to resolve this problem cus it takes me 2 days for fixing it. Finally, thanks for reading until here!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source