Xamarin+iOS编译报错:找不到System.Text.Json程序集求助
Hey there, let's tackle this frustrating assembly resolution error you're hitting after updating Xamarin and Xcode. The core issue here is that your project (specifically the Microsoft.OData.Edm.dll dependency) is looking for a specific version of System.Text.Json that's missing from your NuGet cache or project references. Here's how to resolve it step by step:
1. Install the Missing System.Text.Json Version via NuGet
First, let's ensure the exact required version is installed in your iOS project:
- Right-click your iOS project in Visual Studio → Manage NuGet Packages
- Switch to the Browse tab, search for
System.Text.Json - Look for version
4.0.1.1(if it doesn't appear, double-check that you have the official NuGet.org source enabled in your NuGet settings) - Install this version, then check if the error persists
If version 4.0.1.1 isn't available, try installing the closest stable version (like 4.7.2) and update Microsoft.OData.Edm to its latest version—newer releases of this dependency often use a more widely available version of System.Text.Json.
2. Clean, Clear Caches, and Rebuild
Corrupted build artifacts or stale NuGet caches are common culprits here:
- Go to Build → Clean Solution in Visual Studio
- Manually delete the
binandobjfolders from your iOS project directory (these hold outdated temporary build files that clean commands might miss) - Restart Visual Studio completely to clear in-memory caches
- Right-click your solution → Restore NuGet Packages
- Finally, rebuild your solution with Build → Rebuild Solution
3. Update the Microsoft.OData.Edm Dependency
The error explicitly links the missing assembly to Microsoft.OData.Edm.dll. Let's fix the dependency mismatch:
- In your iOS project's NuGet packages, locate
Microsoft.OData.Edm - Update it to the latest stable version—newer releases will likely depend on a more readily available version of
System.Text.Json, resolving the version conflict - After updating, repeat the clean/rebuild steps above
4. Manually Add the Assembly Reference (If NuGet Fails)
If NuGet can't install the correct version, grab the assembly directly from your .NET framework installation:
- Navigate to
C:\Program Files\dotnet\shared\Microsoft.NETCore.App\ - Look for a directory corresponding to a .NET Core version that includes
System.Text.Json(version 4.0.1.1 is typically tied to .NET Core 3.1) - Find the
System.Text.Json.dllfile in that directory - Right-click your iOS project → Add → Reference → Browse
- Select the
System.Text.Json.dllfile you found and add it to your project
5. Verify Your Xamarin.iOS Target Framework
Outdated target frameworks can cause compatibility issues with newer dependencies:
- Right-click your iOS project → Properties
- Go to the iOS Application tab
- Ensure the Target framework matches a version compatible with your updated Xcode (e.g., if you updated to Xcode 15, target iOS 17 or a supported older version)
内容的提问来源于stack exchange,提问作者Marc George

