我有两个应用程序
,第一个使用 C 编写,第二个使用 VB.NET
我想执行第一个并将状态更新到第二个
有没有办法做到这一点 ?
我可以更改其中任何一个的源代码
我有两个应用程序
,第一个使用 C 编写,第二个使用 VB.NET
我想执行第一个并将状态更新到第二个
有没有办法做到这一点 ?
我可以更改其中任何一个的源代码
我可以看到使用 C 和 VB 存在并发症,但这是一个开始的地方 http://msdn.microsoft.com/en-us/library/aa365574%28VS.85%29.aspx
好的,在VB中你需要在两个程序之间实现一个接口,这样你就可以在它们之间传递参数。
在program1(调用程序)中,我设置了这个:
Dim oType As System.Type
Dim oAssembly As System.Reflection.Assembly
Dim oObject As System.Object
oAssembly = Reflection.Assembly.LoadFrom("C:\VB.NET\report3.exe")
oType = oAssembly.GetType("report3.r1") ' this is [root_namespace.class name]
oObject = Activator.CreateInstance(oType)
oObject.SetParams("a", "b")
oObject.show()
这会导致 report3.exe 运行并将“a”和“b”参数作为值发送给它。
然后在program2(report3.exe)中,我这样设置:
Imports System.Reflection
Public Class r1
Implements IPlugin
Public person As String = ""
Public address As String = ""
Private Sub r1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.TopMost = True 'optional
Dim b1 As New Label()
With b1
.Location = New Point(10, 10)
.Width = 200
.Height = 20
.Parent = Me
.BackColor = Color.Blue
.ForeColor = Color.White
.Text = person
End With
call_addr()
End Sub
Public Sub SetParams(c As String, d As String) Implements IPlugin.SetParams
person = c
address = d
End Sub
Private Sub call_addr()
Dim b2 As New Label()
With b2
.Location = New Point(10, 50)
.Width = 200
.Height = 20
.Parent = Me
.BackColor = Color.Red
.text = address
End With
End Sub
End Class
Public Interface IPlugin
Sub SetParams(ByVal c As String, ByVal d As String)
End Interface