1

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

chue x
  • 18,573
  • 7
  • 56
  • 70
eitan barazani
  • 1,123
  • 3
  • 18
  • 34
  • 1
    All DLLs have to be included in the final package. You are missing the first DLL. It isn't very clear how you did that but the build system wouldn't have very many good clues to know that this dependency exists. Adding a reference to the DLL is required. – Hans Passant Nov 19 '14 at 16:15
  • 1
    How would you add a reference to the DLL? The WinRT component (Step 2 above) doesn't have a way to add the DLL as a reference. The C# app will not accept the DLL created in step 1 above. – eitan barazani Nov 19 '14 at 16:30

1 Answers1

1

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

Rob Caplan - MSFT
  • 21,714
  • 3
  • 32
  • 54