powershell - Could not load file or assembly -
in power shell script loading custom assembly , instantiating class of assembly new-object.
assembly.loadfile() executes new-object statement gives bellow exception.
new-object : exception calling ".ctor" "1" argument(s): "could not load file or assembly 'myassembly, version=1.0.0.0, culture=neutral, publickeytoken=null' or 1 of ts dependencies. system cannot find file specified." script:
[system.reflection.assembly]::loadfile("myassembly.dll") $a=new-object myassembly.myclass -argumentlist "arg1" this custom assembly references following assemblies
system system.core system.runtime.serialization system.xml.linq system.data system.xml i tried explicitly loading system.runtime.serialization dll below. same exception
[system.reflection.assembly]::load("system.runtime.serialization, version=3.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089") any idea?
don't use loadfile. since using powershell v2, preferred method add-type
add-type -assemblyname "mylibrary.dll" http://www.dougfinke.com/blog/index.php/2010/08/29/how-to-load-net-assemblies-in-a-powershell-session/ has list of different ways available import library current shell runspace.
http://technet.microsoft.com/en-us/library/hh849914.aspx technet documentaion on add-type , has examples including how use static methods in loaded library
Comments
Post a Comment