Access SDK outside of MSIX application

%3CLINGO-SUB%20id%3D%22lingo-sub-2039170%22%20slang%3D%22de-DE%22%3EAccess%20SDK%20outside%20of%20MSIX%20application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2039170%22%20slang%3D%22de-DE%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eour%20application%20use%20MATLAB%20for%20complex%20calculations.%20The%20MATLAB%20code%20is%20converted%20to%20a%20NuGet%20package%20and%20referenced%20in%20our%20.net%20application.%20To%20get%20this%20run%2C%20the%20MATLAB%20runtime%20is%20required%2C%20that%20is%20normally%20installed%20at%20C%3A'Program%20Files'MATLAB'MATLAB%20Runtime%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20to%20run%20our%20application%20that%20is%20packaged%20by%20MSIX%20fails%20with%20%22System.DllNotFoundException%22%20of%20%22mclmcrrt9_5.dll%22%2C%20that%20is%20part%20of%20MATLAB%20Runtime.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20it%20somehow%20possible%20to%20allow%20the%20msix%20container%20access%20to%20this%20runtime%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2040020%22%20slang%3D%22en-US%22%3ERe%3A%20Access%20SDK%20outside%20of%20MSIX%20application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2040020%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F920795%22%20target%3D%22_blank%22%3E%40FrankKubis%3C%2FA%3E%26nbsp%3B%20It%20is%20not%20clear%20if%20the%20Matlab%20code%20from%20the%20nuget%20package%20is%20included%20in%20your%20MSIX%20package.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20it%20is%20included%2C%20you%20should%20probably%20try%20using%20the%20Package%20Support%20Framework%20with%20DynamicLibraryFixup.%26nbsp%3B%20Some%20of%20the%20methods%20used%20in%20the%20traditional%20runtime%20of%20modifying%20the%20Path%20Variable%2C%20or%20using%20App%20Paths%20registration%20to%20solve%20dll%20not%20found%20issues%20don't%20work%20under%20MSIX.%26nbsp%3B%20This%20fixup%20allows%20for%20the%20paths%20to%20package%20dlls%20to%20be%20registered%20in%20a%20new%20way%20(inside%20the%20PSF%20config.json%20file)%20and%20ensures%20that%20if%20the%20dll%20is%20inside%20the%20package%20it%20will%20be%20found.%26nbsp%3B%20If%20packaging%20using%20the%20Microsoft%20MSIX%20Packaging%20Tool%2C%20the%20free%20PsfTooling%20can%20be%20used%20to%20add%20in%20the%20fixup%20and%20will%20automatically%20locate%20all%20dlls%20in%20your%20package%20and%20register%20them.%26nbsp%3B%20If%20using%20other%20third%20party%20tooling%20the%20process%20might%20be%20different%2C%20but%20should%20be%20available.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20the%20dll%20is%20not%20inside%20the%20package%2C%20I%20would%20guess%20that%20manual%20manipulation%20of%20the%20json%20might%20be%20possible.%26nbsp%3B%20I%20have%20not%20tried%20this%20and%20am%20not%20sure%20if%20full%20paths%20(rather%20than%20the%20package%20relative%20paths%20normally%20used)%20are%20supported%20but%20they%20should%20be.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2042676%22%20slang%3D%22en-US%22%3ERe%3A%20Access%20SDK%20outside%20of%20MSIX%20application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2042676%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20for%20your%20reply.%3CBR%20%2F%3E%3CBR%20%2F%3ETo%20make%20it%20clear%3A%20the%20missing%20dll%20is%20not%20part%20of%20our%20MSIX%20package.%20Its%20the%20MATLAB%20runtime%20installed%20on%20the%20system.%20We%20don't%20want%20this%20be%20part%20of%20our%20MSIX%20package.%3CBR%20%2F%3E%3CBR%20%2F%3EAs%20I%20understand%20this%20right%2C%20there%20is%20no%20easy%20way%20to%20get%20this%20work%3F%20We%20want%20to%20create%20the%20package%20in%20our%20Build%20Pipeline%2C%20a%20manual%20manipulation%20is%20not%20possible%20for%20us.%20That%20would%20be%20a%20lot%20over%20overhead%20in%20work.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2043644%22%20slang%3D%22en-US%22%3ERe%3A%20Access%20SDK%20outside%20of%20MSIX%20application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2043644%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F920795%22%20target%3D%22_blank%22%3E%40FrankKubis%3C%2FA%3E%26nbsp%3BThat%20makes%20sense%2C%20I%20should%20have%20guessed%20that's%20what%20you%20were%20doing%20as%20soon%20as%20you%20mentioned%20nuget.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20what%20i%20believe%20to%20be%20the%20underlying%20issue.%26nbsp%3B%20A%20native%20install%20of%20your%20application%20would%20have%20likely%20added%20either%20a%20change%20to%20the%20Path%20variable%2C%20or%20the%20setting%20of%20an%20AppPaths%20registration%20to%20tell%20your%20exe%20additional%20folders%20(the%20sdk)%20to%20look%20for%20dlls%20in.%26nbsp%3B%20Those%20types%20of%20entries%20are%20not%20supported%20inside%20the%20package.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Psf%20and%20DynamicLibraryFixup%20is%20one%20solution%20to%20help%20your%20executable%20find%20the%20dlls.%26nbsp%3B%20Another%20might%20be%20a%20newer%20manifest%20entry%20called%20LoaderSearchPathOverride%2C%20however%20I%20have%20found%20that%20it%20doesn't%20seem%20to%20work%20(see%20my%20posting%20on%20this%20earlier%20this%20week%3A%26nbsp%3B%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fmsix-packaging-and-tools%2Floadersearchpathoverride-and-the-manifest%2Fm-p%2F2030851%22%20target%3D%22_blank%22%3ELoaderSearchPathOverride%20and%20the%20Manifest%20-%20Microsoft%20Tech%20Community).%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOther%20options%20available%20to%20you%20would%20include%20making%20the%20sdk%20native%20install%20solve%20the%20problem%2C%20by%20modifying%20the%20Path%20environment%20variable.%26nbsp%3B%20Your%20application%20inside%20the%20MSIX%20container%20will%20use%20the%20Path%20setting%20on%20the%20native%20system%20to%20locate%20dlls.%26nbsp%3B%20Another%20option%20may%20be%20to%20include%20the%20SDK%20inside%20your%20package.%26nbsp%3B%20This%20will%20significantly%20increase%20the%20size%20of%20your%20package%20and%20may%20bring%20in%20additional%20issues%20-%20I%20know%20that%20the%20full%20install%20of%20MatLab%20needs%20help%20but%20perhaps%20the%20SDK%20only%20would%20be%20OK.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%20us%20know%20what%20you%20find%20works%20for%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2060099%22%20slang%3D%22en-US%22%3ERe%3A%20Access%20SDK%20outside%20of%20MSIX%20application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2060099%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20did%20get%20managed%20to%20fix%20the%20dll%20not%20found%20issue%20using%20the%20Psf%20and%20DynamicLibraryFixup.%20But%20MatLab%20to%20do%20some%20more%20stuff%20in%20the%20background%20that%20fails.%3CBR%20%2F%3E%3CBR%20%2F%3EIt%20seems%20that%20the%20systems%20tries%20to%20write%20into%20some%20location%20of%20the%20file%20system%20like%3A%3CBR%20%2F%3EC%3A%5CUsers%5CXXXX%5CAppData%5CLocal%5CTemp%5CXXXX%5CmcrCache9.5%5C%3CBR%20%2F%3EC%3A%5CUsers%5CXXXX%5CAppData%5CLocal%5CPackages%5CXXXX%5CLocalCache%5CLocal%5CMicrosoft%5CWritablePackageRoot%5CVFS%5CLocal%20AppData%5CTemp%5CXXXX%5CmcrCache9.5%5CLSDToo0%3CBR%20%2F%3E%3CBR%20%2F%3EIam%20not%20sure%20why%20this%20is%20not%20allowed%20or%20does%20not%20work.%20Could%20that%20require%20some%20more%20permissions%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi,

 

