Search Results

Search found 1 results on 1 pages for 'ijrufus'.

Page 1/1 | 1 

  • C# Casting system.__comobject to class type

    - by ijrufus
    I have an Excel Add-In that I'm currently trying to set up a unit test framework for. For the unit tests I've followed this guide: http://blogs.msdn.com/b/varsha/archive/2010/08/17/writing-automated-test-cases-for-vsto-application.aspx It seems to work fine, until I want to return a class object from my interface. Specifying the class object as the return type throws a "return argument has an invalid type" exception when calling the method. Changing the return type from the class to an object allows me to call the method and get the object, but now I'm unable to cast it as the class and use it as intended, getting this exception message when I try: > Unable to cast COM object of type 'System.__ComObject' to class type > 'anaplan.Utility.XYCoordinates'. Instances of types that represent COM > components cannot be cast to types that do not represent COM > components; however they can be cast to interfaces as long as the > underlying COM component supports QueryInterface calls for the IID of > the interface. I've retrieved the Type name using VisualBasic.Information.TypeName and it's showing it as the class I expect. Is there any way to get the comobject cast back to the class? Or another way to access the properties it has? Or am I just being a bit stupid here?

    Read the article

1