Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input string was not in a correct format exception in NuGet

I'm trying to install Ninject in one of my projects with exact version and project name given. I'm using locally hosted package repository. I'm facing following issue during package installation:

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> 

After that:

  • the record is added to packages.config in the project directory
  • the packaged is added to packages directory in the solution directory
  • library is not referenced
  • depending libraries are not processed.

How can I mend it? What can cause this problem?

like image 657
Arkadiusz Kałkus Avatar asked Feb 16 '15 12:02

Arkadiusz Kałkus


People also ask

What is input string?

String input templates allow you to specify the type, order, and number of characters a user can enter in a data entry field. You can define string input templates only on single‑line character data entry fields.


1 Answers

I don't know exactly what's causing the problem, but we were able to solve it by running the following command using administrator credentials:

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

However, be sure to actually start the command line as administrator (not just runas), otherwise you'll be presented a success message although the registration actually failed.

After that restart Visual Studio and it should work (at least it did for me, tested on several machines with VS 2010 / 2012 / 2013).

like image 91
andreask Avatar answered Oct 21 '22 20:10

andreask