Create ProteusAPI.dll Step By Step

Today we are going to build and compile a proxy class for BlueCat Networks Proteus appliance so we can manage it from Powershell.

First things first – what version of Powershell are we working with? Open up Powershell and run “Get-Host”  - the output in my case is below. You see from the Version property the value 2.0. This is important because we will want to use the correct version of the .NET framework SDK tools.

We know in our case we are going to use Powershell 2.0 and we know Powershell 2.0 relies on the .NET Framework 2.0. Because we know these two items we now know we need to verify we have the .NET Framework 2.0 SDK installed, if we don’t we need to install it now. (Why do we need the SDK installed? Good question: We need WSDL.exe and that tool is found in the frameworks SDK)

I did not have it installed so I downloaded it here:

Once downloaded run Setup.exe and proceed with the install.

The SDK gets installed in C:\Program Files\Microsoft.NET\SDK. You can see the version that has been installed here.

If we dive a little deeper we will see the tool we need to actually proceed with making our proxy class.

Now that we know we have the right tools installed we can finally get to work.

I suggest hitting this url in a browser in your environment to validate you are correct. Maybe in your environment you need https instead of http .

If you are correct it should look similar to this:

The actual output is much more than I am displaying in the screenshot but you should get the idea.

Open up a command prompt and change to the directory where WSDL.exe in found.

My location is shown below:

It’s time to generate our .cs file.

Here is the command I ran:

The first argument is the WSDL and the second argument is where I want the new .cs file located.

Here is the output from the command:

Below you can see the new .cs file was generated in the path we used as the second argument.

Per the BlueCat documentation we now need to make one small modification to the content of the .cs file. Open it in Notepad and search for the string "public ProteusAPI"
It will look like this:

You will need to make a small edit. It should look like this when done.

Save the file and close Notepad.

Now that I have a .cs file I could use it directly in a C# project from within Visual Studio. In this case I just want to compile the .cs file into a .dll where I can use it from my Powershell scripts.

We complete this task by using csc.exe which is part of the normal everyday .NET Framework, don’t need the SDK for this part.

From your command prompt window change your current directory to c:\windows\Microsoft.NET\Framework.

This is where all versions of the framework are installed.

Change your current directory into the folder that corresponds to the version you need to use. In this case it is still the 2.0 version.

Here is my next command:

We have 3 arguments but for this example we are only interested in the last 2. Where do we want the dll created and where can we find the .cs files.

The output isn't much but here is another screenshot:

And finally we can see our new .dll was created too.

This new .dll file is what you reference from within your Powershell scripts or .NET projects. I will post some examples using this .dll later.

Create ProteusAPI.dll Step By Step Create ProteusAPI.dll Step By Step Reviewed by Shawn on 9:13 AM Rating: 5

1 comment:

  1. Nice tutorial, besides you can also solve problem with Visual Studio missed .dll library files using just download one you need and add in into the system 32 folder. This is the fastest way to fix it without any additional tools and software.


Powered by Blogger.