locked
Consuming a DLL(Universal Apps) from a WinRT Component

    Question

  • Hello,

    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

    Wednesday, November 19, 2014 3:49 PM

Answers

  • 1) Not enough info to know for sure, but my first guess is that you're not including the Dll in the apps package so it isn't deployed and able to be loaded.

    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


    Wednesday, November 19, 2014 6:20 PM
    Owner
  • You could likely create a C++ WinRT component and copy all the code from your existing DLL there instead of creating a separate DLL. Then you would create a facade in the WinRT component that wraps your native C++ functions.

    Basically you would just combine 1. and 2. into a single project.

    Thursday, November 20, 2014 10:57 AM

All replies

  • 1) Not enough info to know for sure, but my first guess is that you're not including the Dll in the apps package so it isn't deployed and able to be loaded.

    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


    Wednesday, November 19, 2014 6:20 PM
    Owner
  • You could likely create a C++ WinRT component and copy all the code from your existing DLL there instead of creating a separate DLL. Then you would create a facade in the WinRT component that wraps your native C++ functions.

    Basically you would just combine 1. and 2. into a single project.

    Thursday, November 20, 2014 10:57 AM
  • 1) Not enough info to know for sure, but my first guess is that you're not including the Dll in the apps package so it isn't deployed and able to be loaded.

    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


    What do you mean with this?

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

    I just have the same problem, I already have added the dll in the solution and marked as content, but it doesn't work.


    Monday, May 04, 2015 8:33 AM