locked
Is it not possible to use VisualStudio 2010 project dll's in a Metro application?

    Question

  • Hi!

    I have a metro javascript metro application which are using C++ metro components. The C++ components are using dll's that are built by using Visual Studio 2010 projects which I have imported into my Visual Studio 2012 solution. But from what I have experienced from this is that it is not possible to use the dll's in the metro application. Is this true? Is it not possible to use non-metro-projects dll's in a metro project?

    What I have tried:

    1. Simply compile and launch the application. The compilation went well, but when starting the application the module (which is the needed dll) is not found. If I copy the dll to the application folder everything works.

    2. Ad the dll project as a reference to the metro component project that needs the dll. Visual studio displayed a dialogue saying ”Adding reference to ’Logger’ is not recommended because it is not compatible with Metro style apps”.

    So from the warning I received from approach 2, I assume that doing as in approach 1 is not recommended (copying the dll to the application folder). So I need to convert all my 2010 projects into metro components in order to be able to use them or am I missing something?

    Friday, June 15, 2012 9:57 AM

All replies

  • 1. you need to set that dll as a package content 
    2. your dll _must_ use WinRT API, otherwise your application certification will fail

    Friday, June 15, 2012 10:18 AM
  • Ok, by setting the dll as the package content (solution 1): Then I first have to set the project as a reference to another project in order to be able to set this property? Because I cant find any settings in the properties. If adding as reference, I anyway get the incompatible warning. So that isn't really a solution to my problem.

    Do my dll really need to use the WinRT API? Or do you mean that I'm can't use the win32 api and should use the WinRT api instead in order to get certified? Because it sounds weird that the my code has call external apis in order to get certified. Or do you mean that I need to create metro components for every dll library that I want to use?

    Friday, June 15, 2012 11:38 AM
  • You DLLs do not need to use the WinRT API and they do not need to be Windows Runtime Components to use in your Metro style app.

    They can regular Win32 DLLs using regular Win32 API, so long as they use only Win32 API which are available to Metro style apps.

    The problem with using VS 2010 is that the C runtime and libraries that it uses are not compatible with Metro style apps, even if the code that you wrote doesn't call any Win32 API directly. Depending on what all your code calls, you may be able to just recompile with VS 2012 so the DLL uses the compatible version of the runtime.

    See Win32 and COM for Metro style apps for more information on which Win32 API are available to use in Metro style apps.

    --Rob

    Friday, June 15, 2012 11:56 AM
    Owner
  • Hi! I have already have recompiled the dlls with visual studio 2012. I have set the "Platform Toolset" in the 2010 projects to Visual Studio 11 and it compiles without any errors. Is there something more I need to do? Since I still get the warning message when I try to add the library as a reference to the metro component. So is that warning message wrong? Since from what I understand, you're saying that this shouldn't be any problem.
    Friday, June 15, 2012 12:12 PM
  • Correct me if I'm wrong, but it appears from above you have it working as desired, if you manually copy the DLL to the app folder? If that is the case, Petr was correct in you needing to include the DLL in your project (not referenced) and set the type as content.

    1. Copy the DLL into the project folder for your Metro style app
    2. Right-click the X.dll and Include in Project
    3. Set the properties for CppDllCOMServer.dll
    3a. Content = True
    3b. File Type = Document

    This will deploy the DLL with the app. Using this method, it will also be included when creating a Store Appx package. It will look like the following.


    David Lamb

    Friday, June 15, 2012 11:06 PM
    Moderator
  • Note that by switching the Toolset to 2010, your dll will still be linked against the VS 2010 CRT which, as Rob mentioned, is not supported. Try recompiling your dll using the 2012 toolset and make sure you have the following define specified for all your cpp files:

    WINAPI_FAMILY=WINAPI_FAMILY_APP

    Marian Luparu
    Visual C++

    • Proposed as answer by Jesse Jiang Wednesday, June 27, 2012 9:36 AM
    Monday, June 18, 2012 11:27 PM