question

HarikrishnanVR-4367 avatar image
0 Votes"
HarikrishnanVR-4367 asked YanGu-MSFT commented

How can we test the c++/WinRT library using a c++ console application

Im writing a C++/WinRT library now and I'd like to test the API in a C++ console.

Any way to do this?

windows-uwpc++
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YanGu-MSFT avatar image
0 Votes"
YanGu-MSFT answered YanGu-MSFT commented

Hello,

Welcome to Microsoft Q&A.

It is not supported to test a C++/WinRT library(whichever the project is a C++ DLL(Universal Windows) project or a C++ Static Library(Universal Windows) project) in a C++ console application. The compiler will tell you that a reference to your library cannot be added to a console application because the two projects target different platforms.

We suggest you use a UWP app to test your winrt library. You could refer to the document to learn how to add a reference to your c++/winrt library project from a UWP app(including Blank App(C++/WinRT) project and Core App(C++/WinRT) project).


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

so i can use the c++/winrt console project for testing,right? There it is possible to add the reference.

0 Votes 0 ·
YanGu-MSFT avatar image YanGu-MSFT HarikrishnanVR-4367 ·

@HarikrishnanVR-4367 A C++/WinRT console project is not a UWP app. If you try to add a reference in a C++/WinRT Console project, you will get the same error as the c++ console application.

0 Votes 0 ·