PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Program Addins C# and New Inspector event

Reply

C# and New Inspector event

 
Thread Tools Rate Thread
Old 07-06-2007, 11:57 PM   #1
=?Utf-8?B?YnN0cnVt?=
Guest
 
Posts: n/a
Default C# and New Inspector event


Does anyone have code to capture the new inspector event from c# using late
binding? I need to be able to capture this event in an Office version
neutral way.

I put some code together but it fails on the advise method with an invalid
cast exception.

Guid guid = new Guid("{000????-0000-0000-C000-000000000046}");
UCOMIConnectionPointContainer oCPP = (UCOMIConnectionPointContainer)app;
oCPP.FindConnectionPoint(ref guid, out m_oConnectionPoint);
m_oConnectionPoint.Advise(this, out m_Cookie);

Thanks,

Benjamin Strum
ThinkTron Corp.
  Reply With Quote
Old 08-06-2007, 12:31 AM   #2
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: C# and New Inspector event

Your object must suppport the IDispatch and IInspectorEvents interfaces .

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"bstrum" <bstrum@discussions.microsoft.com> wrote in message
news:CE37D698-1611-41D4-AFD1-4E00606EFEE2@microsoft.com...
> Does anyone have code to capture the new inspector event from c# using
> late
> binding? I need to be able to capture this event in an Office version
> neutral way.
>
> I put some code together but it fails on the advise method with an invalid
> cast exception.
>
> Guid guid = new Guid("{000????-0000-0000-C000-000000000046}");
> UCOMIConnectionPointContainer oCPP = (UCOMIConnectionPointContainer)app;
> oCPP.FindConnectionPoint(ref guid, out m_oConnectionPoint);
> m_oConnectionPoint.Advise(this, out m_Cookie);
>
> Thanks,
>
> Benjamin Strum
> ThinkTron Corp.



  Reply With Quote
Old 08-06-2007, 02:52 PM   #3
=?Utf-8?B?YnN0cnVt?=
Guest
 
Posts: n/a
Default Re: C# and New Inspector event

Any code examples? I was using the SafeCOMWrapper from

http://www.codeproject.com/csharp/S...197#xx1214201xx

but it doesn't include Inspectors. I added the following but I am getting
invalid cast exception:

[ComEvents(typeof(InspectorsEventSink), InspectorsEventSink.InterfaceID)]
public interface IInspectorsEvents
{
event NewInspectorEventHandler NewInspector;
}

[
ComImport,
Guid(InspectorsEventSink.InterfaceID),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
TypeLibType(TypeLibTypeFlags.FDispatchable)
]
public interface UCOMIInspectorsEvents
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType =
MethodCodeType.Runtime), DispId(0xf001)]
void NewInspector(object NewInspector);
}

[ClassInterface(ClassInterfaceType.None)]
public sealed class InspectorsEventSink : ComEventSink,
UCOMIInspectorsEvents
{
internal const string InterfaceID =
"00063079-0000-0000-C000-000000000046";

static readonly object NewInspectorEvent = new object();

public void NewInspector(object NewInspector)
{
RaiseEvent(NewInspectorEvent, NewInspector);
}
}

public delegate void NewInspectorEventHandler(object NewInspector);

"Dmitry Streblechenko" wrote:

> Your object must suppport the IDispatch and IInspectorEvents interfaces .
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "bstrum" <bstrum@discussions.microsoft.com> wrote in message
> news:CE37D698-1611-41D4-AFD1-4E00606EFEE2@microsoft.com...
> > Does anyone have code to capture the new inspector event from c# using
> > late
> > binding? I need to be able to capture this event in an Office version
> > neutral way.
> >
> > I put some code together but it fails on the advise method with an invalid
> > cast exception.
> >
> > Guid guid = new Guid("{000????-0000-0000-C000-000000000046}");
> > UCOMIConnectionPointContainer oCPP = (UCOMIConnectionPointContainer)app;
> > oCPP.FindConnectionPoint(ref guid, out m_oConnectionPoint);
> > m_oConnectionPoint.Advise(this, out m_Cookie);
> >
> > Thanks,
> >
> > Benjamin Strum
> > ThinkTron Corp.

>
>
>

  Reply With Quote
Old 08-06-2007, 06:02 PM   #4
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: C# and New Inspector event

