I am having trouble getting a .NET 5 (C#) console application that references a .NET 5 C++/CLI assembly to work when embedded in the EXE.
Here it what I have done:
- Using the Wizard create a .NET 5.0 C++/CLI assembly and a .NET 5.0 test application in C# that references it. It builds and runs fine in debug/release.
- Now using 'Publish' create a single EXE. I used the options: Framework-dependent, target runtime: win-x64, and 'produce single file'.
This creates a result, but when I run it I get the following:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
at <Module>.__security_init_cookie()
--------------------------------
at <Module>.<CrtImplementationDetails>.LanguageSupport.InitializeNative(<CrtImplementationDetails>.LanguageSupport*)
at <Module>.<CrtImplementationDetails>.LanguageSupport._Initialize(<CrtImplementationDetails>.LanguageSupport*)
at <Module>.<CrtImplementationDetails>.LanguageSupport.Initialize(<CrtImplementationDetails>.LanguageSupport*)
at <Module>..cctor()
at ConsumeThisOne.Program.Main(System.String[])
The C++/CLI method I am calling is trivial, it is a static method that just writes a string to the console.
Can anyone else get this to work? Thanks in advance.