title: Can you use C++ DLLs in C# code in a UWP?
body: <p>I wrote a C++ Class Library in Visual Studio that just defines a function that invokes some Python:</p>
  
  <pre><code>#pragma once
  
  #include &lt;Python.h&gt;
  
  extern "C"
  __declspec(dllexport)
  void python()
  {
      Py_Initialize();
      PyRun_SimpleString("2 + 2");
  }
  </code></pre>
  
  <p>I made another project in the same solution that was a C# Blank Universal app. I tried to reference the DLL generated from the previous project I mentioned:</p>
  
  <pre><code>using System;
  ...
  
  namespace StartupApp
  {
      ...
      sealed partial class App : Application
      {
          private const string CPPPythonInterfaceDLL = @"pathtodll";
  
          [DllImport(CPPPythonInterfaceDLL, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
          private static extern void python();
  
          public static void Python()
          {
              python();
          }
          ...
          public App()
          {
              ...
  
              Python();
          }
  
          ...
      }
  }
  </code></pre>
  
  <p>The app is in a Release configuration.</p>
  
  <p>Whenever I try to run the app on my Local Machine, it always gives an error: </p>
  
  <pre><code>The program '[2272] StartupApp.exe' has exited with code -1073741790 (0xc0000022).
  Activation of the Windows Store app 'ab6a8ef2-1fa8-4cc7-b7b3-fb7420af7dc3_7dk3a6v9mg4g6!App' failed with error 'The app didn't start'.
  </code></pre>
  
  <p>So my question is this: can I reference a C++ class library from a C# UWP project? Or does the security on UWP apps not allow this?</p>
  
  <p>Or is it because of Python.h?</p>
  
  <p>EDIT:</p>
  
  <p>I built the project with a DLL project and a Runtime Component that wrapped it, and now I have this error:</p>
  
  <p>An exception of type 'System</p>
  
  <pre><code>'System.DllNotFoundException' occurred in StartupApp.exe but was not handled in user code
  
  Additional information: Unable to load DLL 'pathtodll': Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
  </code></pre>
  
  <p>I added a user to the DLL with the object name "Everyone" (I am not sure how else to give everyone permissions) but the error still comes up.</p>