Search code examples
c#dlltransferrainmeter

Do .dll 's retain any references added to your project?


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.


Solution

  • 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.