A
auad
hi,
I'm having a problem with plugins....as follows:
I have 3 projects: 2 class libraries and 1 Windows App
(Project 1: ClassLibrary)
I have a plugin interface:
--------------------------------------------------------------------
namespace API
{
public interface IPlugin
{
string GetPluginName(); // returns the plugin name
void Setup(); // displays the configuration
form
}
}
(Project 2: ClassLibrary)
a plugin class that implements the interface:
a plugin configuration form:
--------------------------------------------------------------------
namespace Plugins
{
public class Plugin1: IPlugin
{
string GetPluginName()
{
//...
}
void Setup()
{
frmSetup form = new frmSetup();
form.ShowDialog();
}
}
partial class frmSetup : Form
{
public frmSetup()
{
InitializeComponent();
}
}
}
(Project 3: WinApp)
load a plugin:
--------------------------------------------------------------------
namespace WinApp
{
public partial class frmPrincipal: Form
{
public frmPrincipal()
{
InitializeComponent();
Assembly assembly = Assembly.LoadFile("My_Plugin.dll");
Type[] types = assembly.GetTypes(); // This line throws an
error
}
}
}
Error: Unable to load one or more of the requested types. Retrieve the
LoaderExceptions property for more information.
{System.IO.FileNotFoundException: Could not load file or assembly 'API,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. The system cannot find the file specified.
File name: 'API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
I think that when I run the GetTypes method, the compiler looks in my
plugin assembly and finds that it references my plugin Interface, which
is in another assembly, but it doesn't find it, so it throws this
error.
I tried to solve it by using the GetType method passing the full path
to my plugin class as parameter, but it always returns null...On the
other hand, if I pass the full path for the configuration form class
(which is in the same project, and isn't my objective) it works
fine....
Can someone help me?
Tks
I'm having a problem with plugins....as follows:
I have 3 projects: 2 class libraries and 1 Windows App
(Project 1: ClassLibrary)
I have a plugin interface:
--------------------------------------------------------------------
namespace API
{
public interface IPlugin
{
string GetPluginName(); // returns the plugin name
void Setup(); // displays the configuration
form
}
}
(Project 2: ClassLibrary)
a plugin class that implements the interface:
a plugin configuration form:
--------------------------------------------------------------------
namespace Plugins
{
public class Plugin1: IPlugin
{
string GetPluginName()
{
//...
}
void Setup()
{
frmSetup form = new frmSetup();
form.ShowDialog();
}
}
partial class frmSetup : Form
{
public frmSetup()
{
InitializeComponent();
}
}
}
(Project 3: WinApp)
load a plugin:
--------------------------------------------------------------------
namespace WinApp
{
public partial class frmPrincipal: Form
{
public frmPrincipal()
{
InitializeComponent();
Assembly assembly = Assembly.LoadFile("My_Plugin.dll");
Type[] types = assembly.GetTypes(); // This line throws an
error
}
}
}
Error: Unable to load one or more of the requested types. Retrieve the
LoaderExceptions property for more information.
{System.IO.FileNotFoundException: Could not load file or assembly 'API,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. The system cannot find the file specified.
File name: 'API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
I think that when I run the GetTypes method, the compiler looks in my
plugin assembly and finds that it references my plugin Interface, which
is in another assembly, but it doesn't find it, so it throws this
error.
I tried to solve it by using the GetType method passing the full path
to my plugin class as parameter, but it always returns null...On the
other hand, if I pass the full path for the configuration form class
(which is in the same project, and isn't my objective) it works
fine....
Can someone help me?
Tks