Microsoft提供了博客文章Coffee Break: Use the PowerShell Runner Add-In如何從Dynamics NAV內運行Dynamics NAV PowerShell Cmdlet。
如果你喜歡在C#中使用它,你可以使用相同的Microsoft.Dynamics.Nav.PowerShellRunner.dll。它位於服務層C:\ Program Files \ Microsoft Dynamics NAV \ 100 \ Service \ Add-ins \ PowerShellRunner的加載宏文件夾中。
C#示例:
PowerShellRunner PowerShellRunner = PowerShellRunner.CreateInSandbox();
PowerShellRunner.WriteEventOnError = true;
PowerShellRunner.ImportModule(@"C:\Program Files(x86)\Microsoft Dynamics NAV\100\RoleTailored Client\Microsoft.Dynamics.Nav.Apps.Tools.dll");
PowerShellRunner.AddCommand("Remove-NAVApplicationObjectLanguage");
string[] sources = new string[] { "TAB9.TXT", "TAB14.TXT" };
PowerShellRunner.AddParameter("Source", sources);
PowerShellRunner.AddParameter("Destination", @".\RESULT");
PowerShellRunner.WriteEventOnError = true;
PowerShellRunner.BeginInvoke();
從代碼調用小命令的實例7000倍的性能開銷不會是從在命令行調用它7000倍不同。要回答你的問題:不,不是直接,cmdlet接口使用'protected'方法,這就是爲什麼你只能在創建一個Cmdlet類的實例時看到'Invoke()'的原因。 –