Hi,

The exception is probably thrown at
> XBookmarksSupplier xBookmarksSupplier = (XBookmarksSupplier)mxDocument;

because your mxDocument object does not have this XBookmarkSupplier interface. Make sure that the mxDocument interface belongs to an object that also implements XBookmarksSupplier interface.


Regards,
Jochen


Florian Limberger wrote:
Hi,

While executing the last line of
--------------------------------------------------------------------------
XBookmarksSupplier xBookmarksSupplier = (XBookmarksSupplier)mxDocument;
XNameAccess xNamedBookmarks = xBookmarksSupplier.getBookmarks();

if (xNamedBookmarks.hasByName("test"))
{
  Object bookmark = xNamedBookmarks.getByName("test");
}
--------------------------------------------------------------------------
an System.InvalidCastException is thrown.

An unhandled exception of type 'System.InvalidCastException' occurred in
mscorlib.dll.

I'm rather new to UNO and have no idea what's wrong here. The "test" bookmark exists of course. Even looping through the xNamedBookmarks elements properly yields all bookmarks, contained in the textDocument.

thx for any hints,
Flo

using OpenOffice.org 1.9.79 with .NETv1.1.4322.

stackTrace:
--------------------------------------------------------------------------
System.InvalidCastException: Das R�ckgabeargument hat einen ung�ltigen Typ.
   at
System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg, Ty
pe paramType)
   at
System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage
msg, Object[] outArgs, Object returnValue)
   at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
   at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
   at unoidl.com.sun.star.container.XNameAccess.getByName(String aName)
   at OOTest.TextDocTest.Test() in
d:\media\develop\ootest\textdoctest.cs:line 8
8
   at
System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg, Ty
pe paramType)
   at
System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage
msg, Object[] outArgs, Object returnValue)
   at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
   at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
   at unoidl.com.sun.star.container.XNameAccess.getByName(String aName)
   at OOTest.TextDocTest.Test() in
d:\media\develop\ootest\textdoctest.cs:line 8
8


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to