Autor Beitrag
Baumunk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 50

WinXP
Delphi 2005
BeitragVerfasst: Di 10.06.08 09:47 
Hallo zusammen,

Ich versuche unter Delphi COM erignis (events) zu kriegen, die aus .NET assembly ausgelöst wird über COM schnittschtelle.

Quellcode des Assemby

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
using Microsoft.Office.Interop.Outlook;
using System.Windows.Forms;

namespace OutlookEvent
{
    public delegate void TerminEvent ();

    [ComVisible(true)]
    [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
    [GuidAttribute("C8431024-6775-4bf1-8F0B-54B4FF42C754")]
    public interface INoRAOutlookEventHandler
    {
        [DispId(1900000201)]
        void Event_AddTermin ();

        [DispId(1900000202)]
        void Event_ModifiedTermin();

        [DispId(1900000203)]
        void Event_RemoveTermin ();
    }

    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    [ComVisible(true)]
    [Guid("FFAD8EDF-895C-45e7-AD1E-E90B0216CB2F")]
    public interface INoRAOutlookEvent
    {
        [DispId(210)]
        String InBearbeitung { get;set;}
    }
        
    [ClassInterface(ClassInterfaceType.None)]
    [ComVisible(true)]
    [Guid("BEBC31DE-B292-46c4-846E-30A600C42C2D")]
    [ComSourceInterfaces(typeof(INoRAOutlookEventHandler))]
    public class NoRAOutlookEvent : INoRAOutlookEvent
    {
        private String mInBearbeitung = String.Empty;
        private Microsoft.Office.Interop.Outlook.ApplicationClass outlook = null;

        public event TerminEvent Event_AddTermin;
        public event TerminEvent Event_ModifiedTermin;
        public event TerminEvent Event_RemoveTermin;

        public NoRAOutlookEvent()
        {
            InitializeComponent();
        }

        void InitializeComponent()
        {
            outlook = new Microsoft.Office.Interop.Outlook.ApplicationClass();
            CalendarMonitor monitor = new CalendarMonitor(outlook.Application.Session);
            monitor.AppointmentAdded +=
                new EventHandler<EventArgs<AppointmentItem>>(monitor_AppointmentAdded);
            monitor.AppointmentModified +=
                new EventHandler<EventArgs<AppointmentItem>>(monitor_AppointmentModified);
            monitor.AppointmentDeleting +=
                new EventHandler<CancelEventArgs<AppointmentItem>>(monitor_AppointmentDeleting);
        }

        private void monitor_AppointmentAdded(object sender, EventArgs<AppointmentItem> e)
        {
            String EntryID = e.Value.EntryID;
            MessageBox.Show("Hinzugefügt (Dll)");
            Event_AddTermin();
        }

        private void monitor_AppointmentModified(object sender, EventArgs<AppointmentItem> e)
        {
            String EntryID = e.Value.EntryID;
            MessageBox.Show("Geändert (Dll)");
            Event_ModifiedTermin();
        }

        private void monitor_AppointmentDeleting(object sender, CancelEventArgs<AppointmentItem> e)
        {
            String EntryID = e.Value.EntryID;
            MessageBox.Show("Gelöscht (Dll)");
            Event_RemoveTermin();
        }


Delphi:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
TNoRAOutlookEvent = class(TOleServer)
  private
    FOnEvent_AddTermin: TNotifyEvent;
    FOnEvent_ModifiedTermin: TNotifyEvent;
    FOnEvent_RemoveTermin: TNotifyEvent;
    FIntf:        INoRAOutlookEvent;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
    FProps:       TNoRAOutlookEventProperties;
    function      GetServerProperties: TNoRAOutlookEventProperties;
{$ENDIF}
    function      GetDefaultInterface: INoRAOutlookEvent;
  protected
    procedure InitServerData; override;
    procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray); override;
    function Get_InBearbeitung: WideString;
    procedure Set_InBearbeitung(const pRetVal: WideString);
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
    procedure Connect; override;
    procedure ConnectTo(svrIntf: INoRAOutlookEvent);
    procedure Disconnect; override;
    property DefaultInterface: INoRAOutlookEvent read GetDefaultInterface;
    property InBearbeitung: WideString read Get_InBearbeitung write Set_InBearbeitung;
  published
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
    property Server: TNoRAOutlookEventProperties read GetServerProperties;
{$ENDIF}
    property OnEvent_AddTermin: TNotifyEvent read FOnEvent_AddTermin write FOnEvent_AddTermin;
    property OnEvent_ModifiedTermin: TNotifyEvent read FOnEvent_ModifiedTermin write FOnEvent_ModifiedTermin;
    property OnEvent_RemoveTermin: TNotifyEvent read FOnEvent_RemoveTermin write FOnEvent_RemoveTermin;
  end;

.....

procedure TNoRAOutlookEvent.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
begin
  case DispID of
    -1: Exit;  // DISPID_UNKNOWN
    1900000201if Assigned(FOnEvent_AddTermin) then
         FOnEvent_AddTermin(Self);
    1900000202if Assigned(FOnEvent_ModifiedTermin) then
         FOnEvent_ModifiedTermin(Self);
    1900000203if Assigned(FOnEvent_RemoveTermin) then
         FOnEvent_RemoveTermin(Self);
  end{case DispID}
end;


Das unverständliche ist das die Meldung aus Assemly Dll kommt immer und auf biliebige maschine (XP, Vista mit Office 2007),
in Delphi jedoch nur auf Vista, auf XP still.

Ich gabe mit regasm Dll registrirt und exptlb TypeLibrary exportiert.

Ich kann es nicht nachvollziehen warum es auf XP maschinen nicht läuft?
Kennt jemant die ursache?