简体   繁体   中英

Azure WebService can't find one of my assemblies but it's there based on Azure Console

I am very new to Azure and WebServices so please bear with me here. Basically, I have a WebService that references 3 different dlls SOCreate.dll , EOTCBase.dll , EOTC_InBuffer.dll , not standard .NET dlls but rather dlls from other projects I have. After I published a WebService on Azure successfully, I am calling my WebService which calls a method in EOTCBase.dll . The method in EOTCBase.dll tries to load an EOTC_InBuffer.dll assembly like so:

Assembly dbAssembly = Assembly.LoadFile(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\EOTC_InBuffer.dll");

but that call fails with an error The system cannot find the file specified. (Exception from HRESULT: 0x80070002) The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

When I check what files I have on Azure I can see my WebService and a bin folder:

在此处输入图像描述

then I go inside the bin folder and can see all 3 dlls in there:

在此处输入图像描述

I guess that means that all 3 dlls are published on Azure and are available in bin folder. I tried to google for something similar but wasn't able to find a similar scenario. Could somebody please maybe point what's wrong here or maybe reference a link to some reading materials? Thank you.

PS It almost looks like that all those 3 dlls in the same bin folder based on Azure Console output but in fact some of them not in there actually.

UPDATE

I mean open kudu on the portal, and manually add the mydll folder as in my screenshot. The specific path of the.dll file is D:\home\site\wwwroot\mydll\a.dll . In this way, if the operation is successful, you don't need to worry about the temporary folder. Copy all the.dll files that will be used to the mydll folder.

在此处输入图像描述

PRIVIOUS

You can use dynamic load function to use your.dll file. If this is successful locally, and unsuccessful after deployment, then the problem should be the Azure cloud environment.

    #region Dynamically load .dll
    object obj=null;
    byte[] filesByte;
    Assembly assembly;
    Type type;
    MethodInfo timerInitial;
    MethodInfo timerDispose;
    #endregion

    private void LoadDll()
    {
        try
        {
            filesByte = File.ReadAllBytes(Path.GetDirectoryName(Application.ExecutablePath) + "//EOTC_InBuffer.dll");
            assembly = Assembly.Load(filesByte);
            type = assembly.GetType("EOTC_InBuffer.dll");
            obj = System.Activator.CreateInstance(type);
            timerStart = tp.GetMethod("TimerStart");
            timerStop = tp.GetMethod("TimerStop");
            if (timerStart != null)
            {
                timerStart.Invoke(obj, null);
            }
        }
        catch(Exception)
        {

        }
    }

You are successful in running locally, but deploying to Azure will fail. This problem cannot be dealt with, because we cannot register the.dll in the Azure environment, nor can we read and load these.dll files in the bin folder through code.

I have replied to this question in another post before, and also tried to use the code to deal with this problem but all failed, I hope it will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM