Msix : how to load DLL from other msix package.

%3CLINGO-SUB%20id%3D%22lingo-sub-280773%22%20slang%3D%22en-US%22%3EMsix%20%3A%20how%20to%20load%20DLL%20from%20other%20msix%20package.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-280773%22%20slang%3D%22en-US%22%3E%3CP%3EThere%20is%20a%20good%20MS%20documentation%20about%20msix%20extension.%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Flaunch-resume%2Fextend-your-app-with-services-extensions-packages%3Fcontext%3D%2Fwindows%2Fmsix%2Frender%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Flaunch-resume%2Fextend-your-app-with-services-extensions-packages%3Fcontext%3D%2Fwindows%2Fmsix%2Frender%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20still%20challenge%20to%20figure%20out%20how%20to%20load%20C%2B%2B%20DLL%20that%20installed%20with%20%22optional%20package%22.%3CBR%20%2F%3EFor%20example%2C%20I%20have%20mainapp.msix(mainapp.exe)%20and%20en-us.msix%20(which%20contains%20en-us%5Cmainappres.dll)%20those%20are%20installed%20unique%20container%20under%20WindowsApps.%20Is%20there%20any%20msix%20configuration%20supported%20to%26nbsp%3Bload%20en-us%5Cmainappres.dll%20from%20mainapp.exe%20LoadlibraryEX()%3F%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EFound%20that%20%22Optional%20package%22%20samples%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAppInstaller%2FOptionalPackageSample%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAppInstaller%2FOptionalPackageSample%3C%2FA%3E.%20Which%20shows%20load%20optional%20DLL.%26nbsp%3B%26nbsp%3BIs%20that%20means%20traditional%20LoadlibraryEX()%20won't%20able%20to%20load%20resource%20DLL%20that%20installed%20from%20additional%20language%20pack%20Msix%3F%3CBR%20%2F%3E%3CBR%20%2F%3EI've%20tried%20with%20resource%20DLL%20MSIX%20with%20set%20MainPackageDependency%20but%26nbsp%3Bstill%20no%20luck.%26nbsp%3B%3CBR%20%2F%3EAny%20suggestions%20and%2For%20ideas%3F%20or%20this%20is%20_not_%20supported.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ERegards%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-281795%22%20slang%3D%22en-US%22%3ERe%3A%20Msix%20%3A%20how%20to%20load%20DLL%20from%20other%20msix%20package.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-281795%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20Andy%2C%3CBR%20%2F%3E%3CBR%20%2F%3ENow%2C%20%22Optional%20package%22%20works%20as%20expected.%20The%20issue%20caused%26nbsp%3Bconverting%20MSI%20to%20MSIX%20with%20%22Msix%20Packaging%20Tool%22%20with%20defining%20below%20Install%20Location.%20If%20I%20define%20install%20location%20as%20%22C%3A%5CProgram%20Files%5CMsixPrototype%22%20then%20MSIX%20generated%20under%20%5BROOT%5D%5CProgram%20Files%26nbsp%3B%20instead%20of%20%5BROOT%5D%5CVFS%5CProgramFilesX64%5C%20which%20caused%20problem%20to%20loading%20optional%20package.%3CBR%20%2F%3EOnce%20change%20package%20location%20under%20%5BROOT%5D%5CVFS%5CProgramFilesX64%5CMsixPrototype%5Cmainapp.exe%26nbsp%3B%3CBR%20%2F%3Eand%20%22Optional%20Package%22%20as%20%5BROOT%5D%5CVFS%5CProgramFielsX64%5CMsixPrototype%5Cmainappres.dll%26nbsp%3B%3CBR%20%2F%3Eall%20worked%20well%20with%20LoadLibraryEx(%20).%3CBR%20%2F%3E%3CBR%20%2F%3ESuggestion%20is%20remove%20%22Install%20location%22%20from%20%22MSIX%20Packaging%20Tool%22%20UI%26nbsp%3B%20_or_%20adding%20description%20to%20avoid%20confusion.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20all.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20792px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F58956iED5EF61D02533928%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%2211-2-2018%202-21-46%20PM.png%22%20title%3D%2211-2-2018%202-21-46%20PM.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20635px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F58957i9E8DBB095619ABE5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%2211-2-2018%202-22-36%20PM.png%22%20title%3D%2211-2-2018%202-22-36%20PM.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-281770%22%20slang%3D%22en-US%22%3ERe%3A%20Msix%20%3A%20how%20to%20load%20DLL%20from%20other%20msix%20package.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-281770%22%20slang%3D%22en-US%22%3E%3CP%3EWith%20regards%20to%20loading%20the%20mainappres.dll%2C%20can%20you%20try%20making%20the%20en-us.msix%20optional%20package%20to%20be%20in%20a%20related%20set%20with%20the%20mainapp.msix%2C%20and%20also%20make%20sure%20mainappres.dll%20is%20in%20the%20root%20of%20en-us.msix%20when%20you%20are%20using%20LoadPackagedLibrary%3F%20Related%20set%20documentation%20for%20working%20within%20Visual%20Studio%20is%20here%3A%20%3CFONT%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Fpackaging%2Foptional-packages%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Fpackaging%2Foptional-packages%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%3EIf%20you%20are%20not%20using%20Visual%20Studio%2C%20you%20can%20create%20the%20related%20set%20manually%20by%20bundling%20the%20mainapp.msix%20into%20an%20.msixbundle%2C%20with%20the%26nbsp%3B%3CSPAN%3EAppxBundleManifest.xml%3C%2FSPAN%3E%20containing%20a%20pointer%20to%20the%20en-us.msix.%20The%20documentation%20for%20how%20to%20do%20this%20is%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fappinstaller%2F2017%2F05%2F12%2Ftooling-to-create-a-related-set%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fblogs.msdn.microsoft.com%2Fappinstaller%2F2017%2F05%2F12%2Ftooling-to-create-a-related-set%2F%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%3ELet%20me%20know%20if%20this%20works%20for%20you.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%3EAndy%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-281764%22%20slang%3D%22en-US%22%3ERe%3A%20Msix%20%3A%20how%20to%20load%20DLL%20from%20other%20msix%20package.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-281764%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20investigating%20a%20bug%20in%20the%20workflow%20for%20modification%20packages%2C%20specifically%20in%20the%20scenario%20you%20outlined%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EJohn.%3C%2FP%3E%0A%3CP%3EProgram%20Manager%20Lead%2C%20MSIX%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-281723%22%20slang%3D%22en-US%22%3ERe%3A%20Msix%20%3A%20how%20to%20load%20DLL%20from%20other%20msix%20package.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-281723%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Andy%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EI've%20followed%20Modification%20package%20process%20the%20same%20way%20as%20%22Microsoft%20Ignite%22%209%2F24%2F18%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Ftime_continue%3D1798%26amp%3Bv%3D_wCv31TI_30%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Ftime_continue%3D1798%26amp%3Bv%3D_wCv31TI_30%3C%2FA%3E%3CBR%20%2F%3Efrom%2031%3A00%20-34%3A30%3CBR%20%2F%3Ewith%20Notepad%2B%2B%20but%20it%20won't%20able%20to%20load%20plugin.%20It%20seems%20like%20working%20if%20you%20have%20Notepad%2B%2B%20MSI%20installed%20but%20once%20Notepad%2B%2B%20MSI%20uninstalled%2C%20the%20Notepad%2B%2B%20that%20installed%20with%20Msix%20won't%20able%20to%20load%20plugin.%26nbsp%3B%3CBR%20%2F%3EAny%20ideas%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-281144%22%20slang%3D%22en-US%22%3ERe%3A%20Msix%20%3A%20how%20to%20load%20DLL%20from%20other%20msix%20package.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-281144%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Andy%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20reply.%20I've%20set%20en-us.msix%20as%20an%20optional%20package.%3C%2FP%3E%3CP%3EI've%20switch%20from%20LoadLibraryEx()%20to%26nbsp%3B%3CSPAN%3ELoadPackagedLibrary()%20but%20still%20does%20not%20working.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20set%20en-us.msix%20as%20%22Framework%22%20and%20set%20%3CPACKAGEDEPENDENCY%3E%20from%20mainapp.msix%20then%20I%20can%20load%20mainappres.dll%20from%20mainapp.exe.%26nbsp%3B%20However%20the%20en-us.msix%20is%20an%20option%20package%20of%20mainapp.msix%20not%20a%20%22Framework%22.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FPACKAGEDEPENDENCY%3E%3C%2FP%3E%3CP%3EIs%20there%20other%20way%20of%20I%20can%20define%20appmanifest.xml%20either%20mainapp.msix%20or%20en-us.msix%20can%20load%20DLL%26nbsp%3B%20the%20same%20way%20as%20en-us.msix%20defined%20with%20%22Framework%22.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EThanks%20for%20sharing%20your%20suggestion.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-280865%22%20slang%3D%22en-US%22%3ERe%3A%20Msix%20%3A%20how%20to%20load%20DLL%20from%20other%20msix%20package.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-280865%22%20slang%3D%22en-US%22%3E%3CP%3EAre%20you%20modeling%20the%20en-us.msix%20as%20an%20optional%20package%20or%20as%20a%20language%20resource%20pack%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20only%20load%20dlls%20from%20optional%20packages%2C%20not%20language%20resource%20packs%2C%20if%20your%20dll%20is%20currently%20contained%20in%20a%20resource%20pack%20then%20you%20should%20move%20it%20to%20be%20part%20of%20the%20main%20package%20or%20change%20the%20resource%20pack%20to%20be%20an%20optional%20package.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20already%20using%20it%20as%20an%20optional%20package%2C%20then%20can%20you%20try%20using%26nbsp%3B%3CSPAN%3ELoadPackagedLibrary%3C%2FSPAN%3E%20(showed%20in%20the%20sample)%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional 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?

MSIX simplifies and modernizes app deployment. It brings a faster, more reliable, and rot-free deployment for your enterprise. Learn the ins and outs of upda...

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