Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. calling COM objects within .NET C#

calling COM objects within .NET C#

Scheduled Pinned Locked Moved C#
helpcsharpquestiondotnetvisual-studio
1 Posts 1 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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??

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups