adammarks / netcoreproto

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

ManagedInteropApp - Cannot run as a .net core app #4

Closed adammarks closed 4 years ago

adammarks commented 4 years ago

I created a example of a Managed entry point C++/CLI Interop app with .net 4.7.2 , made sure that worked, then converted it to .NET Core 3

The app builds fine as Debug / x86 or Release / x86, but when I run, I get the following error message Snag_1e9a5b85

This doesn't make sense to me because I have that release installed, here's my .net core info

.NET Core SDK (reflecting any global.json):
 Version:   3.1.101-servicing-014750
 Commit:    458eb288fa

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.101-servicing-014750\

Host (useful for support):
  Version: 3.1.1-servicing.19575.1
  Commit:  f15b6f92ec

.NET Core SDKs installed:
  2.1.509 [C:\Program Files\dotnet\sdk]
  3.0.101 [C:\Program Files\dotnet\sdk]
  3.1.100 [C:\Program Files\dotnet\sdk]
  3.1.101-servicing-014750 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.1-servicing.19575.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.1-servicing.19575.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]    

This is the ManagedInteropApp.runtimeconfig.json 's contents

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

How strange. Two ideas:

adammarks commented 4 years ago

@mjrousos I do get farther with x64, I can run the app but then when I try to hit C++/CLI code I get the following https://www.screencast.com/t/QKdvqOE54wNj

adammarks commented 4 years ago

@mjrousos I did a dotnet new wpf and that works fine, but then when I change the Platform target to x86 I do get the same error https://www.screencast.com/t/9ncwPMmoR

mjrousos commented 4 years ago

Interesting. Sounds like there may be bitness issues. Can you make sure that you have an x86 version of the .NET SDK installed that corresponds with the version listed in the runtimeconfig.json file?

adammarks commented 4 years ago

@mjrousos I did get past this error for the x86 builds by installing the x86 version of .NET core also. Snag_1e9a5b85

But, I still get a BadFormatException when I try to load the C++/CLI assembly Snag_1d140ddb

adammarks commented 4 years ago

I wrote a separate bug for the BadFormatException https://github.com/adammarks/netcoreproto/issues/5