question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Could not load type 'System.Diagnostics.PerformanceCounter'

See original GitHub issue

Steps to reproduce

the script error.ps1 is attached.

  1. download WinSCP .Net assembly from https://winscp.net/download/WinSCP-5.9.6-Automation.zip
  2. 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”)
  3. copy attached script: error.ps1 inthe the same directory
  4. 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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
TravisEz13commented, Jul 20, 2017

#4306 is tracking the lack of counter CmdLets. I’m not aware of a workaround.

0reactions
daxian-dbwcommented, 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 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

.NET Core/Framework: Could not load type 'System. ...
Visual Studio caught an exception shown as: System.TypeLoadException: 'Could not load type 'System.Diagnostics.PerformanceCounter' from assembly ...
Read more >
Could not load file or assembly 'System.Diagnostics. ...
I have a web in ASP.Net Core (4.6.1 framework) that uses Facebook and MS external login that I created with Visual Studio 2015...
Read more >
Fix: The type name 'PerformanceCounter' could not be found ...
Fix: CS1069 The type name ' PerformanceCounter ' could not be found in the namespace ' System. Diagnostics '. This type has been...
Read more >
Could not load file or assembly 'System.Diagnostics. ...
Hello, We bought license for DevArt DotConnect Oracle Professional 9.6. Installed successfully and referenced below .dlls from installed folder ...
Read more >
Resolve problems related to System.Diagnostics.Tracing ...
Common.targets: Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Diagnostics.Tracing, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found