DLL distribution

1

I created a COM DLL in C # VS2010 to be distributed with another application in Delphi.

This DLL only consumes in WEB Services.

On the machine where the DLL was built, there is no error. But in the distribution when the DLL methods are executed the message is returned:

  

The system can not find the file specified.

Is this a configuration that should be performed in the DLL configuration?

DLL code

    public string RecepcionarLoteRps(string AEnderecoWebService, string AXmlEntrada)
    {
        string Retorno = string.Empty;
        try
        {
            ServiceReferenceAbrasfV201.nfseClient wsClient = new ServiceReferenceAbrasfV201.nfseClient("nfseSOAP1", AXmlEntrada);
            Retorno = wsClient.RecepcionarLoteRps(Cabecalho(), AXmlEntrada);
        }
        catch (Exception e)
        {
            Retorno = e.Message;
        }
        return Retorno;
    }

Code in Delphi to send parameters to dll.

var
  LClientWBAws: IAbrasfV201_Interface;
  LRetorno: string;
begin
    LClientWBAws := CoAbrasfV201.Create;
    if (Pos('ConsultarLoteRpsEnvio', LEnviaArqXml) > 0) then
    begin
      LRetorno := LClientWBAws.Getnfse(ALayout.Parametros['EnderecoWebService'], LEnviaArqXml);
    end
    else if (Pos('CancelarNfseEnvio', LEnviaArqXml) > 0) then
    begin
      LRetorno := LClientWBAws.CancelarNfse(ALayout.Parametros['EnderecoWebService'], LEnviaArqXml);
    end
    else
    begin
      LRetorno := LClientWBAws.RecepcionarLoteRps(ALayout.Parametros['EnderecoWebService'], LEnviaArqXml);
    end;

end;
    
asked by anonymous 20.02.2014 / 15:02

2 answers

2

Use the following command to register the DLL on the machine where the file is not found:

regasm minhaDll.dll /tlb:minhaDll.tlb
    
20.02.2014 / 22:29
0

I found these two posts with information.

1) Exclusive to Delpi Delphi Example

2) For Magic XPA, but the idea is similar. Magic Example

Steps: 1) In the AssemblyInfo.cs file (within properties) change the code below to true

[assembly: ComVisible(true)]

2) Create an interface

[Guid("917979B5-2DC2-419C-A38F-46C23D01E587")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface INota
{
    string EnviarNota(string chave);
}

3) Create the class implementation.

[Guid("EDABAB76-CF5B-4674-BA94-925A7D811869")]
[ClassInterface(ClassInterfaceType.None)]
public class Nota : INota
{
    public string EnviarNota(string chave)
    {            
        return "Chave: " + chave;
    }
}

4) Go to the project properties > build > output > mark the check Register for COM interop

5) Create a strong name, again project property > Sgning > check "Sing the assembly" > new > fill in the data ... then a * .pfx file will appear in the solution.

Once this is done the DLL is ready to be used.

Now just register

1) Register in the GAC use the command GacUtil / i dll_name

2) Register with RegAsm: regasm /tlb:name_tlb.tlb dll_name

Now just use the Delphi or Magic XPA projects according to the posts.

Hugs.

    
19.10.2015 / 15:21