小编Zig*_* Ho的帖子

如何在Assembly.LoadFile()之前从DLL读取属性

我的程序有一个pluginManager模块,它可以加载DLL文件并运行DLL的方法,但我需要先阅读DLL属性Assembly.LoadFile().我该怎么办?

我读了关于Assembly文档,他们读了属性之后Assembly.LoadFile(),你知道Assembly没有UnLoad()方法,所以我必须在LoadFile()之前读取属性 在此输入图像描述

    private void ImprotZip(string path)
    {
        /*
        1?create tempDir, uppackage to tempDir
        2?Load Plugin DLL, Load plugin dependent lib DLL
        */
        string tempDirectory = CreateRuntimeDirectory(path);
        string[] dllFiles = Directory.GetFiles(tempDirectory);
        ///Load DlL
        foreach(string dll in dllFiles)
        {
            ImprotDll(dll, false);
        }
        string libPath = string.Format("{0}\\lib\\", tempDirectory);
        if (!Directory.Exists(libPath))
            return;
        string[] dlls = Directory.GetFiles(libPath);
        ///Load plugin dependent lib DLL
        foreach(string dll in dlls)
        {
            try
            {
                //filtering same DLL 
                //if(Dll.properties.AssemblyProduct != "something")
                //continue;
                Assembly.LoadFile(dll);
            }
            catch(Exception e)
            { …
Run Code Online (Sandbox Code Playgroud)

c# dll .net-assembly

6
推荐指数
1
解决办法
556
查看次数

标签 统计

.net-assembly ×1

c# ×1

dll ×1