Including PCL DLL in C ++ winrt project

I have created a portable class library that I want to use in various WinRT projects. I can use this PCL DLL in C # Winrt Apps, VB WinRT Apps, Silverlight and Windows Phone. But for some reason I cannot successfully add the library to my C ++ project. The error I get when I try to do this:

Could not add a link to file 'C: \ Users \ xyz \ pqr.dll' because it is neither a .NET assembly nor a registered ActiveX control.

I saw the same question on SO earlier and the OP posted a solution that seems to work for him. I tried to search for the following line as my original question, but cannot find it in the vcxproj file.

<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>

      

Since I can't post a comment on the original question, I figured I should post another question.

Any ideas?

Edit: My project setup looks something like this:

  • Let's assume my PCL library is called A.dll.
  • My WinRT component is called B.winmd.
  • B.winmd now uses A.dll internally and creates a wrapper around it.

Now when I want to create Store C in C ++ I need to add references to A.dll and B.winmd in my C project. If I just include B.winmd I get a runtime exception of the first time used from A. dll. What am I doing wrong?

+3


source to share


2 answers


C ++ app doesn't know how to execute managed code. If you want to build a library using C # and make it available to another runtime like C ++ or Javascript, you need to create a Windows Runtime Component project. Its public interface is limited to WinRT-compatible types to allow interoperability between runtimes. Lots of other little rules.



The MSDN start page is here .

+2


source


Your post should be good advice - the PCL library is a .NET library. WinRT projects require WinRT components. You need to create a .NET-based WinRT component that will wrap your PCL to make it usable in non-.NET languages.



0


source







All Articles