Distribution of DLL

Asked

Viewed 612 times

2

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

This DLL only consumes on 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:

System cannot find specified file.

This is some configuration that should be run 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;
    }

Delphi code to send the 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;

  • 1

    You probably have to put inside the DLL the webservice configuration file.

  • But that’s already there the settings of Wsdls

  • Put more information about your error. Is there an exception? For whom the error occurs?

  • The DLL is Activex?

  • Gee can be so many things, some things I thought here: - Check that the dll has actually been distributed and this in the folder that the application expects it to be in. - Another thing that might happen eh if your dll has some reference and that reference is not marked to be distributed together, then your dll is going, but some dependency on it is not. has an option in the reference that says "Copy Local"

  • Error: Process completed with error - Technical error: System cannot find specified file.

  • public string Recepcionarloterps(string Aenderecowebservice, string Axmlinput) { string Return = string. Empty; Try { Servicereferenceabrasfv201.nfseClient wsClient = new Servicereferenceabrasfv201.nfseClient("nfseSOAP1", Axmlinput); Return = wsClient.Recepcionarloterps(Cabecalho(), Axmlentrada); } catch (Exception e) { Return = e.Message; } Return Return; }

  • Was imported as Activex in Delphi.

  • I had a last minute question. The files . svcinfo and Wsdls should be distributed together with the DLL?

  • If the only purpose of the DLL is to call this service, why not call it directly in Delphi? Delphi can also consume web services.

  • Usually when I find a mistake of this kind I use the Processmonitor to find out which file is trying to be accessed. 99% of the time it works.

  • Take a look at the answer I posted here: http://answall.com/questions/8107/dll-c-no-delphi-7/8341#8341

Show 7 more comments

2 answers

2

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

regasm minhaDll.dll /tlb:minhaDll.tlb
  • This runs on the installation.

0

I found these two post with information.

1) Exclusive for delpi Example in Delphi

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

Steps: 1) In 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 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 project properties > build > output > mark check Register for COM Interop

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

Done this the DLL is ready to be used.

Now just register

1) Register in GAC use the command Gacutil /i name_dll.dll

2) Register with Regasm : regasm /tlb:name_tlb.tlb name_dll.dll

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

Hugs.

Browser other questions tagged

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