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

SmilingMoon 981 Reputation points
2021-11-29T20:14:36.203+00:00

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:
https://1drv.ms/u/s!AqB-HjXxUE9ngeJNkU6QOUFd3W6E3w?e=mEpZB2

With out of box simple test project, it happens.

153436-image.png

Developer technologies | Universal Windows Platform (UWP)
Developer technologies | .NET | Other
{count} votes

Accepted answer
  1. Anonymous
    2021-12-01T02:27:42.68+00:00

    Hello,

    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:

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

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.