[英]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.所以我正在做一个项目,需要使用一个名为 Loadengine.dll 的 dll,我按照手册中的步骤操作,但是当我运行应用程序时,错误弹出
Method not found:System.Security.AccessControl.FileSecurity System.IO.File.GetAccessControl(System.String)
我不知道发生了什么。 I didn't call this method in my code.我没有在我的代码中调用这个方法。
Program.cs
程序.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
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.可能是Loadengine引用了旧版本的同名dll并给出了程序中的路径,但也有可能被包含,引用的程序集版本冲突。
You should make sure to deploy the latest DLL and check the folder for no hidden duplicate old assemblies, and recompile.您应该确保部署最新的 DLL 并检查文件夹中没有隐藏的重复旧程序集,然后重新编译。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.