Click here to Skip to main content
15,915,845 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: POP3 Pin
James T. Johnson23-Dec-02 21:32
James T. Johnson23-Dec-02 21:32 
GeneralRe: POP3 Pin
Rocky Moore23-Dec-02 22:23
Rocky Moore23-Dec-02 22:23 
GeneralDocking Windows Pin
Dan S.23-Dec-02 11:10
Dan S.23-Dec-02 11:10 
GeneralRe: Docking Windows Pin
Ray Cassick23-Dec-02 11:33
Ray Cassick23-Dec-02 11:33 
GeneralRe: Docking Windows Pin
flipdoubt7-Jan-03 4:06
flipdoubt7-Jan-03 4:06 
GeneralRemoting to multiple clients Pin
SHaroz23-Dec-02 10:20
SHaroz23-Dec-02 10:20 
GeneralDirectX 9.0 Released Pin
Heath Stewart20-Dec-02 9:28
protectorHeath Stewart20-Dec-02 9:28 
GeneralReflections in the rearview mirror may appear closer than they are! Pin
Derek Lakin20-Dec-02 0:00
Derek Lakin20-Dec-02 0:00 
It seems to be flavour of the month atm, but I'm trying to develop a generic plugin architecture for extending application functionality. To achieve this I have a dll that contains interfaces for a base addin (IBaseAddin) and an addin manager (IAddinManager).

I have an application in mind that is already written, I just need to move some of it's functionality out into addins, which will be tab pages. I also want other people to be able to produce addins for the application, so I am producing and SDK too. Essentially the SDK just extends the generic dll described above, so we have MyAddin which inherits from TabPage and implements IBaseAddin and I also have IMyAddinManager, which extends IAddinManager. This SDK is also a separate dll and any addins will be implemented in their own dll exporting a single type that inherits from MyAddin.

The main form in the application implements IMyAddinManager (i.e. it is the addin manager itself) and has a LoadAddins method which is responsible for loading all addins in the \addins\ folder and addin each one to the tab control of the main form. The code to achieve this looks something like this atm:
C#
public void LoadAddins()
{
  IAddinManager manager = this;
  DirectoryInfo dirInfo = new DirectoryInfo(Environment.CurrentDirectory + @"\addins\");
  FileInfo[] fileInfo = dirInfo.GetFiles("*.dll");
  foreach(FileInfo fileInfo in Files)
  {
    Assembly assembly = Assembly.LoadFrom(fileInfo.FullName);
    try
    {
      Type[] types = assembly.GetExportedTypes();
      object addin = assembly.CreateInstance(types[0].FullName);
      if((null != addin) && (addin is TabPage))
      {
        ((MyAddin)addin).Manager = manager;  // ** Exception ** //
        this.tabControl.Controls.Add(addin as TabPage);
        this.addins.Add(addin as IBaseAddin);
      }
    }
    catch(Exception exc)
    {
      System.Diagnostics.Debug.WriteLine(exc.Message);
    }
  }
}

The line that tries to set the Manager property throws a System.InvalidCastException even though the debugger allows me to browse all of the relevant properties, etc. and shows the correct type. Any ideas why this isn't working?

Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.

Salamander Software Ltd.
GeneralRe: Reflections in the rearview mirror may appear closer than they are! Pin
leppie20-Dec-02 11:07
leppie20-Dec-02 11:07 
QuestionHow to paint over child controls? Pin
dur_kart19-Dec-02 19:47
dur_kart19-Dec-02 19:47 
Generalsecurity problem?help Pin
imran_rafique19-Dec-02 12:55
imran_rafique19-Dec-02 12:55 
GeneralRe: security problem?help Pin
Burt Harris21-Dec-02 10:12
Burt Harris21-Dec-02 10:12 
GeneralProject Dependencies Pin
Derek Lakin18-Dec-02 3:15
Derek Lakin18-Dec-02 3:15 
GeneralRe: Project Dependencies Pin
SimonS19-Dec-02 22:10
SimonS19-Dec-02 22:10 
GeneralRe: Project Dependencies Pin
Burt Harris21-Dec-02 10:22
Burt Harris21-Dec-02 10:22 
GeneralInfo regarding ref parameter and out parameter Pin
Venkatraman17-Dec-02 21:21
Venkatraman17-Dec-02 21:21 
GeneralRe: Info regarding ref parameter and out parameter Pin
Daniel Turini17-Dec-02 21:49
Daniel Turini17-Dec-02 21:49 
General.net licenses Pin
Roger Alsing17-Dec-02 20:43
Roger Alsing17-Dec-02 20:43 
GeneralUsing .NET Framework 1.1 Final Beta with VS.NET (2002) Pin
Arun Bhalla16-Dec-02 11:49
Arun Bhalla16-Dec-02 11:49 
GeneralRe: Using .NET Framework 1.1 Final Beta with VS.NET (2002) Pin
djkno316-Dec-02 12:41
djkno316-Dec-02 12:41 
GeneralViewing a directory Pin
Jamie Nordmeyer16-Dec-02 5:35
Jamie Nordmeyer16-Dec-02 5:35 
GeneralRe: Viewing a directory Pin
Jeff J16-Dec-02 11:39
Jeff J16-Dec-02 11:39 
GeneralRe: Viewing a directory Pin
Jamie Nordmeyer16-Dec-02 11:47
Jamie Nordmeyer16-Dec-02 11:47 
GeneralRe: Viewing a directory Pin
Jeff J16-Dec-02 15:48
Jeff J16-Dec-02 15:48 
QuestionAdjusting alpha of an image with .NET? Pin
Jon Rista15-Dec-02 14:58
Jon Rista15-Dec-02 14:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.