our application use MATLAB for complex calculations. The MATLAB code is converted to a NuGet package and referenced in our .net application. To get this run, the MATLAB runtime is required, that is normally installed at C:\Program Files\MATLAB\MATLAB Runtime

 

Try to run our application that is packaged by MSIX fails with "System.DllNotFoundException" of "mclmcrrt9_5.dll", that is part of MATLAB Runtime.

 

Is it somehow possible to allow the msix container access to this runtime?

5 Replies

@FrankKubis  It is not clear if the Matlab code from the nuget package is included in your MSIX package.

 

If it is included, you should probably try using the Package Support Framework with DynamicLibraryFixup.  Some of the methods used in the traditional runtime of modifying the Path Variable, or using App Paths registration to solve dll not found issues don't work under MSIX.  This fixup allows for the paths to package dlls to be registered in a new way (inside the PSF config.json file) and ensures that if the dll is inside the package it will be found.  If packaging using the Microsoft MSIX Packaging Tool, the free PsfTooling can be used to add in the fixup and will automatically locate all dlls in your package and register them.  If using other third party tooling the process might be different, but should be available.

 

If the dll is not inside the package, I would guess that manual manipulation of the json might be possible.  I have not tried this and am not sure if full paths (rather than the package relative paths normally used) are supported but they should be.

