Could not load file or assembly ‘System.Private.CoreLib
Published Jan 15 2019 02:37 PM 17K Views
Microsoft
First published on MSDN on May 15, 2018
This post to help those that are facing the following error when trying to install an UWP - Desktop Bridge .NET application:



Exception type:   System.IO.FileNotFoundException

Message:          Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.



This error occurs because Microsoft Store no longer accepts packages with mixed UWP and Desktop .NET binaries that have not been created with the proper packaging project ( Visual Studio Packaging Project ). This is to ensure the UWP binaries get the proper .NET native compile in the cloud (which is not applicable to the Desktop .NET binaries).

To package an UWP App with a Win32 extension, consider to use the new Visual Studio Packaging Project template, and then create the Store package out of that project in VS.

If your Win32 EXE is not built in VS and you just want to include the binary in your UWP project you should still use the Packaging project. Make sure the Win32 EXE gets dropped into a subfolder of the package. See screenshot below for this type of project structure.

Details are in the following blog posts:

Example #3 for this specific case:


https://blogs.windows.com/buildingapps/2017/12/04/extend-desktop-application-windows-10-feature...


Package a .NET desktop application using the Desktop Bridge and Visual Studio Preview


https://blogs.msdn.microsoft.com/appconsult/2017/08/28/package-a-net-desktop-application-using-...



Sideload Scenario


To install the App in a sideload scenario (without use Microsoft Store), it is necessary to install the corresponding AppPackages folder that has the “_Test” suffix and install the appxbundle that is in that folder, since the assemblies in the .appxupload generated by VS (in all projects) are IL, not yet compiled with .NET Native.



Don't forget to double-check if the App is compiled in Release mode with .NET native compilation enabled.

For more info/examples, look here:

https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/

https://blogs.windows.com/buildingapps/2017/12/04/extend-desktop-application-windows-10-features... (see example #3)



I hope it helps.
1 Comment
Copper Contributor

I am getting the following error when I am trying to build my C# unit test project. Expecting your help at the earliest

 

assembly xyz.dll failed to load properly Could not resolve assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Are you missing an assembly reference?

 

 

Co-Authors
Version history
Last update:
‎Nov 22 2022 12:20 PM
Updated by: