簡體   English   中英

未加載簡單的 ASMX WebService 和 DLL

[英]Simple ASMX WebService and DLL not loaded

我在運行 ASMX Web 服務時遇到問題。 我從一個方法 (AceptaTools.dll) 調用一個 DLL,這個 DLL 加載 ca4xml.dll。

AceptaTools.dll 已注冊到 REGSVR32。 但是 ca4xml.dll 不行。

當我調用服務時:

_objURL = _CA4XML.GetLastResponse();

我收到一條消息“ca4xml.dll 未加載”。

尋找 al Dependency Walker:

這里詳細介紹了這兩個文件:在此處輸入圖片說明

兩個 DLL 都在 BIN 文件夾中,我的項目以 x86 運行...為什么無法加載? 請幫忙。

[WebMethod]

public string Send(string Ip, string Puerto, string NroDocumento, string TipoDocumento, string Comando, string Impresora, string Linea)
{
    try
    {
        int _Result = 0;
        string _Null = "";
        string _objURL;

        //Config Capsula
        string serverConfig = "cfg|" + Ip.ToString() + "|" + Puerto.ToString() + "|10";

        //Impresora FACTURA,1 por Defecto.
        if (string.IsNullOrEmpty(Impresora)) { Impresora = "FACTURA,1"; }
        if (string.IsNullOrEmpty(NroDocumento)) { NroDocumento = "0"; }
        if (string.IsNullOrEmpty(Comando)) { Comando = "generar"; }

        //Nuevo CAXML Cliente
        AceptaTools.CA4XML_Client _CA4XML = new CA4XML_Client();

        _Result = _CA4XML.Send(ref serverConfig, ref NroDocumento, ref Comando, ref Impresora, ref Linea, out _Null);


        if (_Result != 0)
        {
            _objURL = _CA4XML.GetLastResponse(); //Get URL
            return _objURL.ToString();
        }
        else
        {
            return "Error";
        }


    }
    catch (Exception ex)
    {
        return ex.Message.ToString();
    }
}

}

在此處輸入圖片說明

當你沒有在程序中加載 DLL 時因為你需要更新一些東西。 您可以在 nuget manager 中更新項目

您是否確保正確部署了ca4xml.dll 由於我猜它沒有被引用為 .NET 程序集,因此 VS 會將其視為普通文件,並且您需要在部署時專門告訴 VS 將其包含在內。

執行以下步驟以檢查部署是否已正確設置:

打開解決方案資源管理器 -> 到ca4xml.dll -> 右鍵單擊​​ -> 選擇Properties -> 設置Build Action = None & Copy to Output = Always

此外,除了Dependency Walker之外,我還建議使用Process Monitor 當您使用文件訪問視圖(忽略注冊表更改等)時,您可以看到進程嘗試從中加載 dll 的所有位置。 之后,您可以確保您缺少的 dll 位於列出的位置之一,這是鏈接:
http://technet.microsoft.com/en-us/sysinternals/bb896645

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM