-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not load file or assembly or one of its dependencies in PowerShell Module project target to netstandard 2.0 #113006
Comments
The tutorial at PowerShell is incomplete. Dependencies aren't copied to output folder on .NET Standard or .NET Core. To get dependencies copied to output folder, you need to use Note that this won't work for System.Threading.AccessControl. There's no single file for System.Threading.AccessControl that works on both .NET Framework and .NET Core. You must multi-target your project with |
Hi @huoyaoyuan . Thanks a lot. Nice information! Make sense to me. It worked as a net462 before. This year we migrate part of the project to net8 and some of the parts remain net462. So we made one of the common lib to netstandard to compile this common lib only once. |
No. It only has reference support for .NET Standard. You can inspect the content of the NuGet package. The support assembly for .NET Framework and .NET 8~10 are not interchangeable. |
Tagging subscribers to this area: @dotnet/area-meta |
As I thought twice, I finally realized that the issue here is that I should not import such a DLL into a netstandard project which DLL has no netstandard implementation. |
I'm not sure what happens exactly with transitive dependencies, but you end goal is to get the correct binary loaded into correct environment. You can check the identity of files get copied to better achieve this. |
Description
PowerShell Module project target to netstandard doesnot work.

It report the error below
Environment
Reproduction Steps
Besides, if a PowerShell Module Project target to net462 refer to a netstandard with the dependency System.Threading.AccessControl, it report the same error.
Expected behavior
It reports error
Actual behavior
It should work in dotnet installed environment. And it should look for 9.0.2, not 9.0.0.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: