madinewala

madinewala

  • NA
  • 164
  • 0

Error returning DataSet from COM+ DLL in C#

Dec 20 2003 8:13 AM
I got a typical error using COM+. I have a COM+ DLL - derived from ServicedComponents, IMYInterface. This DLL has a public method GetRecords(), that returns a DataSet. Now I have a client application, a Windows App in C#. Within this, I try calling GetRecords() method of my DLL. IDBLibrary cdl; cdl = new CDBLibrary(); DataSet ds = cdl.GetRecords(); /*here IDBLibrary is my COM+ DLL name*/ Now when I debug the control creates an object of my COM+ DLL, but when it comes to cdl.GetRecords(), it gives the following error --------------------------- --------------------------- System.InvalidCastException: Return argument has an invalid type. at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object arg, Type paramType) at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage msg, Object[] outArgs, Object returnValue) at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at DBLibrary.IDBLibrary.GetRecords() at useDBLibrary.Form1.button1_Click(Object sender, EventArgs e) in d:\interlogix\r & d\20dec03\usedblibrary\form1.cs:line 96 --------------------------- OK --------------------------- Inorder to make sure that I do not have any error within my code, I have written a simple COM application in C# itself without using any interfaces... I tried to return the dataset from this simple dll and it works fine. Can someone help me out in sorting this error?? I guess there might be some special mechanism to fetch the return value from the COM+ DLL