Answered by:
Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified

Question
-
User-1651604128 posted
I got this error in my mvc web app when I run it trying to Open a RunSpace of a created Runspacefactory.CreateRunspace(connectionInfo) (I need to use PowerShell)
I am using Visual Studio 2017,
I did some searches, it seems it is not related to the RunSpace I created, it is related the reference dll of Infrastructure file,
I checked my reference, the Microsoft.Web.Infrastructure is included in Reference folder of my project, and its property shows: Copy Local is True,
Can anybody help me what is wrong with this error?
Thanks
Wednesday, October 9, 2019 6:50 PM
Answers
-
User-17257777 posted
Hi Peter,
From the error message, you may not reference the package “ Microsoft.Management.Infrastructure”. You should reference it with NuGet:
https://www.nuget.org/packages/Microsoft.Management.Infrastructure/
Similar problems have been solved here:
https://github.com/PowerShell/PowerShell/issues/7909
Best Regards,
Jiadong Meng.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, October 10, 2019 8:25 AM -
User-1651604128 posted
Hi Peter,
From the error message, you may not reference the package “ Microsoft.Management.Infrastructure”. You should reference it with NuGet:
https://www.nuget.org/packages/Microsoft.Management.Infrastructure/
Similar problems have been solved here:
https://github.com/PowerShell/PowerShell/issues/7909
Best Regards,
Jiadong Meng.
Hi jiadongm, thanks a lot for your help,
As your instructed, I installed the Microsoft.Management.Infrastructure through Tools\Nuget Package Manager\Manage Nuget Package for Solution window,
The installation was completed, but I can not see it from the Reference folder of my project, I did some searches, and somebody said I can add this reference from
C:\Program Files (x86)\Reference Assemblies\Microsoft\WMI\v1.0, so by right clicking Reference folder and click Add Reference, click Browse to find it from this path and add it,
So I can see Microsoft.Management.Infrastructure appear in the Reference folder now, then I compile it with success, and run it again.
Now, I got this new run-time error: WSMan Initialization failed with error code: -2144108171.
any idea? was it caused by that I added the Microsoft.Management.Infrastructure from local is wrong? or something el;se?
Thanks again
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, October 10, 2019 12:43 PM
All replies
-
User-17257777 posted
Hi Peter,
From the error message, you may not reference the package “ Microsoft.Management.Infrastructure”. You should reference it with NuGet:
https://www.nuget.org/packages/Microsoft.Management.Infrastructure/
Similar problems have been solved here:
https://github.com/PowerShell/PowerShell/issues/7909
Best Regards,
Jiadong Meng.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, October 10, 2019 8:25 AM -
User-1651604128 posted
Hi Peter,
From the error message, you may not reference the package “ Microsoft.Management.Infrastructure”. You should reference it with NuGet:
https://www.nuget.org/packages/Microsoft.Management.Infrastructure/
Similar problems have been solved here:
https://github.com/PowerShell/PowerShell/issues/7909
Best Regards,
Jiadong Meng.
Hi jiadongm, thanks a lot for your help,
As your instructed, I installed the Microsoft.Management.Infrastructure through Tools\Nuget Package Manager\Manage Nuget Package for Solution window,
The installation was completed, but I can not see it from the Reference folder of my project, I did some searches, and somebody said I can add this reference from
C:\Program Files (x86)\Reference Assemblies\Microsoft\WMI\v1.0, so by right clicking Reference folder and click Add Reference, click Browse to find it from this path and add it,
So I can see Microsoft.Management.Infrastructure appear in the Reference folder now, then I compile it with success, and run it again.
Now, I got this new run-time error: WSMan Initialization failed with error code: -2144108171.
any idea? was it caused by that I added the Microsoft.Management.Infrastructure from local is wrong? or something el;se?
Thanks again
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, October 10, 2019 12:43 PM -
User-17257777 posted
Hi Peter,
It seems that the package itself has an issue, or the dotnet publish did not successfully release the dll. This may be related to the unique environment of PC.
I suggest you go to github to seek a solution.
Best Regards,
Jiadong Meng
Friday, October 11, 2019 9:23 AM