English 中文(简体)
登记在VB6号C#.net活动中
原标题:Subscribe to C# .net Event in VB6
  • 时间:2011-08-16 08:30:51
  •  标签:
  • .net
  • com
  • vb6

我需要能够处理VB6的蚊帐事件。 迄今为止,我通过让我看到“C”类“COM”来建立这一机制。 我的VB6物体可以要求使用这种方法,但现在需要某种方式从蚊帐到VB。 如果在我的组别上增加一个活动,则网包裹似乎增加一个部分。 活动与删除 假设情况是签署和不提交活动。 但是,就VB6而言,i m仍然是一种创新,因此实际上无法确定如何使用。

添加“EventName”似乎是指 谁是谁? i 审理该次,但给我留下了一个错误。 谁知道如何使用? 这方面的一个例子是,我已经做了些什么。

Private oHost As HostService.IHost

Private Sub Form_Load()
    Set oHost = New HostService.Host
    oHost.Start
    oHost.add_EvalReceived EvalReceivedEventHandler
End Sub

Private Sub EvalReceivedEventHandler(ByVal sender As Variant, ByVal e As EvalReceivedEventArgs)
MsgBox "Eval Received in VB: " & e.Eval.TimeSent & ":" & e.Eval.FirstName & " " & e.Eval.LastName & " - " & e.Eval.Comments
End Sub

So oHost.add_EvalReceived Line is wrong

最佳回答

您可尝试在您的<代码>上添加。 标题

Private WithEvents oHost As HostService.IHost

然后,民主选举学会应允许你在<条码>上创建活动操作员。 背 景 它只是要打上你的<条码>。 密码窗口顶端的倒塌应当让你选择<代码>o。 背 景

申斥: 我曾多次利用这一机会处理来自COM物体的事件。 我从未实际尝试过一次事件。 网上反对,但我认为你必须这样做。

问题回答

Ok i在MarkJ的帮助下工作。 我必须有一个接口,代表我为COM而开展的活动。 因此,他们最终认为了这一点。

[ComSourceInterfaces(typeof(IHostEvents))]
[ClassInterface(ClassInterfaceType.None)]
[Guid("037CF765-4C30-4CF7-969C-1775E79844CE")]
public class Host : IHost
{
    //IHost implementation
}

[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
[Guid("8C0C3F0E-5793-4E11-AB20-3A556C0B6790")]
public interface IHostEvents
{
    [DispId(1)]
    void EvalReceived(object sender, EvalReceivedEventArgs e);
}

可在VB6中使用<代码>。 地址Of营运人,间接创建代表:

oHost.add_EvalReceived AddressOf EvalReceivedEventHandler




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签