简体   繁体   中英

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 https://aka.ms/applicationconfiguration.
        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("");
        
    }

}
}

错误弹出

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.

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