C # InteropServices and Visual Basic 6.0 error reference error

2

I made a dll in C # for use with Visual Basic 6. When I create the reference in vb6 VB6 I get the following error:

  

Error 91: Object variable or With block variable not set

I have tried it in several ways but it always gives me the same error, I already registered it with REGASM solcomfe.dll /tlb:com.solcomfe.tlb, but it is always the same problem. Compiled with Any Cpu in Visual Studio 2015, compiled with x86 and the problem is the same.

VISUAL BASIC 6.0 Code:

Private Sub Command1_Click()

 Dim objhacienda As SolcomFE.clsHacienda
 Set objhacienda = New SOLCOMFE.clsHacienda' Error can not create the object 429
 Dim blnResult As Boolean
 blnResult = objhacienda.tengoAcceso Error 91: Object variable or With block variable not set
end sub

C # Code:

namespace SolcomFE
{


[
    ComVisible(true), //Hace visible las interfaces
    GuidAttribute("4F52E06E-29C6-4168-8AC2-F836CD7A1C4A"),  //Tomado del asembly del proyecto
    Description("Interfaces para acceso de factura electronica")
    //      ClassInterface(ClassInterfaceType.None)

    ]

//----------------------------------------------------Diseño de interfaces -------------------------------------//
public interface IclsHacienda
{

    [DispId(1)]
    bool tengoAcceso();

    [DispId(2)]
    void configuracion(bool pBlnEnvioProduccion,
                 string pStrUsuarioHacienda,
                 string pStrClaveHacienda,
                string pStrPinCerti,
                string pStrRutaCerti,
           string pStrRutaArchEnvio = "C://HACIENDA/Almacenamiento/",
                 string pStrRutaArchRespuesta = "C://HACIENDA/Almacenamiento/");

    [DispId(3)]
    string[] registrarDocElectronico(
                string pStrVerificador,
                 byte pBytSituacionEnCom,
                DocumentoEncabezado pLstEncabezadoDoc
                );
}


//-------------------------------------------Clases ---------------------------------------------------------//

[ClassInterface(ClassInterfaceType.None)]
[Guid("64B7C116-BA68-4EE0-8340-74F64846CB3D")]
public class clsHacienda : IclsHacienda
{
    //------------------------------------------ Atributos de la clase --------------------------------------//


    private bool EnvioProduccion //
    {
        get
        {
            return envioProduccion;
        }
        set
        {
            envioProduccion = value;
        }
    }

    private string UsuarioHacienda //
    {
        get
        {
            return usuariohacienda;
        }
        set
        {
            usuariohacienda = value;
        }
    }

    private string ClaveHacienda //
    {
        get
        {
            return clavehacienda;
        }
        set
        {
            clavehacienda = value;
        }
    }
    private string RutaCertificado
    {
        get
        {
            return rutacertificado;
        }
        set
        {
            rutacertificado = value;
        }
    }



    private string RutaArchEnvio
    {
        get
        {
            return rutaarchenvio;
        }
        set
        {
            rutaarchenvio = value;
        }
    }

    private string RutArchrespuesta
    {
        get
        {
            return rutaarchrespuesta;
        }
        set
        {
            rutaarchrespuesta = value;
        }
    }


    private string PinCertificado
    {
        get
        {
            return pincertificado;
        }
        set
        {
            pincertificado = value;
        }
    }




    public clsHacienda() { } 

    public bool tengoAcceso() { return true; }


    public void configuracion(bool pBlnEnvioProduccion,
                 string pStrUsuarioHacienda,
                 string pStrClaveHacienda,
                string pStrPinCerti,
                string pStrRutaCerti,
           string pStrRutaArchEnvio = "C://HACIENDA/Almacenamiento/",
                 string pStrRutaArchRespuesta = "C://HACIENDA/Almacenamiento/")

    {
        EnvioProduccion = pBlnEnvioProduccion;

        UsuarioHacienda = pStrUsuarioHacienda;
        ClaveHacienda = pStrClaveHacienda;
        PinCertificado = pStrPinCerti;
        RutaCertificado = pStrRutaCerti;
        RutaArchEnvio = pStrRutaArchEnvio;
        RutArchrespuesta = pStrRutaArchRespuesta;
    }

    public string[] registrarDocElectronico(
                string pStrVerificador,
                 byte pBytSituacionEnCom,
                DocumentoEncabezado pLstEncabezadoDoc
                 )
    {
        string[] strArrValores = new string[10];
        return strArrValores;
    }




  }

}
    
asked by tico00 03.02.2018 в 18:34
source

1 answer

0

I found a solution

Create 2 classes, inteface, class of methods Example iInterface, COMInterface, COMIterface implements iInterface.

Go to tools and create GUID Create a key Implement_OleCreate and copy it to iInterface class, then create a new one 5.Guid Class key

link

    
answered by 04.02.2018 в 07:06