Search code examples
c#uwpdesktop-bridge

UWP FullTrustProcess can't load dll


I'm using uwp and winforms project as full trust process. In winF project I've added reference through NuGet to Dotras.dll. Dll was added to references and everything look ok, launching from winforms directly works good. But when launching UWP and fullTrustProcess called (connection is ok, messages sended) and trying to call Dotras.dll exception thrown.

Could not load file or assembly 'DotRas, Version=1.3.5166.33435, Culture=neutral, PublicKeyToken=b378f04384b7892a' or one of its dependencies. The system cannot find the file specified.

I've tried adding refernce to UWP project, but it it not allowing cause target is .net core and DotRas is .net framework. Any hints where to put dll to make it work? Thanks!


Solution

  • Make sure the exe and dll are deployed to the same folder.

    Here is how.

    Open the project in Visual Studio, there is an Assets folder, normally it is used to store logo images.

    Put both exe and dll into this folder, by right clicking the folder, and select "Add New Item" in the menu, and set their Build Action as Content, so during app deployment they will be to copied to the installation directory in C:\Program Files\WindowsApps\YouPackageFamilyName\, under the same Assets folder.

    In the appxmanifest file, make sure the executable path is correct.

    <desktop:Extension Category="windows.fullTrustProcess" Executable="Assets\YourWinForms.exe">
    </desktop:Extension>
    

    Edit: It doesn't have to be the Assets folder, the key is add the dll to the project with Build Action set as Content and put in the same folder as the exe.