By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,148 Members | 774 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,148 IT Pros & Developers. It's quick & easy.

Unable to cast object of type System.__ComObject

P: n/a
In a Distributed Windows application, I receive the following message when
the client calls the server:

************** Exception Text **************
System.InvalidCastException: Unable to cast object of type
System.__ComObject to type System.Data.DataSet.

Server stack trace:
at servidor.IclaseSvr.prueba2(DataSet ds)
at
System.Runtime.Remoting.Messaging.StackBuilderSink .PrivateProcessMessage(MethodBase
mb, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext,
Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink .SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData&
msgData, Int32 type)
at servidor.claseSvr.prueba2(DataSet ds)
at cliente.frmPrincipal.Button1_Click(Object sender, EventArgs e) in
d:\My Documents\Visual Studio
Projects\ErrorComObject\cliente\frmPrincipal.vb:li ne 113
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

However, if the Application COM's identity is the same that the client's
user ID, all works fine.

My server code is:

<SecureMethod()> _
Public Class claseSvr
Inherits ServicedComponent
Implements IclaseSvr

Public Sub prueba2(ByVal ds As DataSet) _
Implements IclaseSvr.prueba2
'<My Code Here>
End Sub

End Class

Public Interface IclaseSvr
Sub prueba2(ByVal ds As DataSet)
End Interface
My Client code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim svr As New servidor.claseSvr
Dim ds As DataSet

ds = New DataSet
'<some code>
svr.prueba2(ds)
End Sub
Some guess?

Thanks,

Fidias Gil de Montes

Sep 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.