I have no idea how to do that in C#, sorry.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"bstrum" <bstrum@discussions.microsoft.com> wrote in message
news:7910661C-6950-4287-B786-4D344215707C@microsoft.com...
> Any code examples? I was using the SafeCOMWrapper from
>
> http://www.codeproject.com/csharp/S...197#xx1214201xx
>
> but it doesn't include Inspectors. I added the following but I am getting
> invalid cast exception:
>
> [ComEvents(typeof(InspectorsEventSink), InspectorsEventSink.InterfaceID)]
> public interface IInspectorsEvents
> {
> event NewInspectorEventHandler NewInspector;
> }
>
> [
> ComImport,
> Guid(InspectorsEventSink.InterfaceID),
> InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
> TypeLibType(TypeLibTypeFlags.FDispatchable)
> ]
> public interface UCOMIInspectorsEvents
> {
> [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType =
> MethodCodeType.Runtime), DispId(0xf001)]
> void NewInspector(object NewInspector);
> }
>
> [ClassInterface(ClassInterfaceType.None)]
> public sealed class InspectorsEventSink : ComEventSink,
> UCOMIInspectorsEvents
> {
> internal const string InterfaceID =
> "00063079-0000-0000-C000-000000000046";
>
> static readonly object NewInspectorEvent = new object();
>
> public void NewInspector(object NewInspector)
> {
> RaiseEvent(NewInspectorEvent, NewInspector);
> }
> }
>
> public delegate void NewInspectorEventHandler(object NewInspector);
>
> "Dmitry Streblechenko" wrote:
>
>> Your object must suppport the IDispatch and IInspectorEvents interfaces .
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "bstrum" <bstrum@discussions.microsoft.com> wrote in message
>> news:CE37D698-1611-41D4-AFD1-4E00606EFEE2@microsoft.com...
>> > Does anyone have code to capture the new inspector event from c# using
>> > late
>> > binding? I need to be able to capture this event in an Office version
>> > neutral way.
>> >
>> > I put some code together but it fails on the advise method with an
>> > invalid
>> > cast exception.
>> >
>> > Guid guid = new Guid("{000????-0000-0000-C000-000000000046}");
>> > UCOMIConnectionPointContainer oCPP =
>> > (UCOMIConnectionPointContainer)app;
>> > oCPP.FindConnectionPoint(ref guid, out m_oConnectionPoint);
>> > m_oConnectionPoint.Advise(this, out m_Cookie);
>> >
>> > Thanks,
>> >
>> > Benjamin Strum
>> > ThinkTron Corp.

>>
>>
>>



  Reply With Quote
Old 08-06-2007, 10:31 PM   #5
Ken Slovak - [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: C# and New Inspector event

Helmut Obertanner has an Inspector wrapper example in C# up on
www.outlookcode.com.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message
news:efHLc5eqHHA.5092@TK2MSFTNGP04.phx.gbl...
>I have no idea how to do that in C#, sorry.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool


  Reply With Quote
Old 09-06-2007, 12:27 AM   #6
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: C# and New Inspector event

But it still requires an interop; the original question was about doing COM
event sinking using the low level COM API (IConnectionPointContainer,
IConnectionPoint, etc).
But I can't imagine why the lowest Outlook version interop (2000?) cannot be
used instead...

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Ken Slovak - [MVP - Outlook]" <kenslovak@mvps.org> wrote in message
news:uqQTPShqHHA.1212@TK2MSFTNGP05.phx.gbl...
> Helmut Obertanner has an Inspector wrapper example in C# up on
> www.outlookcode.com.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message
> news:efHLc5eqHHA.5092@TK2MSFTNGP04.phx.gbl...
>>I have no idea how to do that in C#, sorry.
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool

>



  Reply With Quote
Old 11-06-2007, 05:10 PM   #7
=?Utf-8?B?YnN0cnVt?=
Guest
 
Posts: n/a
Default Re: C# and New Inspector event

Does anyone know how to do this? We have spent a lot of time making our code
version independent using late binding. We now need to be able to hook into
the newinspector event.

Here is some more code that I am trying. Right now, it throws an
InvalidCast exception on m_oConnectionPoint.Advise(this, out m_Cookie).

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;


using ThinkTron.Email.Common;
using MO = ManagedOffice;
using MSWord = ManagedOffice.Word;
using MSOutlook = ManagedOffice.Outlook;

namespace SSNProtector
{
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
GuidAttribute("00063079-0000-0000-c000-000000000046")]
public interface DInspectorEvents
{
void NewInspector([MarshalAs(UnmanagedType.Struct)]object
NewInspector);
}

class InspectorEventHelper : IDisposable, DInspectorEvents
{
public InspectorEventHelper()
{
m_oConnectionPoint = null;
m_Cookie = 0;
}

private IConnectionPoint m_oConnectionPoint;
private int m_Cookie;

public void SetupConnection(object Inspectors)
{
if (m_Cookie != 0) return;
try
{
Guid guid = new
Guid("{00063079-0000-0000-c000-000000000046}");

IConnectionPointContainer oCPP =
(IConnectionPointContainer)Inspectors;
oCPP.FindConnectionPoint(ref guid, out m_oConnectionPoint);

m_oConnectionPoint.Advise(this, out m_Cookie);

}
catch (Exception exc)
{
Log.Write(exc.Message);
}
}

public void RemoveConnection()
{
if (m_Cookie != 0)
{
m_oConnectionPoint.Unadvise(m_Cookie);
m_oConnectionPoint = null;
m_Cookie = 0;
}
}

#region IDisposable Members

public void Dispose()
{
RemoveConnection();
}

#endregion

//#region DOutlookApplicationEvents_10 Members
[DispId(0xF001)]
public void NewInspector([MarshalAs(UnmanagedType.Struct)]object
NewInspector)
{
}
}
}


