C# Get Error Method Not Found: System. Security. Accesscontrol. Filesecurity System. Io. File. Getaccesscontrol(System. String) When I Link to Dll

So I am working on a project which need to use a dll called Loadengine.dll, I follow the steps in the manual, but when I run the application the error pop up Method not found :System.Security.AccessControl.FileSecurity System.IO.File.GetAccessControl(System.String) I don't know what happend. I didn't call this method in my code.

Program.cs

namespace wcb
{
using System.Reflection;
using System.IO;
using Microsoft.VisualBasic.ApplicationServices;
using System.Windows.Forms;
using System;

internal static class Program
{
    /// <summary>
    ///  The main entry point for the application.
    /// </summary>
    
    [STAThread]
    static void Main()
    {
        // To customize application configuration such as set high DPI settings or default font,
        // see 
        AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
        ApplicationConfiguration.Initialize();
        Application.Run(new Form1());
    }
    static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
    {
        List<string> engineDlls = new List<string>();
        engineDlls.AddRange(new string[] { "LoaderEngine", "RFMDMPSSE", "Bin", "Utilities" });
        AssemblyName assemblyName = new AssemblyName(args.Name);
        if (engineDlls.Contains(assemblyName.Name))
        {
            string dllLocation = "C:\\Users\\jay.lin\\AppData\\Local\\Programs\\Qorvo\\RF Optimizer\\"+ assemblyName.Name + ".dll";
            if (File.Exists(dllLocation))
            {
                return Assembly.LoadFrom(dllLocation);
            }
        }
        return null;
    }
}
}

Form1.cs

namespace wcb
{
public partial class Form1 : Form
{
    private LoaderEngine.LoaderEngine engine;
    public Form1()
    {
        InitializeComponent();
        engine = new LoaderEngine.LoaderEngine();
        engine.InitializeEngine("");
        
    }

}
}

1 Answer

It may be that Loadengine refers to an old version of the dll of the same name and gives the path in the program, but it may also be included, and the referenced assembly version conflicts.

You should make sure to deploy the latest DLL and check the folder for no hidden duplicate old assemblies, and recompile.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest