0

i'm currently trying to load a self-written dynamic link module (Compiled with /ZW /EHsc) in an UWP app using the LoadPackagedLibrary(...) function. It is required to load all libraries dynamically due to the way the libs are build. I have included the DLL within the project and enabled it as content (Also verified: it at least gets copied to the XBox like expected).

In case I run my application on Windows everything works fine as expected. But as soon as I launch my application on the XBox LoadPackagedLibrary(...) failed with ERROR_MOD_NOT_FOUND. In the Visual Studio output window, I can see that the XBox is loading my DLL with no problems but directly discards it after loading it:

"DAServerUWP.exe" (Win32): "D:\DevelopmentFiles\<<MYAPP>>\SampleDAClient.dll" geladen. Symbole wurden geladen.
"DAServerUWP.exe" (Win32): "D:\DevelopmentFiles\<<MYAPP>>\SampleDAClient.dll" wurde entladen.

I suspect it has something to do with the Package.appxmanifest not properly (or currently not at all) specifying the DLL. But I didn’t find that much information online nor did any of the proposed solutions work.

Edit: Here are the lines how the DLL is defined in the .vcxproj:

<ItemGroup>
   <None Include="SampleDAClient.dll">
      <DeploymentContent>true</DeploymentContent>
   </None>
</ItemGroup>

Edit2: Probably it has something to do with dll dependencys. Theses are my libs dependencys:

Desktop_To_UWP_dll

which look totaly different when compared to an native UWP dll:

Native_UWP_dll

Ohjurot
  • 47
  • 9
  • Has the dll file that added to your project been set to `content` type? – Roy Li - MSFT May 03 '21 at 05:55
  • @RoyLi-MSFT Yes, I have selected `True` for `Content` in VisualStudio. However, inside the `.vcxproj` file the dll is under the `None` xml Tag with `DeploymentContent` equal to `true`. I have included the lines regarding the dll in the original question. – Ohjurot May 03 '21 at 06:59
  • @RoyLi-MSFT I think I have isolated the problem: There has to be an module dependency inside my DLL that is not availible on XBOX. When comparing to the native UWP dll, it used a completly diffrent naming pattern and a special runntime (VCRUNTIME_XXX_APP). I will add the screenshots to the question. But I need to get an desktop cross plaform dynamic link lib running on XBOX because the used build system (premake) does not support UWP / Windows Store apps. The only thing it allowes me to do is add special flags to the linker and compiler (And I tried to match these). – Ohjurot May 03 '21 at 17:39
  • I asked other engineers and they told me the same thing - the DLL is probably missing a dependency that is present on other platforms, but not Xbox. Our suggestion is that you might need to find other dlls that support Xbox instead of using these dlls. – Roy Li - MSFT May 04 '21 at 02:38
  • Is there no way to change the project type by adding a compiler argument? My DLL itself works fine when migrated to a Universal Windows project. So the problem is not the features used by the DLL. – Ohjurot May 04 '21 at 10:15
  • Now after converting the project to UWP the DLL is not usable on windows desktop. Why is it not possible to set the project type on a per platform base? – Ohjurot May 04 '21 at 11:50
  • Not sure why the DLL is designed to be like this. I think you might submit feedbacks for this issue in the Feedback Hub. Currently, you still need to use other DLLs that supported on Xbox – Roy Li - MSFT May 05 '21 at 08:00
  • I'm currently writing a little tool that copies and converts the `.sln` and '.vcxproj' files to a separate directory just for building the UWP dlls. I will take the time later and submit a feedback when I'm done with the tool and know exactly what it takes to go this dual support rout. – Ohjurot May 05 '21 at 09:47

1 Answers1

1

To compile a UWP DLL you need to pass these arguments to the compiler:

/D__WRL_NO_DEFAULT_LIB__ /DWINAPI_FAMILY=WINAPI_FAMILY_APP /MD

And these linker flags:

/APPCONTAINER /NODEFAULTLIB:ole32.lib /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:user32.lib /NODEFAULTLIB:msvcrt.lib windowsapp.lib

Furthermore, you need to specify a different LIBPATH to the linker. Instead of this:

/LIBPATH:<VSDIR>\VC\Tools\MSVC\<MSVC_VERSION>\lib\x64

You need to use pass this LIBPATH to the linker:

/LIBPATH:<VSDIR>\VC\Tools\MSVC\<MSVC_VERSION>\lib\x64\store
Sunius
  • 2,789
  • 18
  • 30
  • Thank you for the answer! Works fine. Finally a working solution to unify UWP and Desktop development in one vs solution. Now I can continue blaming the series s/x retail dev kits for not reporting all DirectX 12 features they are capable of in UWP mode :-) I hope Microsoft will at some point of time allow everybody to develope for the XBOX with the free GDK… It would solve all that UWP madness once and for ever. – Ohjurot Aug 27 '21 at 07:29
  • 1
    The details in [this blog post](https://walbourn.github.io/directx-and-uwp-on-xbox-one/) about *UWP on Xbox* applies to both Xbox One and Xbox Series X|S. It is true that there's no 'enhanced' GPU features exposed through UWP on Xbox for Xbox Series X|S as it just exposes Direct3D Hardware Feature 11.0. – Chuck Walbourn Aug 27 '21 at 20:49