UWP Package project encountering "Could not load file or assembly 'System.Memory" error on XmlSerializer"

SmilingMoon 981 Reputation points

When running Package project with UWP dependency,
it causes "Could not load file or assembly 'System.Memory" error on XmlSerializer.Deserialize() method.
Here is the test solution you can download and run it:

With out of box simple test project, it happens.


Microsoft Technologies based on the .NET software framework.
3,195 questions
Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Roy Li - MSFT 31,481 Reputation points Microsoft Vendor


    Welcome to Microsoft Q&A!

    @SmilingMoon You could try to add <Target Name="ResolvePackageDependenciesForBuild" /> this into the project file of the packaging project.

    Like this:

        <ProjectReference Include="..\TestUWP\TestUWP.csproj" />  
      <Target Name="ResolvePackageDependenciesForBuild" />  

    After adding this, I could run your sample correctly without exceptions.

    Thank you.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful