Msix : how to load DLL from other msix package.

Copper Contributor

There is a good MS documentation about msix extension. 

https://docs.microsoft.com/en-us/windows/uwp/launch-resume/extend-your-app-with-services-extensions-...

 

However, still challenge to figure out how to load C++ DLL that installed with "optional package".
For example, I have mainapp.msix(mainapp.exe) and en-us.msix (which contains en-us\mainappres.dll) those are installed unique container under WindowsApps. Is there any msix configuration supported to load en-us\mainappres.dll from mainapp.exe LoadlibraryEX()? 

Found that "Optional package" samples https://github.com/AppInstaller/OptionalPackageSample. Which shows load optional DLL.  Is that means traditional LoadlibraryEX() won't able to load resource DLL that installed from additional language pack Msix?

I've tried with resource DLL MSIX with set MainPackageDependency but still no luck. 
Any suggestions and/or ideas? or this is _not_ supported.


Regards,

 

6 Replies

Are you modeling the en-us.msix as an optional package or as a language resource pack?

 

You can only load dlls from optional packages, not language resource packs, if your dll is currently contained in a resource pack then you should move it to be part of the main package or change the resource pack to be an optional package.

 

If you are already using it as an optional package, then can you try using LoadPackagedLibrary (showed in the sample)?

Hi Andy,

 

Thanks for reply. I've set en-us.msix as an optional package.

I've switch from LoadLibraryEx() to LoadPackagedLibrary() but still does not working.

 

If I set en-us.msix as "Framework" and set <PackageDependency> from mainapp.msix then I can load mainappres.dll from mainapp.exe.  However the en-us.msix is an option package of mainapp.msix not a "Framework".

Is there other way of I can define appmanifest.xml either mainapp.msix or en-us.msix can load DLL  the same way as en-us.msix defined with "Framework".


Thanks for sharing your suggestion. 

Hi Andy,

I've followed Modification package process the same way as "Microsoft Ignite" 9/24/18
https://www.youtube.com/watch?time_continue=1798&v=_wCv31TI_30
from 31:00 -34:30
with Notepad++ but it won't able to load plugin. It seems like working if you have Notepad++ MSI installed but once Notepad++ MSI uninstalled, the Notepad++ that installed with Msix won't able to load plugin. 
Any ideas?

We are investigating a bug in the workflow for modification packages, specifically in the scenario you outlined below.

 

John.

Program Manager Lead, MSIX 

With regards to loading the mainappres.dll, can you try making the en-us.msix optional package to be in a related set with the mainapp.msix, and also make sure mainappres.dll is in the root of en-us.msix when you are using LoadPackagedLibrary? Related set documentation for working within Visual Studio is here: https://docs.microsoft.com/en-us/windows/uwp/packaging/optional-packages

If you are not using Visual Studio, you can create the related set manually by bundling the mainapp.msix into an .msixbundle, with the AppxBundleManifest.xml containing a pointer to the en-us.msix. The documentation for how to do this is here: https://blogs.msdn.microsoft.com/appinstaller/2017/05/12/tooling-to-create-a-related-set/

 

Let me know if this works for you.

 

Andy

Thanks Andy,

Now, "Optional package" works as expected. The issue caused converting MSI to MSIX with "Msix Packaging Tool" with defining below Install Location. If I define install location as "C:\Program Files\MsixPrototype" then MSIX generated under [ROOT]\Program Files  instead of [ROOT]\VFS\ProgramFilesX64\ which caused problem to loading optional package.
Once change package location under [ROOT]\VFS\ProgramFilesX64\MsixPrototype\mainapp.exe 
and "Optional Package" as [ROOT]\VFS\ProgramFielsX64\MsixPrototype\mainappres.dll 
all worked well with LoadLibraryEx( ).

Suggestion is remove "Install location" from "MSIX Packaging Tool" UI  _or_ adding description to avoid confusion. 

Thanks all.


11-2-2018 2-21-46 PM.png11-2-2018 2-22-36 PM.png