Error in runtime VB6

Asked

Viewed 277 times

2

I have a DLL that was created in . NET and I need it to run as COM+.

code in . NET:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace thiago.dll.NET
{
    public class dllNET
    {
         public String retornoString()
         {
               return "retorno";
         }
    }
}

code adaptation WITH+:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace thiago.dll.NET.COMPLUS
{
    [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual),
    Guid("2382A011-76E7-4729-A8C9-A016465DCA19")]
    public interface IStringRetorno
    {
        String retornoString();
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace thiago.dll.NET.COMPLUS
{
    [ComVisible(true), ClassInterface(ClassInterfaceType.None),
    Guid("7457F910-D91C-4378-91CD-D768A32FF339")]
    public class StringRetorno : IStringRetorno
    {
        thiago.dll.NET.dllNET obj = new thiago.dll.NET.dllNET();
        public StringRetorno()
        {

        }

        [ComVisible(true)]
        public String retornoString()
        {
            return obj.retornoString();
        }
    }
}

To explain better I did a DLL on . NET and I want it to run on VB6, but for that I needed to create another DLL (which turned into a tlb that is read on VB6) where VB6 can see the methods and apply them. What I realized is that when I referenced the DLL made in . NET in that other DLL, it takes the dll file where is the method, as the VB6 will read this dll?

I made the Strong Name Key, checked the option Register For COM interop, referenciei no projeto a DLL feito em . NET, I left as Global Assembly (GAC) and added to in Component Services (Library Application(COM+)), but when using VB6 it gives a Erro em tempo de execução: Erro de automação

There’s another way to do this?

Edit: I made a simple COM+ DLL without having to reference another DLL. NET and when I went to play VB6 worked. The problem may be the reference in COM+ from DLL . NET?

  • I found the error: The problem was to make a DLLCOM+ to read a.NET DLL, and when referenced this DLLCOM+ it washed with the.NET DLL and in this the VB6 does not support. The solution was to create the DLL.NET and DLLCOM+ in the same classlibrary

1 answer

2

COM+ is always a problem...

Here, when we do these Wrappers, the initial COM class (and only it) is derived from Servicedcomponent. Other interfaces/classes obtained from the initial do not need to derive from Servicedcomponent.

Also not registered in GAC, but only using the Regsvcs.exe. Make sure to use 64-bit or 32-bit version depending on the machine.

  • It’s a solution too, but in my case my . NET was already created, I needed to turn it into COM+

Browser other questions tagged

You are not signed in. Login or sign up in order to post.