Click here to Skip to main content
15,566,522 members
Home / Discussions / COM
   

COM

 
Questionshell COM problems with Vista Pin
T800G12-Dec-09 10:59
T800G12-Dec-09 10:59 
AnswerRe: shell COM problems with Vista Pin
KarstenK14-Dec-09 23:39
mveKarstenK14-Dec-09 23:39 
GeneralRe: shell COM problems with Vista Pin
T800G15-Dec-09 10:59
T800G15-Dec-09 10:59 
GeneralRe: shell COM problems with Vista Pin
KarstenK15-Dec-09 21:28
mveKarstenK15-Dec-09 21:28 
GeneralRe: shell COM problems with Vista Pin
T800G20-Dec-09 12:02
T800G20-Dec-09 12:02 
GeneralRe: shell COM problems with Vista Pin
T800G25-Dec-09 8:17
T800G25-Dec-09 8:17 
QuestionHow to use collection object as interface method parameter in .NET Pin
Chiman111-Dec-09 18:41
Chiman111-Dec-09 18:41 
QuestionUnable to cast COM object of type 'magic.magicClass' to interface type 'magic.Dmagic'. Pin
Chrispie12310-Dec-09 0:27
Chrispie12310-Dec-09 0:27 
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
        Implements www.example.com.com.tibco.amx.sample.helloworld.simple.java.soa.IHelloWorldPT

        Dim log As System.Diagnostics.TraceSource

        Public Sub New()
            log = Funcs.ts
        End Sub

        Public Function sayHello(ByVal HelloRequest As String) As String Implements www.example.com.com.tibco.amx.sample.helloworld.simple.java.soa.IHelloWorldPT.sayHello

            Dim a1 As Integer = 1
            Dim b1 As Integer = 2

            Dim dllWrapper As New CallingMagicDLLWrapper.Class1
            dllWrapper.callMagicDLL(a1, b1)

            Return "dot net : " & Trim(Convert.ToString(b1))

        End Function
    End Class
End Namespace


I did implement
<STAThread()> _
On my main method in my class that calls the dll.

If I run the code as it is I get the following error. And I don’t seem to get pass that.

CallServiceImpl: Unable to cast COM object of type 'magic.magicClass' to interface type 'magic.Dmagic'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{F1556D77-4488-489D-8B1F-53FC0F7AC312}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).; on machine = DHN00807

Stack trace: at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&amp; msgData)
at magic.magicClass.magicdll(Int32 pMagicRequestXML, Int32&amp; prMagicResponseXML)
at CallingMagicDLLWrapper.CallWithMain.Main()
at CallingMagicDLLWrapper.Class1.callMagicDLL(Int32&amp; input, Int32&amp; output)
at ActiveMatrixComponent1.ActiveMatrixComponent1.HelloWorld_HelloWorldPTImpl.sayHello(String HelloRequest)


I read on the internet and it seems like I need to set the thread to STA.
If I try to set the current thread (in my wrapper class before I call the COM object)
Thread.CurrentThread.SetApartmentState(ApartmentState.STA)
I do get an error that it cannot be set. If I create my own thread and set the new thread state to STA it works but I don’t know how to get the data back once the thread is done. And if I do it this way and call it over and over (17 odd times) it falls over.

(I can call my .NET dll from the TIPCO app and send and retrieve data. But as soon as I call the .NET dll that calls the .NET wrapper dll that calls the COM object it falls over with the above error. I can call the above from a new windows application and then everything works but as soon as I call it from an outside .NET application I get the error).
Any suggestions please? It will help a lot.

Thanks
Chris
AnswerRe: Unable to cast COM object of type 'magic.magicClass' to interface type 'magic.Dmagic'. Pin
Richard MacCutchan10-Dec-09 3:35
mveRichard MacCutchan10-Dec-09 3:35 
AnswerRe: Unable to cast COM object of type 'magic.magicClass' to interface type 'magic.Dmagic'. Pin
KarstenK14-Dec-09 23:42
mveKarstenK14-Dec-09 23:42 
QuestionHow to hide one of the pins in the DirectShow Source Filter ? Pin
Raja Bose C Leo8-Dec-09 22:42
Raja Bose C Leo8-Dec-09 22:42 
QuestionExcel.exe is not getting killed implicitly Pin
KTTransfer7-Dec-09 19:40
KTTransfer7-Dec-09 19:40 
AnswerRe: Excel.exe is not getting killed implicitly Pin
serzh8316-Dec-09 6:21
serzh8316-Dec-09 6:21 
Questionusing interface Pin
Chiman15-Dec-09 2:09
Chiman15-Dec-09 2:09 
AnswerRe: using interface Pin
Jonathan Davies5-Dec-09 6:03
Jonathan Davies5-Dec-09 6:03 
AnswerRe: using interface Pin
«_Superman_»5-Dec-09 6:04
professional«_Superman_»5-Dec-09 6:04 
QuestionCalling Com object From C# to add 2 numbers Pin
Chrispie1232-Dec-09 8:47
Chrispie1232-Dec-09 8:47 
AnswerRe: Calling Com object From C# to add 2 numbers Pin
Chrispie1233-Dec-09 19:32
Chrispie1233-Dec-09 19:32 
AnswerRe: Calling Com object From C# to add 2 numbers Pin
KarstenK14-Dec-09 23:48
mveKarstenK14-Dec-09 23:48 
AnswerRe: Calling Com object From C# to add 2 numbers Pin
Md. Marufuzzaman15-Dec-09 5:04
professionalMd. Marufuzzaman15-Dec-09 5:04 
QuestionIs it possible to attach the manifest info to a dll for SxS? Pin
levinp29-Nov-09 22:41
levinp29-Nov-09 22:41 
QuestionUsing COM component invalid pointer error Pin
Ash_VCPP27-Nov-09 2:19
Ash_VCPP27-Nov-09 2:19 
AnswerRe: Using COM component invalid pointer error Pin
KarstenK27-Nov-09 2:34
mveKarstenK27-Nov-09 2:34 
GeneralRe: Using COM component invalid pointer error Pin
Ash_VCPP27-Nov-09 3:15
Ash_VCPP27-Nov-09 3:15 
AnswerRe: Using COM component invalid pointer error Pin
James Charlesworth27-Nov-09 3:24
James Charlesworth27-Nov-09 3:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.