Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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:

  1. 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.
  2. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
478 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...