0

I have a piece of third-party software that is an out-of-process ActiveX server. This application was developed, I'm guessing, in VB6 and the documentation uses VB as the example client.

After fighting with C# to get this to work, I thought I would try it in VB.NET and, to my surprise, what seems like identical code in VB.NET works whereas in C# it does not.

The method in question has signature

short oleProvider.GiveMeGlobalDB(ref iGenericDB ptr)

The remaining interface types are defined in the ActiveX component.

VB.NET (This works!)

' defined in a module '
Public pWV As iGenericDB        ' Interface iGenericDB  '
Public pProvider As oleProvider ' Interface oleProvider '

' in a class '
Public Class clsWatView
    Public Sub StartUp()
        pProvider = New oleProvider  ' returns a COM object '            
        pProvider.GiveMeGlobalDb(pWV)        
        ' pWV gets interface pointer to COM object '
    End Sub    
End Class

C#

public static class clsWatView
{
    public static iGenericDB pWV;          // interface iGenericDB
    public static oleProvider pProvider;   // interface oleProvider

    static void StartUp()
    {
        pProvider = new oleProvider();  // This returns a COM object (OK)
        pProvider.GiveMeGlobalDb(pWV);  // executes, but pWV remains null
    }
}

My question is - What is different about these two pieces of code? VB.NET ends up with pWV pointing to a valid COM object and C# ends up with null. What is VB.NET doing differently from C# here?

2 Answers 2

3

I would try this:

pProvider.GiveMeGlobalDb(ref pWV);
Sign up to request clarification or add additional context in comments.

1 Comment

Of course. So obvious... Why do we catch these things so much more easily in other peoples' code! Thanks.
0

Maybe try a "out" keyword on C# ?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.