adammarks / netcoreproto

.NET Core C++/CLI Prototypes
0 stars 0 forks source link

NativeInteropApp crashes when running C++/CLI code #1

Closed adammarks closed 4 years ago

adammarks commented 4 years ago
  1. Build NativeInteropApp as Debug/x64
  2. Run
  3. Select Help-About

Access violation when running C++/CLI code https://www.screencast.com/t/v8Gz4hfl4YN

NOTE: I am also created a CPP_CLI_Interop.runtimeconfig.json file in the output directory that contains the following

{
    "runtimeOptions": {
      "tfm": "netcoreapp3.1",
      "framework": {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "3.1.0"
      }
    }
  }
mjrousos commented 4 years ago

How strange. I can't seem to repro this. When I use the exact same runtimeconfig.json, the app works for me!

All I can figure is maybe some .NET SDK component is out of date. Can you run dotnet --info and share the results? Also, if you can use a debugger like WinDbg to capture a stack trace of the failure, that will help.

adammarks commented 4 years ago

@mjrousos I kept looking at this and I noticed that I had a dependency problem similar to the other example where when I did a rebuild I was getting a linker error about a missing cpp_cli_interop.lib Once I added the output directory and setup a project reference to the cpp_cli_interop project the linker error went away and that also seemed to fix the error I was getting above, so it this project all works now.

Likely the dependency issue I was having was keeping a dll from being created and/or dropped into the right directory, which would cause the error above, but it seems to be working find now.