Search code examples
c#dllvb6vb6-migration

Can't see values of properties created in C#


Good Morning,

Introduction:

My problem is about C# dll and VB6. And it refers to the reason of why I can't see the values of the C# properties, but I can see the same values of those properties in my VB6 project.

Explanation:

I created a dll file and a tlb file from a Windows Form Application with VS19 (Visual Studio 2019).

I moved into Properties -> Application and I changed the "Output type" from "Windows application" to "Class Library". After, I clicked in "Assembly information" and I checked the COM visible voice at the bottom of the window that appeared when I clicked.

After that I moved in "Compilation" and checked the "Interop COM" checkbox at the bottom.

In the end I compile the solution and moved the two files in a Virtual Machine (Win XP 32bit SP3), created with Virtual Box. where there's my application developed in VB6.

In my VB6 project I can set and use properties and method of the .NET dll and I see the values (EOL and EOLs are my .NET classes).

Like this:

    Vin_car_11 = Mid$(frmInput.txtVinCode.Text, 11, 1)

    Select Case Vin_car_11
        Case "2"
            EOL.XMLPrdWsUrl = "URL"    'Brescia
        Case "5"
            EOL.XMLPrdWsUrl = "URL"     'Suzzara
        Case "9"
            EOL.XMLPrdWsUrl = "URL"    'Bolzano
    End Select
    
    EOL.Vin = frmInput.txtVinCode.Text
    EOL.Van = frmInput.txtVanCode.Text
    
    returnCode = EOLs.GetXMLFile()

Here the problem:

Why I see the value of "EOL.vin" in VB6, but I can't see the same value in C#?

Here the code of my EOL class:

public class cEOL
{
    private string vin;
    public string Vin
    {
        get
        {
            return this.vin;
        }
        set
        {
            this.vin = value;
        }
    }

 }

Here the code of my EOLs class:

public class cEOLs
{
    #region DICHIARAZIONI
    Vehicle.AuthHeader auth;
    cEOL EOL;

    string result;
    string errorDescr;
    #endregion

    #region COSTRUTTORE
    public cEOLs()
    {
        EOL = new cEOL();
        auth = new Vehicle.AuthHeader();

        result = "";
        errorDescr = "";
    }
    #endregion

    #region METODO
    public int GetXMLFile()
    {
        //chiave di autenticazione server rilasciato da EHSA (IVECO) 
        auth.AuthKey = "Key";

        var client = new Vehicle.EOLClientsAPI4EXT { Url = EOL.XMLPrdWsUrl };

        EOL.ReturnCode = client.GetProductionXML(EOL.Vin, EOL.Van, out result, out errorDescr);

        EOL.Result = result;
        EOL.ErrorDescr = errorDescr;

        return EOL.ReturnCode;
    }
    #endregion

THANKS IN ADVANCE! I HOPE I WAS CLEAR IN THE EXPLANATION!


Solution

  • I resolved it by myself by simply creating a method that returns a string. I recall this method in my VB6 project for setting the value of the property.

    Here the method:

        public string ImpostaVIN(string vin)
        {
            EOL.Vin = vin;
    
            return EOL.Vin;
        }
    

    Here the call in VB6:

    EOL.Vin = EOLs.ImpostaVIN(string)