microsoft / Windows-Dev-Performance

A repo for developers on Windows to file issues that impede their productivity, efficiency, and efficacy
MIT License
438 stars 21 forks source link

Consuming a C# component in a C++ app crashes at runtime #53

Closed JaiganeshKumaran closed 3 years ago

JaiganeshKumaran commented 3 years ago

If you create a C# component and use it from C++, it will crash at runtime on 1709+. FUSION_E_REF_DEF_MISMATCH 0x80131040 The located assembly's manifest definition does not match the assembly reference

JaiganeshKumaran commented 3 years ago

Please fix this, workarounds are hard and not ideal

orcmid commented 3 years ago

@Jaiganeshkumaran Are you saying the error message is incorrect?

Or is the "workaround" what it takes to have the C++ reference be compatible?

JaiganeshKumaran commented 3 years ago

@orcmid Earlier you can create a C# managed Windows Runtime component and directly reference it from C++ and it will work but now it crashes due to some .NET Core version issue. Some workarounds like modifying the project file for C++ can work sometimes but it's not ideal.

bitcrazed commented 3 years ago

@Jaiganeshkumaran. Could you please provide more info? Do you have a repro case you can share? Which versions of C++ and .NET? Etc.

asklar commented 3 years ago

@Jaiganeshkumaran I've written about this: https://github.com/asklar/WinRTComponent/blob/master/README.md See also Raymond's post: https://devblogs.microsoft.com/oldnewthing/20200615-00/?p=103868/

JaiganeshKumaran commented 3 years ago

@asklar I can't do this workaround every time I create a new project also I'm not that familiar with these project files and it's not a good experience. The SDK should ship proper templates in my opinion that doesn't require workarounds.

asklar commented 3 years ago

Agree that it's not a good experience. This isn't a Windows SDK issue though but a .net native issue, so I suggest you should file a bug against visual studio in the developer community site about it (In VS, go to Help, send feedback)

AvriMSFT commented 3 years ago

This issue is out of scope for this repository. Per @asklar's response, please file the bug against VS!