Which version of Google.Protobuf is good for .netframework 4.0?

2.3k views Asked by At

When I install version from 3.0.0 to 3.5.1, error message as below:

Install-Package : Could not install package 'Google.Protobuf 3.5.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. At line:1 char:1 + Install-Package Google.Protobuf -Version 3.5.1 -Project HDExamine + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

Then I refer to nuget package site, its dependencies include NETStandard.Library (>= 1.6.1), after I installed NETStandard.Library 2.0.1 successfully, but the err message is still the same.

My application is based on .net framework 4.0, want to know which version of Google.Protobuf I can use, very appreciated for any help.

1

There are 1 answers

2
Marc Gravell On

It looks like the official Google packages target .NET 4.5 (and .NET Standard) - and has never targeted anything lower than .NET 4.5. There could be a technical reason for this, but it could be simply testing, convenience, etc. So one option is to simply clone it locally and try changing the target framework: see what breaks.

Alternatively, if you're not tied to that implementation: protobuf-net targets all the versions (well, not quite - I finally dropped .NET 1.1). The API works differently, but it should still have what you need, including .proto to C# codegen (https://protogen.marcgravell.com is the easiest way to do that; there's also a download on the page for the command-line tool, which has more features).