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