"Dmitry Streblechenko" wrote:

> But it still requires an interop; the original question was about doing COM
> event sinking using the low level COM API (IConnectionPointContainer,
> IConnectionPoint, etc).
> But I can't imagine why the lowest Outlook version interop (2000?) cannot be
> used instead...
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "Ken Slovak - [MVP - Outlook]" <kenslovak@mvps.org> wrote in message
> news:uqQTPShqHHA.1212@TK2MSFTNGP05.phx.gbl...
> > Helmut Obertanner has an Inspector wrapper example in C# up on
> > www.outlookcode.com.
> >
> > --
> > Ken Slovak
> > [MVP - Outlook]
> > http://www.slovaktech.com
> > Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> > Reminder Manager, Extended Reminders, Attachment Options
> > http://www.slovaktech.com/products.htm
> >
> >
> > "Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message
> > news:efHLc5eqHHA.5092@TK2MSFTNGP04.phx.gbl...
> >>I have no idea how to do that in C#, sorry.
> >>
> >> Dmitry Streblechenko (MVP)
> >> http://www.dimastr.com/
> >> OutlookSpy - Outlook, CDO
> >> and MAPI Developer Tool

> >

>
>
>

  Reply With Quote
Old 11-06-2007, 05:57 PM   #8
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: C# and New Inspector event

Again, *why* do you need to do that from the scratch?
Create an interop using the lowest version of Outlook that you are planning
to support (Outlook 2000?); then you will need to use late binding only for
the features not supported by that version.
Otherwise C# is not the best tool for the task i am afraid.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"bstrum" <bstrum@discussions.microsoft.com> wrote in message
news:87EE4796-87D1-4D5B-9509-34E86F23A796@microsoft.com...
> Does anyone know how to do this? We have spent a lot of time making our
> code
> version independent using late binding. We now need to be able to hook
> into
> the newinspector event.
>
> Here is some more code that I am trying. Right now, it throws an
> InvalidCast exception on m_oConnectionPoint.Advise(this, out m_Cookie).
>
> using System;
> using System.Runtime.CompilerServices;
> using System.Runtime.InteropServices;
> using System.Runtime.InteropServices.ComTypes;
>
>
> using ThinkTron.Email.Common;
> using MO = ManagedOffice;
> using MSWord = ManagedOffice.Word;
> using MSOutlook = ManagedOffice.Outlook;
>
> namespace SSNProtector
> {
> [InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
> GuidAttribute("00063079-0000-0000-c000-000000000046")]
> public interface DInspectorEvents
> {
> void NewInspector([MarshalAs(UnmanagedType.Struct)]object
> NewInspector);
> }
>
> class InspectorEventHelper : IDisposable, DInspectorEvents
> {
> public InspectorEventHelper()
> {
> m_oConnectionPoint = null;
> m_Cookie = 0;
> }
>
> private IConnectionPoint m_oConnectionPoint;
> private int m_Cookie;
>
> public void SetupConnection(object Inspectors)
> {
> if (m_Cookie != 0) return;
> try
> {
> Guid guid = new
> Guid("{00063079-0000-0000-c000-000000000046}");
>
> IConnectionPointContainer oCPP =
> (IConnectionPointContainer)Inspectors;
> oCPP.FindConnectionPoint(ref guid, out m_oConnectionPoint);
>
> m_oConnectionPoint.Advise(this, out m_Cookie);
>
> }
> catch (Exception exc)
> {
> Log.Write(exc.Message);
> }
> }
>
> public void RemoveConnection()
> {
> if (m_Cookie != 0)
> {
> m_oConnectionPoint.Unadvise(m_Cookie);
> m_oConnectionPoint = null;
> m_Cookie = 0;
> }
> }
>
> #region IDisposable Members
>
> public void Dispose()
> {
> RemoveConnection();
> }
>
> #endregion
>
> //#region DOutlookApplicationEvents_10 Members
> [DispId(0xF001)]
> public void NewInspector([MarshalAs(UnmanagedType.Struct)]object
> NewInspector)
> {
> }
> }
> }
>
>
> "Dmitry Streblechenko" wrote:
>
>> But it still requires an interop; the original question was about doing
>> COM
>> event sinking using the low level COM API (IConnectionPointContainer,
>> IConnectionPoint, etc).
>> But I can't imagine why the lowest Outlook version interop (2000?) cannot
>> be
>> used instead...
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "Ken Slovak - [MVP - Outlook]" <kenslovak@mvps.org> wrote in message
>> news:uqQTPShqHHA.1212@TK2MSFTNGP05.phx.gbl...
>> > Helmut Obertanner has an Inspector wrapper example in C# up on
>> > www.outlookcode.com.
>> >
>> > --
>> > Ken Slovak
>> > [MVP - Outlook]
>> > http://www.slovaktech.com
>> > Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
>> > Reminder Manager, Extended Reminders, Attachment Options
>> > http://www.slovaktech.com/products.htm
>> >
>> >
>> > "Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message
>> > news:efHLc5eqHHA.5092@TK2MSFTNGP04.phx.gbl...
>> >>I have no idea how to do that in C#, sorry.
>> >>
>> >> Dmitry Streblechenko (MVP)
>> >> http://www.dimastr.com/
>> >> OutlookSpy - Outlook, CDO
>> >> and MAPI Developer Tool
>> >

