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?

Jacob
  • 77,566
  • 24
  • 149
  • 228
intinit
  • 480
  • 4
  • 14

1 Answers1

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.

Chris
  • 533
  • 12
  • 19