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

1

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)

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

enter image description here

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

enter image description here

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.

P.S. 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.

c#
.net
azure
azure-web-app-service
asked on Stack Overflow May 13, 2020 by Oleksii Dniprovskyi • edited May 13, 2020 by Oleksii Dniprovskyi

1 Answer

1

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.

enter image description here

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.

answered on Stack Overflow May 14, 2020 by Jason Pan • edited May 19, 2020 by Jason Pan

User contributions licensed under CC BY-SA 3.0