当我在MonoDevelop中创建一个控制台项目并尝试通过NuGet添加一个包时,我的应用程序停止并显示此错误:
Adding 'MongoDB.Bson 2.1.0' to NugetEx. Could not install package 'MongoDB.Bson 2.1.0'. 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. System.InvalidOperationException: Could not install package 'MongoDB.Bson 2.1.0'. 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 NuGet.ProjectManager.ExtractPackageFilesToProject (IPackage package) [0x00000] in <filename unknown>:0 at NuGet.ProjectManager.AddPackageReferenceToProject (IPackage package) [0x00000] in <filename unknown>:0 at NuGet.ProjectManager.Execute (NuGet.PackageOperation operation) [0x00000] in <filename unknown>:0 at NuGet.ProjectManager.Execute (IPackage package, IPackageOperationResolver resolver) [0x00000] in <filename unknown>:0 at NuGet.ProjectManager.AddPackageReference (IPackage package, Boolean ignoreDependencies, Boolean allowPrereleaseVersions) [0x00000] in <filename unknown>:0 at NuGet.ProjectManager.AddPackageReference (System.String packageId, NuGet.SemanticVersion version, Boolean ignoreDependencies, Boolean allowPrereleaseVersions) [0x00000] in <filename unknown>:0 at ICSharpCode.PackageManagement.SharpDevelopPackageManager.AddPackageReference (IPackage package, Boolean ignoreDependencies, Boolean allowPrereleaseVersions) [0x00000] in <filename unknown>:0 at ICSharpCode.PackageManagement.SharpDevelopPackageManager.InstallPackage (IPackage package, ICSharpCode.PackageManagement.InstallPackageAction installAction) [0x00000] in <filename unknown>:0 at ICSharpCode.PackageManagement.PackageManagementProject.InstallPackage (IPackage package, ICSharpCode.PackageManagement.InstallPackageAction installAction) [0x00000] in <filename unknown>:0 at ICSharpCode.PackageManagement.InstallPackageAction.ExecuteCore () [0x00000] in <filename unknown>:0 at ICSharpCode.PackageManagement.ProcessPackageAction.Execute () [0x00000] in <filename unknown>:0 at ICSharpCode.PackageManagement.PackageActionRunner.Run (IPackageAction action) [0x00000] in <filename unknown>:0 at ICSharpCode.PackageManagement.PackageViewModel.InstallPackage (IEnumerable`1 packageOperations) [0x00000] in <filename unknown>:0 at ICSharpCode.PackageManagement.PackageViewModel.InstallPackage () [0x00000] in <filename unknown>:0 at ICSharpCode.PackageManagement.PackageViewModel.TryInstallingPackage () [0x00000] in <filename unknown>:0
答案 0 :(得分:2)
阅读错误信息的那一部分:
无法安装软件包&#39; MongoDB.Bson 2.1.0&#39;。你正试图 将此包安装到目标项目中 &#39; .NETFramework,版本= 4.0版&#39;
如果我们看一下official driver page,我们可以确认Mongo 2.1.0和.Net4确实不兼容:
如上表所示,您应该安装1.10版本。
但是,NuGet上似乎没有该版本。您必须在GitHub page for version 1.10
上手动下载我验证NuGet上的版本是否可用的方式是使用以下命令:
Get-Package Mongo.BSon -ListAvailable -AllVersions
如果可用,您可以使用以下方法安装特定版本:
Install-Package Mongo.BSon -Version 1.10