Thank for your reply.

To make it clear: the missing dll is not part of our MSIX package. Its the MATLAB runtime installed on the system. We don't want this be part of our MSIX package.

As I understand this right, there is no easy way to get this work? We want to create the package in our Build Pipeline, a manual manipulation is not possible for us. That would be a lot over overhead in work.

 

Seems some lake of permission, running the application as administrator does work.

@FrankKubis That makes sense, I should have guessed that's what you were doing as soon as you mentioned nuget.

 

Here is what i believe to be the underlying issue.  A native install of your application would have likely added either a change to the Path variable, or the setting of an AppPaths registration to tell your exe additional folders (the sdk) to look for dlls in.  Those types of entries are not supported inside the package.

 

The Psf and DynamicLibraryFixup is one solution to help your executable find the dlls.  Another might be a newer manifest entry called LoaderSearchPathOverride, however I have found that it doesn't seem to work (see my posting on this earlier this week:  LoaderSearchPathOverride and the Manifest - Microsoft Tech Community).

 

Other options available to you would include making the sdk native install solve the problem, by modifying the Path environment variable.  Your application inside the MSIX container will use the Path setting on the native system to locate dlls.  Another option may be to include the SDK inside your package.  This will significantly increase the size of your package and may bring in additional issues - I know that the full install of MatLab needs help but perhaps the SDK only would be OK.

 

Let us know what you find works for you!

We did get managed to fix the dll not found issue using the Psf and DynamicLibraryFixup. But MatLab to do some more stuff in the background that fails.

It seems that the systems tries to write into some location of the file system like:
C:\Users\XXXX\AppData\Local\Temp\XXXX\mcrCache9.5\
C:\Users\XXXX\AppData\Local\Packages\XXXX\LocalCache\Local\Microsoft\WritablePackageRoot\VFS\Local AppData\Temp\XXXX\mcrCache9.5\LSDToo0

Iam not sure why this is not allowed or does not work. Could that require some more permissions?

@FrankKubis You probably need to add the FileRedirectionFixup to handle the file write permissions to any file contained inside the package.

 

Heads up: There is a known issue in the FRF that affects ways that a few apps access files if the user name includes the space character, so avoid that for now until we get it addressed.