I have a DLL that was created in .NET and I need it to run as COM +.
.NET code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace thiago.dll.NET
{
public class dllNET
{
public String retornoString()
{
return "retorno";
}
}
}
COM + adaptation code:
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 in .NET and I want it to run in VB6, but for this I needed to create another DLL (which turned into a Tlb that is read in 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 the method is, how will VB6 read this dll?
I made the Strong Name Key
, I checked the Register For COM interop
option, I referenced in the project the DLL made in .NET, I left as Global Assembly (GAC)
and added them in Component Services (Library Application (COM + Application) but at the time of use in VB6 it gives Erro em tempo de execução: Erro de automação
Is there another way to do this?
Edit: I made a simple COM + DLL without needing to reference another .NET DLL and when I was playing in VB6 it worked. Can the problem be the reference in COM + of the .NET DLL?