>>
>>
>>



  Reply With Quote
Old 11-06-2007, 08:32 PM   #9
=?Utf-8?B?YnN0cnVt?=
Guest
 
Posts: n/a
Default Re: C# and New Inspector event

Do I need to add a reference to the 2000 PIA? If so, then my installer will
include it, right? We had problems in the early release of our addin when
including any of the PIAs because the addin would just not load correctly on
certain office versions. This was extremely difficult to debug and I would
rather not compromise all the work we have done to solve the load issues.

If I do not need to include the PIA / add a reference, is there a way to
generate my own c# wrapper for this specific event?

Thank you,

Benjamin Strum
ThinkTron Corp.

"Dmitry Streblechenko" wrote:

> Again, *why* do you need to do that from the scratch?
> Create an interop using the lowest version of Outlook that you are planning
> to support (Outlook 2000?); then you will need to use late binding only for
> the features not supported by that version.
> Otherwise C# is not the best tool for the task i am afraid.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "bstrum" <bstrum@discussions.microsoft.com> wrote in message
> news:87EE4796-87D1-4D5B-9509-34E86F23A796@microsoft.com...
> > Does anyone know how to do this? We have spent a lot of time making our
> > code
> > version independent using late binding. We now need to be able to hook
> > into
> > the newinspector event.
> >
> > Here is some more code that I am trying. Right now, it throws an
> > InvalidCast exception on m_oConnectionPoint.Advise(this, out m_Cookie).
> >
> > using System;
> > using System.Runtime.CompilerServices;
> > using System.Runtime.InteropServices;
> > using System.Runtime.InteropServices.ComTypes;
> >
> >
> > using ThinkTron.Email.Common;
> > using MO = ManagedOffice;
> > using MSWord = ManagedOffice.Word;
> > using MSOutlook = ManagedOffice.Outlook;
> >
> > namespace SSNProtector
> > {
> > [InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
> > GuidAttribute("00063079-0000-0000-c000-000000000046")]
> > public interface DInspectorEvents
> > {
> > void NewInspector([MarshalAs(UnmanagedType.Struct)]object
> > NewInspector);
> > }
> >
> > class InspectorEventHelper : IDisposable, DInspectorEvents
> > {
> > public InspectorEventHelper()
> > {
> > m_oConnectionPoint = null;
> > m_Cookie = 0;
> > }
> >
> > private IConnectionPoint m_oConnectionPoint;
> > private int m_Cookie;
> >
> > public void SetupConnection(object Inspectors)
> > {
> > if (m_Cookie != 0) return;
> > try
> > {
> > Guid guid = new
> > Guid("{00063079-0000-0000-c000-000000000046}");
> >
> > IConnectionPointContainer oCPP =
> > (IConnectionPointContainer)Inspectors;
> > oCPP.FindConnectionPoint(ref guid, out m_oConnectionPoint);
> >
> > m_oConnectionPoint.Advise(this, out m_Cookie);
> >
> > }
> > catch (Exception exc)
> > {
> > Log.Write(exc.Message);
> > }
> > }
> >
> > public void RemoveConnection()
> > {
> > if (m_Cookie != 0)
> > {
> > m_oConnectionPoint.Unadvise(m_Cookie);
> > m_oConnectionPoint = null;
> > m_Cookie = 0;
> > }
> > }
> >
> > #region IDisposable Members
> >
> > public void Dispose()
> > {
> > RemoveConnection();
> > }
> >
> > #endregion
> >
> > //#region DOutlookApplicationEvents_10 Members
> > [DispId(0xF001)]
> > public void NewInspector([MarshalAs(UnmanagedType.Struct)]object
> > NewInspector)
> > {
> > }
> > }
> > }
> >
> >
> > "Dmitry Streblechenko" wrote:
> >
> >> But it still requires an interop; the original question was about doing
> >> COM
> >> event sinking using the low level COM API (IConnectionPointContainer,
> >> IConnectionPoint, etc).
> >> But I can't imagine why the lowest Outlook version interop (2000?) cannot
> >> be
> >> used instead...
> >>
> >> Dmitry Streblechenko (MVP)
> >> http://www.dimastr.com/
> >> OutlookSpy - Outlook, CDO
> >> and MAPI Developer Tool
> >>
> >> "Ken Slovak - [MVP - Outlook]" <kenslovak@mvps.org> wrote in message
> >> news:uqQTPShqHHA.1212@TK2MSFTNGP05.phx.gbl...
> >> > Helmut Obertanner has an Inspector wrapper example in C# up on
> >> > www.outlookcode.com.
> >> >
> >> > --
> >> > Ken Slovak
> >> > [MVP - Outlook]
> >> > http://www.slovaktech.com
> >> > Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> >> > Reminder Manager, Extended Reminders, Attachment Options
> >> > http://www.slovaktech.com/products.htm
> >> >
> >> >
> >> > "Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message
> >> > news:efHLc5eqHHA.5092@TK2MSFTNGP04.phx.gbl...
> >> >>I have no idea how to do that in C#, sorry.
> >> >>
> >> >> Dmitry Streblechenko (MVP)
> >> >> http://www.dimastr.com/
> >> >> OutlookSpy - Outlook, CDO
> >> >> and MAPI Developer Tool
> >> >
> >>
> >>
> >>

