Powershell v2 - The correct way to load an assembly as part of a module -
i have powershell (v2.0) script working on.
one of first things loads module (runmysqlquery.psm1) includes (amongst other bits) function connect mysql database.
import-module runmysqlquery.psm1
however, requires assembly mysql.data.dll
loaded in order work.
if place line:
[void][system.reflection.assembly]::loadfrom("c:\powershell\modules\runmysqlquery\mysql.data.dll")
at top of script (separate import-module entry), whole thing works fine.
but want able load assembly @ same time module, don't have worry forgetting including assembly each time use module.
i tried placing @ top of .psm1 file, didn't work.
i added manifest file as: requiredassemblies = @("c:\powershell\modules\runmysqlquery\mysql.data.dll")
this didn't work.
am missing here, there proper way include assemblies part of module?
n.b. error when hasn't loaded is:
you cannot call method on null-valued expression
can try assign varialbe beginig of module :
$dumy = [system.reflection.assembly]::loadfrom("c:\powershell\modules\runmysqlquery\mysql.data.dll")
Comments
Post a Comment