输入字符串在NuGet中的格式不正确

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (94)

我正试图在我的一个项目中安装nineject,并给出了确切的版本和项目名称。我正在使用本地托管的包存储库。在包安装过程中,我面临以下问题:

PM> Install-Package Ninject -version 3.2.2.0 -project My.Project.Name
Installing 'Ninject 3.2.2.0'.
You are downloading Ninject from Ninject Project Contributors, the license agreement to which is available at https://github.com/ninject/ninject/raw/master/LICENSE.txt. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Ninject 3.2.2.0'.
Adding 'Ninject 3.2.2.0' to My.Project.Name.
Install failed. Rolling back...
Install-Package : Input string was not in a correct format.
At line:1 char:16
+ Install-Package <<<<  Ninject -version 3.2.2.0 -project My.Project.Name
    + CategoryInfo          : NotSpecified: (:) [Install-Package], FormatException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

PM> $error[0].Exception.StackTrace
   at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at NuGet.PowerShell.Commands.NuGetBaseCommand.Log(MessageLevel level, String message, Object[] args)
   at NuGet.VisualStudio.VsProjectSystem.RemoveReference(String name)
   at NuGet.ProjectManager.RemovePackageReferenceFromProject(IPackage package)
   at NuGet.ProjectManager.Execute(PackageOperation operation)
   at NuGet.ProjectManager.Execute(IPackage package, IPackageOperationResolver resolver)
   at NuGet.ProjectManager.RemovePackageReference(IPackage package, Boolean forceRemove, Boolean removeDependencies)
   at NuGet.VisualStudio.VsPackageManager.RollbackProjectActions(IProjectManager projectManager, IEnumerable`1 packagesAdded, IEnumerable`1 packagesRemoved)
   at NuGet.VisualStudio.VsPackageManager.RunProjectAction(IProjectManager projectManager, Action action)
   at NuGet.VisualStudio.VsPackageManager.AddPackageReference(IProjectManager projectManager, IPackage package, Boolean ignoreDependencies, Boolean allowPrereleaseVersio
ns)
   at NuGet.VisualStudio.VsPackageManager.<>c__DisplayClass8.<InstallPackage>b__4()
   at NuGet.VisualStudio.VsPackageManager.RunSolutionAction(Action action)
   at NuGet.VisualStudio.VsPackageManager.InstallPackage(IProjectManager projectManager, String packageId, SemanticVersion version, Boolean ignoreDependencies, Boolean a
llowPrereleaseVersions, Boolean skipAssemblyReferences, ILogger logger)
   at NuGet.VisualStudio.VsPackageManager.InstallPackage(IProjectManager projectManager, String packageId, SemanticVersion version, Boolean ignoreDependencies, Boolean a
llowPrereleaseVersions, ILogger logger)
   at NuGet.PowerShell.Commands.InstallPackageCommand.InstallPackage(IVsPackageManager packageManager)
   at NuGet.PowerShell.Commands.InstallPackageCommand.ProcessRecordCore()
   at NuGet.PowerShell.Commands.NuGetBaseCommand.ProcessRecord()
PM> 

之后:

  • 将记录添加到项目目录中的Packages.config中
  • 打包后的文件将添加到解决方案目录中的Packages目录中。
  • 未引用库
  • 不处理依赖库。

我该怎么修复呢?是什么导致了这个问题?

提问于
用户回答回答于

我不知道到底是什么导致了问题,但是我们能够通过使用管理员凭据运行以下命令来解决这个问题:

regsvr32 "C:\Program Files (x86)\Common Files\microsoft shared\MSEnv\VsLangproj.olb"

但是,请确保以管理员身份实际启动命令行(而不仅仅是runas),否则你将收到一个成功消息,尽管注册实际上失败了。

在重新启动VisualStudio之后,它应该可以工作(至少对我来说是这样,在VS 2010/2012/2013的几台机器上进行了测试)。

用户回答回答于

我已经试过了,它正像预期的那样正常工作。

regsvr32 "C:\Program Files (x86)\Common Files\microsoft shared\MSEnv\VsLangproj.olb"

扫码关注云+社区