由于我以前从未有理由这样做,所以我不知道如何执行以下操作,或者是否可能?!
我有一个 C# winforms 单实例应用程序(从属),它有一个控件,可以使用自定义 .Net 控件显示计划数据。该应用程序需要从 DynamicsNAV / Navision (Master) 打开,因为它无法使用正在使用的控件。
一旦主设备打开从设备应用程序,它需要传递一个参数,以便从设备可以收集正确的数据并显示它。我知道我可以将其作为命令行参数传递,但我们真正想做的是将其传递到一个方法中,以便我们可以根据需要更新从属计划。我已经在从属应用程序中创建了一个公共方法,但现在我不知道如何打开它并调用该方法。我想使用 Master winforms 应用程序获得一个工作示例,但也无法实现。
任何人都可以提供任何建议或帮助吗?
谢谢,
卡尔
As I've never had reason to do this before, I don't know how to do the following, or if it's even possible?!
I have a C# winforms single instance application (Slave) that has a control on it that displays schedule data using custom .Net controls. The application needs to be opened from DynamicsNAV / Navision (Master) as this can't use the controls being used.
Once the Master opens the Slave app, it needs to pass across a parameter so the Slave can gather the correct data and display it. I know I could pass this as a command line argument, but what we'd really like to do is have it passed into a method so we can update the Slaves Schedule as and when we like. I've already created a public Method in the Slave application, but now I'm stuck as to how I'd open it and call the method. I wanted to get a working example using a Master winforms app, but couldn't get that working either.
Can anyone offer any advice or assitance?
Thanks,
Karl
发布评论
评论(3)
如果您使用的是 Dynamics NAV 6 R2 和角色定制客户端,您可以使用 .NET 互操作 调用 WinForms 应用程序上的方法。如果您使用的是经典客户端,则需要实现 COM 组件来执行相同的操作。
在这种情况下,WinForms 应用程序是“服务器”,NAV 是“客户端”。您可以查看如何使用 IpcChannel 此处。
If you are using Dynamics NAV 6 R2 and the Role Tailored Client you can use .NET interop to invoke methods on your WinForms application. If you are using the Classic client you need to implement a COM component to do the same thing.
In such a scenario, the WinForms app is the 'server' and NAV is the 'client'. You can see an example of how this might work using an IpcChannel here on MSDN.
是的,你可以这样做 - 通常这被称为“进程间通信”。
有许多可用的方法,但只要您使用 .Net 3.5 或更高版本,您就应该使用 WCF (Windows Communication Foundation) 来实现此目的。互联网上有许多关于 WCF 的指南和介绍。
如果您使用 3.5 之前的 .Net 版本,请查看 .Net 远程处理。
Yes you can do this - typically this is referred to as "inter process communication".
There are many available methods, but as long as you are using .Net 3.5 or later you should probably be using WCF (Windows Communication Foundation) for this. There are many guides and introductions to WCF available on the internet.
If you are using a version of .Net prior to 3.5 then look into .Net remoting.
以任何形式(命令参数、文件、TCP/IP 套接字等)发送数据、解析数据并调用使用从分离创建的参数创建的命令怎么样?
What about sending the data in any form (command arguments, a file, TCP/IP socket, whatever), parsing the data and calling the command you've created with the arguments created from the parting?