Local machine test of MSIX app removes dll's from main project

Copper Contributor

VS 2019

 

I've added a MSIX project to my solution. My Main project compiles and runs with no probems.

I can compile the MSIX project with no problems.

When I Start on Local Machine, the MSIX project displays the Main project, but says a dll is missing.

When I return to the Main project, certain dll's are missing from the reference (although not the dll MSIX said was missing.

 

I've done this 3 or 4 times with the same results.

Have I done something wrong?

Bob K.

4 Replies

@rkamarowski 

 

What's the specific error you get at when you try run the app? And if you go to the output directory of the MSIX package is the dll there? e.g. MSIXProj\bin\x64\Debug\

 

Tanaka

@Tanaka_Jimha 

No, the dll is not in the debug folder. And it is no longer in the Main project. When I attempt to add the dll back into the main project i'm getting the second error.

@rkamarowski The addition of the MSIX package should not affect dlls from the main package.  I'm going to ignore that report in my comments here, assuming something else was going on.

 

There are situations where under MSIX your dlls would not be found.  It depends on how the non-MSIX version would have found them as the LoadModule function will operate differently.  A summary of these causes are:

  1.  The working directory of the process has changed.  Traditional apps tend to have a working directory set to the directory of the exe file. LoadModule will first look in the process working directory for the dll.  MSIX packages have the System32 set as the working directory, so dlls in the primary folder might not be found.
  2. The working directory of the process has changed. The shortcut lnk file of the original program might have specifically set another folder, such as a subfolder where dlls are stored, as the working directory. MSIX packages have the System32 set as the working directory, so dlls in the sub folder might not be found.
  3. The old program relied on a change to the PATH variable to inform LoadLibrary to look into additional folders.  MSIX packages can's set/change environment folders, so dlls in these additional folders might not be found.
  4. The old program relied on setting the registry "App Paths" registration for you process as a way to tell LoadLibrary to look into additional folders when a certain named exe is running.  MSIX doesn't support this registration so dlls in these additional folders might not be found.

 

Items 1 & 2 may be solved by adding PsfLauncher to the package and configuring your shortcut to target Psflauncher. In the config.json file you also add, you specify your target application exe and the working directory that you want.  A value of "" gives you #1.

 

Items 3 & 4 may be solve by adding PsfLauncher plus a fixup called DynamicLibraryFixup. This fixup will force your application to find dlls located within the package, no matter where they are.

@TIMOTHY MANGAN 

It's fixed! I was able to include the sqlite.interop.dll, and now it's perfect. As far as the disappearing dll's, it hasn't happened since I restarted the solution, so I'll assume it was something I was doing incorrectly.

Thanks everyone for the quick responses.

Bob K.