在一个VB.NET语言写的ASP.NET应用程序中,调用一个COM组件VB.NET中对应代码如下(对COM已经做过引用)
Dim Server As New XXX.Server
Dim myObject As New XXX.Object
Dim success As Booleansuccess = Server.Connect("localhost", 1234)
success = Server.Login("Name", "PWD")
success = myObject.DoSomething()问题是myObject一NEW出来就有错误
Description<error: an exception of type: {System.InvalidCastException} occurred>String
执行到success = myObject.DoSomething()后
抛出来的异常信息为QueryInterface for interface XXX.IOAObject failed. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: QueryInterface for interface XXX.IOAObject failed.不知道什么原因。

解决方案 »

  1.   

    除了添加引用,
    有没有打开命名空间: using ...;
      

  2.   

    除了添加引用,
    有没有打开命名空间: using ...;
    ////////////
    这个倒没有但是就算没打开命名空间,带上前缀一样可以用,只不过麻烦点
      

  3.   

    先添加引用,然后在代码中using,实例化想要的类,即可使用类下面的方法
      

  4.   

    现在是.NET 调用COM组件的问题,参考http://www.ddvip.net/web/aspnet/index2/10.htm
      

  5.   

    使用dcomcnfg
    找到COM组件
    设置ASPNET用户具有启动及执行的权限