从第二个访问第一个应用程序 [英] Accessing first application from second

查看:72
本文介绍了从第二个访问第一个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用-APP1.
它具有公共类,属性,方法等,并且要加载和显示很多工作,因此具有初始形式.
我还创建了一些在运行时创建的控件,因此在Sub New()中的主要InitializeComponent()之前有很多代码. APP1还读取大量数据,将其组织并存储在集合等中.

我还有第二个应用程序-APP2.
APP2使用APP1中的某些类.
我希望APP2能够使用APP1中的数据,而不必重新读取APP1先前读取的所有数据.
APP2引用了APP1,因此可以理解APP1对象模型.
APP1也是可见的,用户可以更改APP2需要了解的一些数据.

如果我使用APP2中的代码:将Dim app用作New APP1;然后加载APP1的第二个实例,显示启动屏幕等.

然后,我以为我可能会使用COM.即
APP2会有一个GetObject(,"APP1"),但出现错误-无法创建ActiveX等.

有什么想法吗?

我在3.5Framework中使用VB.将启动传输).


您是否同时拥有这两个应用程序的源代码?如果这样做,请对其进行重新加工以使其在一个过程中运行.当然,您通常可以将代码分隔在不同的程序集中,但应将它们用作库,而不是不同的应用程序.



因此,您的目标是没有两个应用程序和通信.您的目标是使代码成为可插入代码的一部分.这是合理的.绝对不应该是两个不同的应用程序和不同的过程!
部分代码可插入并不意味着不同的过程,相反.您需要将可插拔代码作为单独的程序集,并在运行时一开始就将其可插拔.

创建一个插件接口,在其中实现两个或不同版本的AutoCAD(或其他任何版本).有一个配置文件来指定哪些DLL来使用,负载在运行时和调用代码的实现你的插件接口实例适当选择装配.将所有步骤集中在一起非常重要.

现在,您将在这里找到非常详细的插件架构草图:
创建使用可重载插件的WPF应用程序... [ ^ ],
AppDomain拒绝加载程序集 [
Any ideas which way to go??

I am using VB in the 3.5Framework

解决方案

You could set up a WCF channel between the two, and transfer the data that way (probably when app2 starts up, it would initiate the transfer).


Do you have source code for both applications? If you do, re-work them to run in one process. Of course, you could and usually should to segregate code in different assemblies, but use them as libraries, not different applications.

[EDIT]

So, you goal is not having two applications and communication. You goal is make a part of the code pluggable. This is reasonable. No way it should be two different applications and different processes!
Having part of the code pluggable does not mean different process, it''s rather the opposite. You need to make pluggable code a separate assembly and pluggable during run-time, in the very beginning of it.

Make a plug-in interface, implement in it for two or different version of AutoCAD (or whatever else). Have a configuration file to specify which DLL to use, load appropriately selected assembly during run time and invoke the instance of the code implementing you plug-in interface. Having it all in one process is very important.

Now, you will find a very detailed sketch of plug-in architecture here:
Create WPF Application that uses Reloadable Plugins...[^],
AppDomain refuses to load an assembly[^].

Now, don''t get it wrong! Most of the text in the above solutions is devoted to the difficult problem of re-loaded plug-ins. You don''t need anything re-loadable. So you should ignore anything related to Application Domains and the discussion of really difficult problems or unloading/reloading. You architecture will be really simple. Just read on how to develop the plug-in architecture, loading of the assembly, recognition of the plug-in implementation in the loaded assembly and invocation of the class implementing plug-in.

Please, do yourself a favor: stop playing with the idea of separate processes. It''s possible, will require ICP, remoting would be just an evil in your case. Don''t do it, do plug-ins.

—SA


这篇关于从第二个访问第一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