nullByteMe
nullByteMe

Reputation: 6391

How can I load an assembly and use it in powershell?

I read the suggestions on How to load assemblies in PowerShell?, but I didn't really understand it and I don't know how to apply it to my situation.

I'm trying to load this assembly http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx so that I can serialize an object, and being very new to powershell I feel like I'm in over my head.

Can anyone guide me to how I go about loading this assembly into a script? I'm getting the error:

make sure that the assembly containing this type is loaded

And when I use Add-Type -Namespace System.Runtime.Serialization.Formatters.Binary it prompts me for information for which I don't know how to provide.

Upvotes: 1

Views: 1547

Answers (1)

manojlds
manojlds

Reputation: 301527

The BinaryFormatter is present in mscorlib.dll and is already loaded. To create a new object, you can do the following:

$formatter = new-object System.Runtime.Serialization.Formatters.Binary.BinaryFormatter

Upvotes: 2

Related Questions