简体   繁体   English

System.EntryPointNotFoundException以平行红色显示在输出中

[英]System.EntryPointNotFoundException in Parallel red in output

I had some minor problem but I cant seem to see where its gone wrong , could someone help me out: 我遇到了一些小问题,但是我似乎看不到哪里出了问题,可以有人帮我解决一下:

Loadassembly fn 负载装配fn

public static Assembly LoadAssembly(string assemblyfile)
        {
            Assembly library;
            using (var fs = File.Open(assemblyfile, FileMode.Open))
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    byte[] buffer = new byte[1024];
                    int read;
                    while ((read = fs.Read(buffer, 0, 1024)) > 0)
                        ms.Write(buffer, 0, read);
                    library = Assembly.Load(ms.ToArray());
                }
            }
            return library;
        }

public static string[] GetDLLInfo(string assemblyfile, bool onlyNameSpace)
            {
                var strAssembly = LoadAssembly(assemblyfile).GetTypes();
                List<string> classList = new List<string>();

                var xx = strAssembly.Select(t => t.Namespace).Distinct().ToList();
                var nmSpaceLiStrings = xx.ToArray();

                Parallel.ForEach(nmSpaceLiStrings, x =>
                {
                    var types = strAssembly.Where(t => t.IsClass && t.Namespace == x).ToList();
                    types.ForEach(t => classList.Add(t.FullName));
                });

                /* foreach (var x in nmSpaceLiStrings)
                {
                    var types = strAssembly.Where(t => t.IsClass && t.Namespace == x).ToList();
                    types.ForEach(t => classList.Add(t.FullName));
                } */

                if (onlyNameSpace)
                {
                    return nmSpaceLiStrings;
                }
                return classList.ToArray();
            }

Its kind of weird if I use 'foreach' (not parallel , I got no warning in output dialog, but when I use 'parallel' I got : 如果我使用'foreach'(不是parallel,那有点奇怪,在输出对话框中没有警告,但是当我使用'parallel'时,我得到了:

A first chance exception of type 'System.EntryPointNotFoundException' occurred in mscorlib.dll

Does my parallel gone wrong and show me the correct way? 我的平行测试是否出错并向我显示正确的方法?

Thanks in advance . 提前致谢 。

您没有尝试使用ConcurrentBag <T>来代替将类名添加到列表中吗?

What is LoadAssembly method? 什么是LoadAssembly方法? How it's declared? 如何声明? The exception means that some method does not exist in the dll. 该异常表示dll中不存在某些方法。 So the problem is in the assembly itself or in the LoadAssembly declaration. 所以问题出在程序集本身或LoadAssembly声明中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.EntryPointNotFoundException:无法找到入口点 - System.EntryPointNotFoundException: Unable to find an entry point 未处理的异常:DLL中的System.EntryPointNotFoundException - Unhandled Exception: System.EntryPointNotFoundException in DLL Mono 2.8上的SWIG中的System.EntryPointNotFoundException错误 - System.EntryPointNotFoundException error in SWIG on mono 2.8 使用aff文件时System.EntryPointNotFoundException - System.EntryPointNotFoundException when using aff file System.EntryPointNotFoundException和DllImport(“ kernel32.dll”) - System.EntryPointNotFoundException and DllImport(“kernel32.dll”) 从 DLL 调用 function 时出现 System.EntryPointNotFoundException - System.EntryPointNotFoundException when calling function from DLL 在Linux中,单声道调用我的.so lib返回System.EntryPointNotFoundException - in linux, mono invoke my .so lib return System.EntryPointNotFoundException Owin / Katana System.EntryPointNotFoundException程序集位于其他位置 - Owin/Katana System.EntryPointNotFoundException Assembly located elsewhere 无法使用Magick.NET:System.EntryPointNotFoundException - Can't use Magick.NET: System.EntryPointNotFoundException Excel Interop:使用Task.Run创建实例会导致异常System.EntryPointNotFoundException - Excel Interop: Creating instance with Task.Run results in exception System.EntryPointNotFoundException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM