Search code examples
c#visual-studionugetnuget-packagesystem.diagnostics

ProcessStartInfo does not contain a definition for 'Verb'


I do have this issue whereby ProcessStartInfo does not contain definition verb so i can not do 'runas'. On VisualStudio 2015 a project 'foo' that uses ProcessStartInfo does have this definition 'verb' - confirmed by examining the class. Other project running on VisualStudio 2017 does NOT seem to recognize this method. Moreover, the method is missing from the class itself. Now i am not sure why and how this is possible?

Full error code:

Severity    Code    Description Project File    Line    Suppression State
Error   CS1061  'ProcessStartInfo' does not contain a definition for 'Verb' 
and no extension method 'Verb' accepting a first argument of type 
'ProcessStartInfo' could be found (are you missing a using directive or an 
assembly reference?)    project3cx  C:\Users\Boss\Documents\Visual Studio 
2017\Projects\project\project3cx\Program.cs 64  Active

The only difference between ProcessStartInfo class is that the version 4.0.0.0

#region Assembly System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.dll
#endregion

Does have definition 'verb' and version 4.1.0.0 does not have defitnion verb.

#region Assembly System.Diagnostics.Process, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// C:\Users\Boss\.nuget\packages\system.diagnostics.process\4.3.0\ref\netstandard1.4\System.Diagnostics.Process.dll
#endregion

I can also see that one project assembly is managed by nuget, the other is not. I have installed/updated nuget System.Diagnostics package but to no avail. Any help ?


Solution

  • The only difference between ProcessStartInfo class is that the version 4.0.0.0. Does have definition 'verb' and version 4.1.0.0 does not have defitnion verb.

    Just as Hans commented, you need to "Pay attention to the project template you selected". I repeat the answer here more detail so that other community members who get the same issues can find the answer more easily.

    According to the reply to the question on GitHub, the ProcessStartInfo.Verb is not supported on .NET Core/.NET Standard:

    I've tagged it as a bug since this API shouldn't be showing up in our docs since it's not supported on .NET Core. It needs to be deleted from the article. @chenkennt, @bradygaster another case of APIs that are not really part of .NET Core showing up on docs.

    Besides, both Verb as well as Verbs are coming back as part of .NE Standard 2.0.