Unable to cast COM object of type 'magic.magicClass' to interface type 'magic.Dmagic'.
-
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 ClassImports System.Runtime.CompilerServices
Imports System.Runtime.InteropServicesPublic 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 OnImports com.tibco.matrix.clr
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Xml.SerializationNamespace 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 -
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 ClassImports System.Runtime.CompilerServices
Imports System.Runtime.InteropServicesPublic 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 OnImports com.tibco.matrix.clr
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Xml.SerializationNamespace 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 -
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 ClassImports System.Runtime.CompilerServices
Imports System.Runtime.InteropServicesPublic 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 OnImports com.tibco.matrix.clr
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Xml.SerializationNamespace 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_HelloWorldPTImplYou 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