I am using reflection to search through assemblies that contain a certain interface, the one i am trying to find is a windows form that implements that interface, however the error i am getting claiming it cannot load the file, could it be down to not using reflection correctly or loading in the file properly.
string[] files = Directory.GetFiles(Environment.CurrentDirectory, "*.dll");
foreach (string file in files)
{
try
{
Assembly da = Assembly.LoadFrom(file);
foreach (Type type in da.GetTypes())
{
debugger = (IDebugger)Activator.CreateInstance(type.GetInterfaces().First(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IDebugger)));
break;
}
break;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
continue;
}
}
if (!(debugger == null))
debugger.VirtualMachine = this;
Error
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at SVM.SvmVirtualMachine..ctor() in C:\Users\Ollie\Desktop\Work\SimpleVM\SVM\VirtualMachine\VirtualMachine\SvmVirtualMachine.cs:line 49
System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
File name: 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Aucun commentaire:
Enregistrer un commentaire