You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: Could not load type 'System.Diagnostics.PerformanceCounter' #4295
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-ExternalThe issue is caused by external component(s).
unzip in a directory named C:\PS_B4) Note:
in case a different directory name is choosen, script code below needs to be adapted before running it!
$WinSCPnet_dll = ("C:\PS_B4\WinSCPnet.dll")
copy attached script: error.ps1 inthe the same directory
run powershell.exe
.\error.ps1
Expected behavior
no error
and text:
script: ended successfully
Actual behavior
error gets
thrown:
Exception calling ".ctor" with "0" argument(s): "Could not load type 'System.Diagnostics.PerformanceCounter' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'."
Environment data
>$PSVersionTable
Name Value
---------
PSVersion 6.0.0-beta
PSEdition Core
GitCommitId v6.0.0-beta.4
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
changed the title [-]bug: Could not load type 'System.Diagnostics.PerformanceCounter[/-][+]bug: Could not load type 'System.Diagnostics.PerformanceCounter'[/+]on Jul 19, 2017
mi-hol Thanks!
I tried WinSCP module https://github.com/dotps1/WinSCP - it use the same dll and loads well. I manually load the dll from the module - loads well. I download WinSCP-5.9.6-Automation.zip and mannually load the dll from the package - loads well.
Calling a WinSCP cmdlet raise an exception:
Exception : System.Management.Automation.MethodInvocationException:
Exception calling ".ctor" with "0" argument(s):
"Could not load type 'System.Diagnostics.PerformanceCounter' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'."--->
System.TypeLoadException: Could not load type
'System.Diagnostics.PerformanceCounter'from assembly
'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at WinSCP.Logger..ctor()
at WinSCP.Session..ctor()
---End of inner exception stack trace ---
at System.Management.Automation.DotNetAdapter.Auxili
aryConstructorInvoke(MethodInformation
methodInformation, Object[] arguments, Object[]
originalArguments) in C:\Users\sie\Documents\GitHub\iSa
zonov\PowerShell\src\System.Management.Automation\engin
e\CoreAdapter.cs:line 3776
at System.Management.Automation.DotNetAdapter.Invoke
ResolvedConstructor(MethodInformation bestMethod,
Object[] newArguments, Object[] arguments) in C:\Users\
sie\Documents\GitHub\iSazonov\PowerShell\src\System.Man
agement.Automation\engine\CoreAdapter.cs:line 3940
at System.Management.Automation.DotNetAdapter.Constr
uctorInvokeDotNet(Type type, ConstructorInfo[]
constructors, Object[] arguments) in C:\Users\sie\Docum
ents\GitHub\iSazonov\PowerShell\src\System.Management.A
utomation\engine\CoreAdapter.cs:line 3930
at Microsoft.PowerShell.Commands.NewObjectCommand.Ca
llConstructor(Type type, ConstructorInfo[]
constructors, Object[] args) in C:\Users\sie\Documents\
GitHub\iSazonov\PowerShell\src\Microsoft.PowerShell.Com
mands.Utility\commands\utility\new-object.cs:line 71
TargetObject :
CategoryInfo : InvalidOperation: (:) [New-Object],
MethodInvocationException
FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.C
ommands.NewObjectCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at New-WinSCPSession, C:\Program Files\WindowsPowerShel
l\Modules\winscp\Public\New-WinSCPSession.ps1: line 128
at <ScriptBlock>,<No file>: line 1
PipelineIterationInfo : {}
Also #4272 & #4303 seem related to the same issue.
From my view PerformanceCounter is frequently used and all metrics are defined in
PowerShell/src/Microsoft.PowerShell.Commands.Diagnostics/CoreCLR/Stubs.cs
i.e. to calculate
' /// A difference timer that shows the total time between when the component
/// or process started and the time when this value is calculated.
///
ElapsedTime = 807666944,'
https://github.com/dotnet/corefx/issues/3906 is labelled with Future milestone, so it won't be available in .NET Core 2.0. mi-hol please feel free to leave comments in that corefx issue, so as to let them know the user demands.
I wonder what is plans for our counter cmdlets? Should we make a workaround in the repo until we have CoreFX implementations? Have we a tracking Issue?
Dongbo Wang (@daxian-dbw) in light of Joey Aiello's public community request to 'tell us what does and doesn’t work for you on github' I'm a bit puzzled by the unexpected close of a confirmed incompatibility.
We have been told numerous times that user feedback counts, now #4306 doesn't mention the error message a user will receive due to this incompatibly, hence I wonder how user feedback for this specific issue will be properly gathered?
mi-hol We do welcome feedbacks and I appreciate you brought up this issue.
This issue was closed because the problem was understood and the resolution is out of the scope of powershell. The API/assembly it depends on is not available in .NET Core 2.0 and netstandard2.0, and thus nothing can be done on the powershell side unless dotnet/corefx#3906 is fixed.
mi-hol I edited your comment related to this issue in #4062 to add the root cause of this issue. That will help get all information we need in one place. See #4062 (comment)
mi-hol Your effort is truly appreciated. When reviewing comments reported in #4062, people can easily get here via the link to learn more information about the issue.
Thanks for bringing up your concern about this issue being closed. I should have better explained the "why" when closing it. Lesson learned :)
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-ExternalThe issue is caused by external component(s).
Activity
iSazonov commentedon Jul 19, 2017
mi-hol Thanks for your report! Please add a sample script to repo the error.
[-]bug: Could not load type 'System.Diagnostics.PerformanceCounter[/-][+]bug: Could not load type 'System.Diagnostics.PerformanceCounter'[/+]mi-hol commentedon Jul 19, 2017
Ilya (@iSazonov) error.ps1.txt is now available to repo bug
iSazonov commentedon Jul 20, 2017
mi-hol Thanks!
I tried WinSCP module https://github.com/dotps1/WinSCP - it use the same dll and loads well. I manually load the dll from the module - loads well. I download WinSCP-5.9.6-Automation.zip and mannually load the dll from the package - loads well.
Calling a WinSCP cmdlet raise an exception:
Exception : System.Management.Automation.MethodInvocationException: Exception calling ".ctor" with "0" argument(s): "Could not load type 'System.Diagnostics.PerformanceCounter' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'." ---> System.TypeLoadException: Could not load type 'System.Diagnostics.PerformanceCounter' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. at WinSCP.Logger..ctor() at WinSCP.Session..ctor() --- End of inner exception stack trace --- at System.Management.Automation.DotNetAdapter.Auxili aryConstructorInvoke(MethodInformation methodInformation, Object[] arguments, Object[] originalArguments) in C:\Users\sie\Documents\GitHub\iSa zonov\PowerShell\src\System.Management.Automation\engin e\CoreAdapter.cs:line 3776 at System.Management.Automation.DotNetAdapter.Invoke ResolvedConstructor(MethodInformation bestMethod, Object[] newArguments, Object[] arguments) in C:\Users\ sie\Documents\GitHub\iSazonov\PowerShell\src\System.Man agement.Automation\engine\CoreAdapter.cs:line 3940 at System.Management.Automation.DotNetAdapter.Constr uctorInvokeDotNet(Type type, ConstructorInfo[] constructors, Object[] arguments) in C:\Users\sie\Docum ents\GitHub\iSazonov\PowerShell\src\System.Management.A utomation\engine\CoreAdapter.cs:line 3930 at Microsoft.PowerShell.Commands.NewObjectCommand.Ca llConstructor(Type type, ConstructorInfo[] constructors, Object[] args) in C:\Users\sie\Documents\ GitHub\iSazonov\PowerShell\src\Microsoft.PowerShell.Com mands.Utility\commands\utility\new-object.cs:line 71 TargetObject : CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.C ommands.NewObjectCommand ErrorDetails : InvocationInfo : System.Management.Automation.InvocationInfo ScriptStackTrace : at New-WinSCPSession, C:\Program Files\WindowsPowerShel l\Modules\winscp\Public\New-WinSCPSession.ps1: line 128 at <ScriptBlock>, <No file>: line 1 PipelineIterationInfo : {}mi-hol commentedon Jul 20, 2017
Ilya (@iSazonov) do the comments mean that you can't reproduce the error using my error.ps1 script?
iSazonov commentedon Jul 20, 2017
mi-hol I edited my message.
It seems CoreFX don't implement
System.Diagnostics.PerformanceCounterSee https://github.com/dotnet/corefx/issues/3906
and dotnet/corefx#17898 - "Only refs adjusted!"
/cc Dongbo Wang (@daxian-dbw) Is it problem for PowerShell Core RTM?
mi-hol commentedon Jul 20, 2017
Also #4272 & #4303 seem related to the same issue.
From my view PerformanceCounter is frequently used and all metrics are defined in
PowerShell/src/Microsoft.PowerShell.Commands.Diagnostics/CoreCLR/Stubs.cs
i.e. to calculate
' /// A difference timer that shows the total time between when the component
/// or process started and the time when this value is calculated.
///
ElapsedTime = 807666944,'
daxian-dbw commentedon Jul 20, 2017
https://github.com/dotnet/corefx/issues/3906 is labelled with
Futuremilestone, so it won't be available in .NET Core 2.0.mi-hol please feel free to leave comments in that corefx issue, so as to let them know the user demands.
iSazonov commentedon Jul 20, 2017
I wonder what is plans for our counter cmdlets? Should we make a workaround in the repo until we have CoreFX implementations? Have we a tracking Issue?
/cc Travis Plunk (@TravisEz13)
TravisEz13 commentedon Jul 20, 2017
#4306 is tracking the lack of counter CmdLets.
I'm not aware of a workaround.
mi-hol commentedon Jul 20, 2017
Dongbo Wang (@daxian-dbw) in light of Joey Aiello's public community request to 'tell us what does and doesn’t work for you on github' I'm a bit puzzled by the unexpected close of a confirmed incompatibility.
We have been told numerous times that user feedback counts, now #4306 doesn't mention the error message a user will receive due to this incompatibly, hence I wonder how user feedback for this specific issue will be properly gathered?
daxian-dbw commentedon Jul 20, 2017
mi-hol We do welcome feedbacks and I appreciate you brought up this issue.
This issue was closed because the problem was understood and the resolution is out of the scope of powershell. The API/assembly it depends on is not available in
.NET Core 2.0andnetstandard2.0, and thus nothing can be done on the powershell side unless dotnet/corefx#3906 is fixed.daxian-dbw commentedon Jul 20, 2017
mi-hol I edited your comment related to this issue in #4062 to add the root cause of this issue. That will help get all information we need in one place. See #4062 (comment)
mi-hol commentedon Jul 20, 2017
Dongbo Wang (@daxian-dbw) Thanks! Hopefully the effort I put into opening & reproducing this bug is not wasted.
daxian-dbw commentedon Jul 21, 2017
mi-hol Your effort is truly appreciated. When reviewing comments reported in #4062, people can easily get here via the link to learn more information about the issue.
Thanks for bringing up your concern about this issue being closed. I should have better explained the "why" when closing it. Lesson learned :)