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
– Thiago Alex