Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2005

Tip: Looking for answers? Try searching our database.

custom IOleUndoManager crashing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
- 19 Jan 2005 19:23 GMT
Hi i have an application hosting webbrowser control in design mode. I also
wrote a custom OleUndoManger. My problem is if I move or resize a html
element the application crashes. With NullPointerException.

Can anybody check if the definition is correct?

TIA dom

Please respond on
    d-dot-mohl-at-hico-dot-com

Here is my definition of the ole interfaces:

[ComVisible(true), Guid("B3E7C340-EF97-11CE-9BC9-00AA00608E01"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEnumOleUndoUnits {
   [return: MarshalAs(UnmanagedType.I4)]
   [PreserveSig]
   int Next(
   [In, MarshalAs(UnmanagedType.U4)]
   int numDesired,
   [Out, MarshalAs(UnmanagedType.Interface)]
   out IOleUndoUnit unit,
   [Out, MarshalAs(UnmanagedType.U4)]
   out int numReceived);

[PreserveSig]
int Skip(
   [In, MarshalAs(UnmanagedType.I4)]
   int numToSkip);

[PreserveSig]
   int Reset();

[PreserveSig]
int Clone(
   [Out, MarshalAs(UnmanagedType.Interface)]
   out IEnumOleUndoUnits enumerator);
};

[ComVisible(true), Guid("A1FAF330-EF97-11CE-9BC9-00AA00608E01"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleParentUndoUnit : IOleUndoUnit {
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int Open(
[In, MarshalAs(UnmanagedType.Interface)]
IOleParentUndoUnit parentUnit);
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int Close(
[In, MarshalAs(UnmanagedType.Interface)]
IOleParentUndoUnit parentUnit,
[In, MarshalAs(UnmanagedType.Bool)]
bool fCommit);
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int Add(
[In, MarshalAs(UnmanagedType.Interface)]
IOleUndoUnit undoUnit);
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int FindUnit(
[In, MarshalAs(UnmanagedType.Interface)]
IOleUndoUnit undoUnit);
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int GetParentState(
[Out, MarshalAs(UnmanagedType.I4)]
out int state
);
}
[ComVisible(true), ComImport(),
Guid("6D5140C1-7436-11CE-8034-00AA006009FA"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleServiceProvider {
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int QueryService(
[In] ref Guid guidService,
[In] ref Guid riid,
out IntPtr ppvObject);
}
[ComVisible(true), Guid("D001F200-EF97-11CE-9BC9-00AA00608E01"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleUndoManager {
[PreserveSig]
int Open(
[In, MarshalAs(UnmanagedType.Interface)]
IOleParentUndoUnit parentUndo);
[PreserveSig]
int Close(
[In, MarshalAs(UnmanagedType.Interface)]
IOleParentUndoUnit parentUndo,
[In, MarshalAs(UnmanagedType.Bool)]
bool fCommit);
[PreserveSig]
int Add(
[In, MarshalAs(UnmanagedType.Interface)]
IOleUndoUnit undoUnit);
[return: MarshalAs(UnmanagedType.I4)]
int GetOpenParentState();
[PreserveSig]
int DiscardFrom(
[In, MarshalAs(UnmanagedType.Interface)]
IOleUndoUnit undoUnit);
void UndoTo(
[In, MarshalAs(UnmanagedType.Interface)]
IOleUndoUnit undoUnit);
void RedoTo(
[In, MarshalAs(UnmanagedType.Interface)]
IOleUndoUnit undoUnit);
[return: MarshalAs(UnmanagedType.Interface)]
IEnumOleUndoUnits EnumUndoable();
[return: MarshalAs(UnmanagedType.Interface)]
IEnumOleUndoUnits EnumRedoable();
[return: MarshalAs(UnmanagedType.BStr)]
string GetLastUndoDescription();
[return: MarshalAs(UnmanagedType.BStr)]
string GetLastRedoDescription();
void Enable(
[In, MarshalAs(UnmanagedType.Bool)]
bool fEnable);
}
[ComVisible(true), Guid("894AD3B0-EF97-11CE-9BC9-00AA00608E01"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleUndoUnit {
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int Do(
[In, MarshalAs(UnmanagedType.Interface)]
IOleUndoManager undoManager);
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int GetDescription(
[Out, MarshalAs(UnmanagedType.BStr)]
out string bStr);
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int GetUnitType(
[Out]
out Guid clsid,
[Out, MarshalAs(UnmanagedType.I4)]
out int plID);
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int OnNextAdd();
}
Mattias Sj?gren - 19 Jan 2005 21:31 GMT
>[ComVisible(true), Guid("B3E7C340-EF97-11CE-9BC9-00AA00608E01"),
>InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[quoted text clipped - 8 lines]
>    [Out, MarshalAs(UnmanagedType.U4)]
>    out int numReceived);

Since it's legal to pass a NULL pointer for numRecieved, you should
declare the last parameter as an IntPtr passed by value. You can then
write the number of returned elements with Marshal.WriteInt32().

>[ComVisible(true), Guid("A1FAF330-EF97-11CE-9BC9-00AA00608E01"),
>InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
>public interface IOleParentUndoUnit : IOleUndoUnit {

Interface inheritance doesn't work as you expect with COM interop.
IOleParentUndoUnit must redeclare all methods from the IOleUndoUnit
interface.

And finally, you ought to mark these interfaces with the ComImport
attribute.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.