嘗試在C#中使用Azure cmdlet,除Azure的特定「Get-RoleInstanceCount」外,其他所有工作都正常。 Azure的小命令PROMT運行以下啓動時:如何使用C#運行PowerShell模塊運行空間
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command "cd c:\; Import-Module 'C:\Users\me\Documents\WindowsPowerShell\Modules\WAPPSCmdlets\WAPPSCmdlets.dll'"
我試過如下:
InitialSessionState initialSessionState = InitialSessionState.CreateDefault();
initialSessionState.ImportPSModule(new string[] {"C:\\Users\\me\\Documents\\WindowsPowerShell\\Modules\\WAPPSCmdlets\\WAPPSCmdlets.dll"});
Runspace runspace = RunspaceFactory.CreateRunspace(initialSessionState);
而且也很喜歡他們這樣做是在這裏:
http://msdn.microsoft.com/en-us/library/windows/desktop/ee706596(v=vs.85).aspx
該.dll模塊位於Debug文件夾和上述路徑中。但是,當我嘗試「打開()」運行空間,我得到以下異常:
無法加載文件或程序集「WAPPSCmdlets」或它 的一個依賴。找到的程序集的清單定義不符合程序集引用的 。 (來自HRESULT的例外:0x80131040)
我該怎麼做才能加載使我能夠運行Azure命令的模塊?