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. COM
  4. Unable to cast COM object of type 'magic.magicClass' to interface type 'magic.Dmagic'.

Unable to cast COM object of type 'magic.magicClass' to interface type 'magic.Dmagic'.

Scheduled Pinned Locked Moved COM
csharpjavadotnetwcf
3 Posts 3 Posters 0 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.
  • C Offline
    C Offline
    Chrispie123
    wrote on last edited by
    #1

    Hi Everyone, I need help. My deadline is tomorrow and I have been at this for almost 2 weeks now. I need to call a com object from a C# or VB.NET dll that is called by a third party app (TIPCO). The com object takes in a string and returns a string. I have the following: 1. A .net dll that calls the com (my wrapper) 2. A .net dll that calls my wrapper dll and this is the entry point for calling applications (basically .net is my intermediary) (Please not when referring to a dll I am referring to a class library object) My Code looks as follows My C# dll that calls the com object (wrapper) I have a C# wrapper that calls the com object

    Public Class Class1
    Public Sub callMagicDLL(ByRef input As Integer, ByRef output As Integer)
    Dim myownClass As New CallWithMain()
    myownClass.Main()
    End Sub
    End Class

    Imports System.Runtime.CompilerServices
    Imports System.Runtime.InteropServices

    Public Class CallWithMain

    Dim a As Integer
    Dim b As Integer
    
    <STAThread()> \_
    Sub Main()
        Dim mymagicdll As New magic.magic       'Com object
        Dim a As Integer = 1
        Dim b As Integer = 1
        mymagicdll.magicdll(a, b)
    End Sub
    

    End Class

    Then another C# dll project to call the dll above, that consists of an interface and a class that implement it

    Option Strict Off
    Option Explicit On

    Imports com.tibco.matrix.clr
    Imports System
    Imports System.ComponentModel
    Imports System.Diagnostics
    Imports System.Web.Services
    Imports System.Xml.Serialization

    Namespace www.example.com.com.tibco.amx.sample.helloworld.simple.java.soa

    '''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.1433"), \_
     WebServiceInterface(MethodParameters:="InputMsg", PortTypeName:="HelloWorldPT", PortTypeNamespace:="http://www.example.com/com.tibco.amx.sample.helloworld.simple.java.soa/", WSDLLocation:="HelloWorld\_HelloWorldPT.wsdl")> \_
    Public Interface IHelloWorldPT
    
        '''<remarks/>    
        <System.Web.Services.WebMethodAttribute()> \_
        Function sayHello(<System.Xml.Serialization.XmlElementAttribute(\[Namespace\]:="http://ns.tibco.com/Hello/")> ByVal HelloRequest As String) As String
    End Interface
    

    End Namespace

    And then the class that implements the interface

    Imports com.tibco.matrix.clr

    Namespace ActiveMatrixComponent1
    <ServiceImplementation()> Public Class HelloWorld_HelloWorldPTImpl

    L K 2 Replies Last reply
    0
    • C Chrispie123

      Hi Everyone, I need help. My deadline is tomorrow and I have been at this for almost 2 weeks now. I need to call a com object from a C# or VB.NET dll that is called by a third party app (TIPCO). The com object takes in a string and returns a string. I have the following: 1. A .net dll that calls the com (my wrapper) 2. A .net dll that calls my wrapper dll and this is the entry point for calling applications (basically .net is my intermediary) (Please not when referring to a dll I am referring to a class library object) My Code looks as follows My C# dll that calls the com object (wrapper) I have a C# wrapper that calls the com object

      Public Class Class1
      Public Sub callMagicDLL(ByRef input As Integer, ByRef output As Integer)
      Dim myownClass As New CallWithMain()
      myownClass.Main()
      End Sub
      End Class

      Imports System.Runtime.CompilerServices
      Imports System.Runtime.InteropServices

      Public Class CallWithMain

      Dim a As Integer
      Dim b As Integer
      
      <STAThread()> \_
      Sub Main()
          Dim mymagicdll As New magic.magic       'Com object
          Dim a As Integer = 1
          Dim b As Integer = 1
          mymagicdll.magicdll(a, b)
      End Sub
      

      End Class

      Then another C# dll project to call the dll above, that consists of an interface and a class that implement it

      Option Strict Off
      Option Explicit On

      Imports com.tibco.matrix.clr
      Imports System
      Imports System.ComponentModel
      Imports System.Diagnostics
      Imports System.Web.Services
      Imports System.Xml.Serialization

      Namespace www.example.com.com.tibco.amx.sample.helloworld.simple.java.soa

      '''<remarks/>
      <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.1433"), \_
       WebServiceInterface(MethodParameters:="InputMsg", PortTypeName:="HelloWorldPT", PortTypeNamespace:="http://www.example.com/com.tibco.amx.sample.helloworld.simple.java.soa/", WSDLLocation:="HelloWorld\_HelloWorldPT.wsdl")> \_
      Public Interface IHelloWorldPT
      
          '''<remarks/>    
          <System.Web.Services.WebMethodAttribute()> \_
          Function sayHello(<System.Xml.Serialization.XmlElementAttribute(\[Namespace\]:="http://ns.tibco.com/Hello/")> ByVal HelloRequest As String) As String
      End Interface
      

      End Namespace

      And then the class that implements the interface

      Imports com.tibco.matrix.clr

      Namespace ActiveMatrixComponent1
      <ServiceImplementation()> Public Class HelloWorld_HelloWorldPTImpl

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Chris Tiaan wrote:

      My C# dll that calls the com object (wrapper) I have a C# wrapper that calls the com object

      I don't see any C# code here, it looks to me like Visual Basic. You might get better help posting this in the VB forum.

      1 Reply Last reply
      0
      • C Chrispie123

        Hi Everyone, I need help. My deadline is tomorrow and I have been at this for almost 2 weeks now. I need to call a com object from a C# or VB.NET dll that is called by a third party app (TIPCO). The com object takes in a string and returns a string. I have the following: 1. A .net dll that calls the com (my wrapper) 2. A .net dll that calls my wrapper dll and this is the entry point for calling applications (basically .net is my intermediary) (Please not when referring to a dll I am referring to a class library object) My Code looks as follows My C# dll that calls the com object (wrapper) I have a C# wrapper that calls the com object

        Public Class Class1
        Public Sub callMagicDLL(ByRef input As Integer, ByRef output As Integer)
        Dim myownClass As New CallWithMain()
        myownClass.Main()
        End Sub
        End Class

        Imports System.Runtime.CompilerServices
        Imports System.Runtime.InteropServices

        Public Class CallWithMain

        Dim a As Integer
        Dim b As Integer
        
        <STAThread()> \_
        Sub Main()
            Dim mymagicdll As New magic.magic       'Com object
            Dim a As Integer = 1
            Dim b As Integer = 1
            mymagicdll.magicdll(a, b)
        End Sub
        

        End Class

        Then another C# dll project to call the dll above, that consists of an interface and a class that implement it

        Option Strict Off
        Option Explicit On

        Imports com.tibco.matrix.clr
        Imports System
        Imports System.ComponentModel
        Imports System.Diagnostics
        Imports System.Web.Services
        Imports System.Xml.Serialization

        Namespace www.example.com.com.tibco.amx.sample.helloworld.simple.java.soa

        '''<remarks/>
        <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.1433"), \_
         WebServiceInterface(MethodParameters:="InputMsg", PortTypeName:="HelloWorldPT", PortTypeNamespace:="http://www.example.com/com.tibco.amx.sample.helloworld.simple.java.soa/", WSDLLocation:="HelloWorld\_HelloWorldPT.wsdl")> \_
        Public Interface IHelloWorldPT
        
            '''<remarks/>    
            <System.Web.Services.WebMethodAttribute()> \_
            Function sayHello(<System.Xml.Serialization.XmlElementAttribute(\[Namespace\]:="http://ns.tibco.com/Hello/")> ByVal HelloRequest As String) As String
        End Interface
        

        End Namespace

        And then the class that implements the interface

        Imports com.tibco.matrix.clr

        Namespace ActiveMatrixComponent1
        <ServiceImplementation()> Public Class HelloWorld_HelloWorldPTImpl

        K Offline
        K Offline
        KarstenK
        wrote on last edited by
        #3

        You are shure that 'magic.Dmagic' interface is implemented in the 'magic.magicClass'? Be shure that all components are created and running in the same Thread model or you never wont get rid of bad trouble. X|

        Press F1 for help or google it. Greetings from Germany

        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