Accessing and using managed Struct from COM

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Mortimer Schnurd (fugetaboutit_at_hotsmail.com)
Date: 12/13/04


Date: Mon, 13 Dec 2004 16:59:13 -0500

I have a simple Struct in a C# assembly which I would like to use in a
VB6 application. If the Struct contains only int types, VB6 has no
problem referencing the fields and intellisense picks them up fine.
However, as soon as I add a string type to the C# struct, VB6 can no
longer "see" any of the fields.

How do I get VB6 to "see" the struct when it contains string types?

Example Code that works:
public struct MyStruct
{
        int x;
        int y:
}

Example Code that doesn't work:
public struct MyStruct
{
        int x;
        int y;
        string zText;
}

--
Regards,
John Wood a.k.a Mortimer Schnurd
johnp.wood@dropthistaggmail.com
(to reply: remove "dropthistag")


Relevant Pages

  • Re: VB6 Types
    ... >> Define a class or struct. ... >> vb6 programmers is hard to understand at first. ... >>> Dim Name as String ... >>>Dim iTags() as Tags ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: VB6 Types
    ... Define a class or struct. ... Then define an array or any kind of list with the type of the class or ... Struct is the equivalent to Type in vb6. ... > Dim Name as String ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Forcing WS to return DS with empty fields...
    ... that when i return the ds, vb6 crashes... ... i know that i can return a xml using the ds.GetXml method... ... Then, for each table that has no parent, keep a List, where T is the type of the corresponding struct. ... just fill in your pseudo-DataSet by copying into it from the real DataSet. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Mashaling a VB6 Array Of Struct to C# Array of Struct
    ... Is it possible to convert a VB6 Array of Struct ... CSharpStruct myData = new CSharpStruct; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: struct ToString() not automatically invoked
    ... I made a struct, and I want to ... public struct MyStruct ... public override string ToString() ... complain, and also wouldn't be invoked automatically. ...
    (microsoft.public.dotnet.languages.csharp)