Bonjour à tous,

Suite a la lecture de la tuto sur les application modulaire, j'ai décidé de tester le tout. J'ai donc créé une solution dans VS 2008 avec un projet Interface, une application principale et un plugin (un simple bouton)

L'interface :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace Interface
{
    public interface InterfacePlugIn
    {
        UserControl VisualComponent();
    }
}
Le plugin

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Interface;
using System.Windows.Forms;
using System.Drawing;
 
namespace Bouton1
{
    public class Bouton1 : UserControl, InterfacePlugIn
    {
        private Button button1;
 
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(0, 0);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 0;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            // 
            // Bouton1
            // 
            this.Controls.Add(this.button1);
            this.Name = "Bouton1";
            this.Size = new System.Drawing.Size(75, 23);
            this.ResumeLayout(false);
 
        }
 
        public UserControl VisualComponent()
        {
            return this;
        }
    }
}
Application principale

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Interface;
 
namespace MainFrame
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            object obj;
            obj = AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap("Bouton1.dll", "Bouton1.Bouton1");
        }
    }
}
J'ai aucune erreur tout semble fonctionner, cependant il me manque la parti affichage dans le programme principale. Je ne sais pas comment afficher le plugin qui est un simple bouton.