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()'的原因。 –