How can a C++/CLI project reference a portable class library?
Asked Answered
K

1

7

We've got a bunch of C# code that references Prism.Core. Prism.Core is a portable class library. When we reference this in C++/CLI and try to use a delegate command, we get:

C4691: 'System::Object': type referenced was expected in unreferenced assembly 'System.Runtime', type defined in current translation unit used instead

Can anyone explain why? And is there any way to fix, other than rebuilding the source, which I didn't want to do as Prism is Nugeted into our c# source?

Klaraklarika answered 22/3, 2016 at 16:49 Comment(0)
C
0

I had a similar setup with the same warning. The C# project referenced a NuGet package with multiple target frameworks. Since managed NuGet packages cannot be added to C++/CLI projects, a reference had to be manually added for that project. The manually-added reference ended up being to a DLL for a different target framework in the NuGet package. Something like:

CSharpProject.csproj -> packages\Prism.Core.6.2.0\lib\portable-win+net45+wp80+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Prism.dll
CppCliProject.vcxproj -> packages\Prism.Core.6.2.0\lib\net45\Prism.dll

Changing the reference in the C++/CLI project to use the same DLL as the C# project fixed it in my case.

Cesaro answered 6/10, 2016 at 23:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.