Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading plug-in DLL files, "The invoked member is not supported in a dynamic assembly."

We have custom DLL's that are not included in our initial setup file. They are loaded at runtime. This process worked fine while using .NET 2.0, but we are getting the "The invoked member is not supported in a dynamic assembly" error message now that we are using .NET 4.0.

try {     assem = Assembly.LoadFrom(fi.FullName); //fi is FileSystemInfo } catch (FileLoadException) {} catch (BadImageFormatException) {} catch (System.Security.SecurityException) {} catch (ArgumentException) {} catch (PathTooLongException) {} 
like image 664
Trevorm Avatar asked Apr 10 '12 15:04

Trevorm


1 Answers

This error is occurring because Assembly.Load cannot be called upon dynamic assemblies. You must filter out the dynamic assemblies before using them.

var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(p => !p.IsDynamic);

like image 71
Gusdor Avatar answered Sep 23 '22 11:09

Gusdor