1

PROBLEM
I created a C# project that implements the System.Management.Automation reference (allowing me to write powershell commands in my project).
enter image description hereenter image description here

I compiled the project and copied the dll to the plugins folder of my Rainmeter application so that I could leverage it along with the other dll 's Rainmeter comes with. enter image description here

This works perfectly on my machine (64 bit); however, I want to load this same configuration on another server (also 64 bit). Both machines are using the same installation of the .NET framework (4.5).

According to this source, I should be able to simply copy the Rainmeter folder with the included dll and it should run without any problems (I'm using the portable installation of Rainmeter).

I receive the error "System.IO.FileNotFoundException" unless I remove the "SystemVersion.dll" that I created, when running Rainmeter on another server.
enter image description here

QUESTION
Since the issue is clearly the dll I have added, I'm assuming the reference is not being added to the dll?

========================================================================= EDIT
As per @Hackerman 's answer, the issue was that the dll was unable to find my reference. The path for System.Management.Automation required powershell version 3.0 to be installed on the machine in order to load the reference.
enter image description here My server was running powershell version 2.0, but after installing version 3.0 the dll was able to load the reference and Rainmeter would display my results as expected.

ITSUUUUUH
  • 189
  • 1
  • 3
  • 18
  • Is this a WinForms project? – Hackerman Oct 07 '16 at 17:03
  • @Hackerman No, it is a dll. Output type is a Class Library. – ITSUUUUUH Oct 07 '16 at 17:06
  • Ok, now I have a better understanding....you created a Rainmeter plugin, but when you include your dll in the plugins folrder, Rainmeter doesn't works, right? – Hackerman Oct 07 '16 at 17:24
  • @Hackerman That is correct. – ITSUUUUUH Oct 07 '16 at 17:25
  • 1
    Can you post the full error message....I think that maybe your dll can't find the `System.Management.Automation` assembly...and answering your question, no, when you build your dll, it doesn't embed the referenced dll... – Hackerman Oct 07 '16 at 17:31
  • @Hackerman Sorry, had a few meetings to attend. ... You were right about the dll being unable to find the 'System.Management.Automation assembly'. The full path in properties is: C:\Program Files (x86)\Reference Assemblies\Microsoft\**WindowsPowerShell\3.0**\System.Management.Automation.dll The server I was targeting did not have powershell version 3.0, so it could not load the reference. – ITSUUUUUH Oct 07 '16 at 19:07
  • @Hackerman Post your answer to my question, as well as your suspicion that the dll was unable to find the 'System.Management.Automation' as an "Answer" below. I will accept it and add an edit to my post showing where the issue was found. – ITSUUUUUH Oct 07 '16 at 19:21
  • Consider it done :) – Hackerman Oct 07 '16 at 19:30

1 Answers1

1

When you build your class library, the references don't get embedded on your final dll. The System.IO.FileNotFoundException that you are getting is because your dll can't load the System.Managem‌​ent.Automation.dll reference on the destination server. Installing PowerShell 3.0 on the server should resolve the issue.

Hackerman
  • 12,139
  • 2
  • 34
  • 45