>
>
>

  Reply With Quote
Old 11-06-2007, 09:28 PM   #10
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: C# and New Inspector event

As long as you arae developing on an Outlook 2000 machine where the interop
is built, you shoudld be Ok.
As long as your addin is running under teh version of fOutlook equal to or
greater thaan thee one you used to create the PIA, your add-in will load
just fine.
If you do not add a PIA, your only options is doing the raw COM events using
IConnectionPointContainer, IConnectionPoint, etc.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"bstrum" <bstrum@discussions.microsoft.com> wrote in message
news:8C30A359-27EE-486E-A7CC-F9C7D496C455@microsoft.com...
> Do I need to add a reference to the 2000 PIA? If so, then my installer
> will
> include it, right? We had problems in the early release of our addin when
> including any of the PIAs because the addin would just not load correctly
> on
> certain office versions. This was extremely difficult to debug and I
> would
> rather not compromise all the work we have done to solve the load issues.
>
> If I do not need to include the PIA / add a reference, is there a way to
> generate my own c# wrapper for this specific event?
>
> Thank you,
>
> Benjamin Strum
> ThinkTron Corp.
>
> "Dmitry Streblechenko" wrote:
>
>> Again, *why* do you need to do that from the scratch?
>> Create an interop using the lowest version of Outlook that you are
>> planning
>> to support (Outlook 2000?); then you will need to use late binding only
>> for
>> the features not supported by that version.
>> Otherwise C# is not the best tool for the task i am afraid.
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "bstrum" <bstrum@discussions.microsoft.com> wrote in message
>> news:87EE4796-87D1-4D5B-9509-34E86F23A796@microsoft.com...
>> > Does anyone know how to do this? We have spent a lot of time making
>> > our
>> > code
>> > version independent using late binding. We now need to be able to hook
>> > into
>> > the newinspector event.
>> >
>> > Here is some more code that I am trying. Right now, it throws an
>> > InvalidCast exception on m_oConnectionPoint.Advise(this, out m_Cookie).
>> >
>> > using System;
>> > using System.Runtime.CompilerServices;
>> > using System.Runtime.InteropServices;
>> > using System.Runtime.InteropServices.ComTypes;
>> >
>> >
>> > using ThinkTron.Email.Common;
>> > using MO = ManagedOffice;
>> > using MSWord = ManagedOffice.Word;
>> > using MSOutlook = ManagedOffice.Outlook;
>> >
>> > namespace SSNProtector
>> > {
>> > [InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
>> > GuidAttribute("00063079-0000-0000-c000-000000000046")]
>> > public interface DInspectorEvents
>> > {
>> > void NewInspector([MarshalAs(UnmanagedType.Struct)]object
>> > NewInspector);
>> > }
>> >
>> > class InspectorEventHelper : IDisposable, DInspectorEvents
>> > {
>> > public InspectorEventHelper()
>> > {
>> > m_oConnectionPoint = null;
>> > m_Cookie = 0;
>> > }
>> >
>> > private IConnectionPoint m_oConnectionPoint;
>> > private int m_Cookie;
>> >
>> > public void SetupConnection(object Inspectors)
>> > {
>> > if (m_Cookie != 0) return;
>> > try
>> > {
>> > Guid guid = new
>> > Guid("{00063079-0000-0000-c000-000000000046}");
>> >
>> > IConnectionPointContainer oCPP =
>> > (IConnectionPointContainer)Inspectors;
>> > oCPP.FindConnectionPoint(ref guid, out
>> > m_oConnectionPoint);
>> >
>> > m_oConnectionPoint.Advise(this, out m_Cookie);
>> >
>> > }
>> > catch (Exception exc)
>> > {
>> > Log.Write(exc.Message);
>> > }
>> > }
>> >
>> > public void RemoveConnection()
>> > {
>> > if (m_Cookie != 0)
>> > {
>> > m_oConnectionPoint.Unadvise(m_Cookie);
>> > m_oConnectionPoint = null;
>> > m_Cookie = 0;
>> > }
>> > }
>> >
>> > #region IDisposable Members
>> >
>> > public void Dispose()
>> > {
>> > RemoveConnection();
>> > }
>> >
>> > #endregion
>> >
>> > //#region DOutlookApplicationEvents_10 Members
>> > [DispId(0xF001)]
>> > public void NewInspector([MarshalAs(UnmanagedType.Struct)]object
>> > NewInspector)
>> > {
>> > }
>> > }
>> > }
>> >
>> >
>> > "Dmitry Streblechenko" wrote:
>> >
>> >> But it still requires an interop; the original question was about
>> >> doing
>> >> COM
>> >> event sinking using the low level COM API (IConnectionPointContainer,
>> >> IConnectionPoint, etc).
>> >> But I can't imagine why the lowest Outlook version interop (2000?)
>> >> cannot
>> >> be
>> >> used instead...
>> >>
>> >> Dmitry Streblechenko (MVP)
>> >> http://www.dimastr.com/
>> >> OutlookSpy - Outlook, CDO
>> >> and MAPI Developer Tool
>> >>
>> >> "Ken Slovak - [MVP - Outlook]" <kenslovak@mvps.org> wrote in message
>> >> news:uqQTPShqHHA.1212@TK2MSFTNGP05.phx.gbl...
>> >> > Helmut Obertanner has an Inspector wrapper example in C# up on
>> >> > www.outlookcode.com.
>> >> >
>> >> > --
>> >> > Ken Slovak
>> >> > [MVP - Outlook]
>> >> > http://www.slovaktech.com
>> >> > Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
>> >> > Reminder Manager, Extended Reminders, Attachment Options
>> >> > http://www.slovaktech.com/products.htm
>> >> >
>> >> >
>> >> > "Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message
>> >> > news:efHLc5eqHHA.5092@TK2MSFTNGP04.phx.gbl...
>> >> >>I have no idea how to do that in C#, sorry.
>> >> >>
>> >> >> Dmitry Streblechenko (MVP)
>> >> >> http://www.dimastr.com/
>> >> >> OutlookSpy - Outlook, CDO
>> >> >> and MAPI Developer Tool
>> >> >
>> >>
>> >>
>> >>

>>
>>
>>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off