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

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

Accepted answer
  1. Roy Li - MSFT 32,731 Reputation points Microsoft Vendor
    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