从控制台应用程序打开 wpf 应用程序并将对象传递给它
我们想从控制台应用程序打开一个 wpf 应用程序,并将在控制台应用程序中初始化的对象传递给 wpf 应用程序。只是想知道这是否可能。 谢谢 氮
We would like to open a wpf app from a console app and pass objects which were initialized in the console app to the wpf app. Just wondering if this is possible.
Thanks
N
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用命令行并将序列化对象作为参数传递,但这仅在您启动 wpf 应用程序时有效 1 次。
如果您需要保持两者之间的持续对话,您将需要在 wpf 应用程序中托管一个 wcf 服务并以这种方式与之对话。
IMO 在 WPF 应用程序中托管服务是最好的方法。
You could use the command line and pass serialized objects as arguments but this will only work 1 time, when you start the wpf app.
If you need to maintain an ongoing conversation between the two you will need to host a wcf service in the wpf app and talk to it that way.
IMO hosting a service in the WPF app is the best way to go.
您可以像任何其他类一样在 wpf 窗口的构造函数中传递对象。
例如: Window1 window = new window1(myObject);
You can pass objects in the constructor of your wpf window just like any other class..
Ex: Window1 window = new window1(myObject);