简体   繁体   中英

Consuming a DLL(Universal Apps) from a WinRT Component

I have a C++ (Native code) DLL project developed for iOS and Android. I would like to port it to a C++ DLL (Universal Apps) to be consumed by a C# Universal Store Application. The code isn't HW dependent.

As a first step, before moving all the code, I created a small test solution as follows:

  1. I created a C++ DLL (Universal Apps), myDll, that has a C++ Add1(int, int) function.
  2. I created a C++ WinRT component (Universal Apps) that has C++ Add2(int, int) function.
  3. I created a C# Universal Application, myApp, that calls Add2 which calls Add1 .

Compilation passes OK, however when I run myApp the application crashes and report that myDll wasn't loaded.

My questions are:

  1. Is the scenario I described above possible? And If so, what can be the problem causing myApp to crash?
  2. Is there a better way for me to port the iOS/Android C++ code to be consumed in a C# Universal Application?

Thx

1) Like Hans, my first guess is that you're not including the Dll in the apps package. If it's not deployed in the package it isn't available to be loaded. Since you can't add a reference to the DLL you'll need to add it explicitly:

Add the files to the project, open the files' properties in the Solution Explorer window, and mark them as content to be included in the app package.

Check that out is actually in the appx dir after you deploy.

2) That's probably the easiest. You could also include just the Dll and pinvoke. Either way you'll need to make sure the dll is valid for Windows Store apps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM