Could not load file or assembly


In my power shell script I am loading a custom assembly and then instantiating a class of that assembly by New-Object.

Assembly.LoadFile() executes successfully but New-Object statement gives the bellow exception.


This custom assembly references only the following assemblies

I tried explicitly loading the System.Runtime.Serialization dll like below. But same exception

Any idea?


Don’t use LoadFile. Since you are using Powershell V2, the preferred method is Add-Type has a good list of the different ways available to import a library into the current shell runspace. is the technet documentaion on Add-Type and has examples including how to use static methods in a loaded library


Could not load file or assembly by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply