Azure Functions中Google.Protobuf程序集版本冲突问题求助
Hey there! Let's figure out why you're running into this Google.Protobuf version mismatch issue when setting up FirestoreDb in your Azure Functions project, and walk through how to fix it.
This boils down to an assembly version binding conflict, and there are a few common culprits:
- Indirect dependencies pulling in old versions: Some of your installed NuGet packages (like the Firestore SDK itself) might be referencing Google.Protobuf v3.0.0 indirectly. When Azure Functions loads assemblies, it might pick this older version over the v3.5.1 you installed directly.
- Azure Functions runtime assembly loading rules: The Functions runtime has its own assembly loading strategy, and sometimes it prioritizes older versions that come bundled with the runtime instead of using the ones from your project.
- VS2017 build/deployment quirks: The 15.6.2 version of Visual Studio 2017 is pretty old, and it might have issues properly copying the newer Google.Protobuf assembly to your output directory, or overwriting it during deployment.
Let's go through solutions in order of priority:
1. Add assembly binding redirects
Force the runtime to use v3.5.1 of Google.Protobuf by adding binding redirects to your project configuration file.
For .NET Framework projects (app.config):
Add this inside the <runtime> section:
<dependentAssembly> <assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.5.1.0" newVersion="3.5.1.0" /> </dependentAssembly>
For .NET Core/.NET 5+ projects (runtimeconfig.json):
Make sure your file includes this configuration:
{ "runtimeOptions": { "assemblyBinding": { "dependencies": { "Google.Protobuf": { "version": "3.5.1.0" } } } } }
2. Update all related NuGet packages
Old versions of the Firestore SDK might be the ones pulling in Google.Protobuf v3.0.0. Update your Google Cloud packages to the latest compatible versions to resolve this:
- Right-click your project → Manage NuGet Packages
- Go to the Installed tab, find packages like
Google.Cloud.Firestore - Click Update to install the latest stable version (this should automatically reference a newer Google.Protobuf version that matches your installed v3.5.1)
3. Ensure the new assembly is copied to output
Double-check that the v3.5.1 Google.Protobuf DLL is being copied to your project's output folder:
- If you've referenced the DLL directly, right-click it in your project → Properties → Set Copy Local to
True - Manually check your output directory (usually
bin\Debug\netX.x) to confirmGoogle.Protobuf.dllhas version 3.5.1.0
4. Clean, rebuild, and redeploy
Old VS versions can cache outdated assemblies. Do a full clean and rebuild to make sure no old files are stuck around:
- Right-click your project → Clean
- Delete the
binandobjfolders from your project directory - Right-click your project → Build
- Redeploy your Azure Functions project
5. Upgrade Visual Studio (optional but recommended)
VS2017 15.6.2 is quite outdated, and newer versions (even later VS2017 updates, or VS2019/2022) have better handling of Azure Functions dependencies and deployment. Upgrading can prevent similar issues in the future.
内容的提问来源于stack exchange,提问作者Gustavo Cesar Goncalves Soares

