calling COM objects within .NET C#
-
I'm in the process of trying to call our Verity COM object from within a .NET c# class. I successfully made a reference to the COM object from within VS.NET, and it seems to have worked in that I can see the methods and properties of the object. (from my reading, my adding a reference from VS.NET, it automatically takes care of creating the metadata necessary to call the COM object from within .NET as opposed to running the command line tlbimp.exe) I am also able to create the object, and set some properties....however when trying to set some one object type to another, the compiler will not let me do it. For example: The Verity Object has a Vsearch class. A method in the vsearch class is called "GetResults()". The docs say it returns a "Result" Object. So in my code, I create a Search object, a Result object, and then try to set my result object to the contents...like this VerityIS.Vsearch mysearch = new VerityIS.Vsearch(); VerityIS.Result myresult = new VerityIS.Result(); ...set some parametes for searching on mysearch, then execute the GetResults() method. myresult = mysearch.Getresult(); The compiler complains that you cannot implicitly convert type "Object" to "VerityIS.Result"....meaning it sees the mysearch.Getresult() as returning just an "Object" type. So then I try to use explicit casting..... myresult = (VerityIS.Result)mysearch.GetResult(); The compiler let's me do this, without a problem. However, when I call this from within a ASP+ page, I get the InvalidCastException error message. My question is, Is this a bug? Or, is there someway for me to identify the mysearch.Getresult() as the type of "VerityIS.Result" to the .NET framework??