Hello tout le monde,

Dans ma solution Visual Studio 2010 j'ai 2 projets :

  • Librairie Windows Forms
  • Application ASP.NET


Dans mon projet Windows Forms j'ai un UserControl que j'aimerais ajouter comme ActiveX dans une page web de mon projet ASP.NET.

Le problème c'est que ça ne marche pas.

Voici le code de mon UserControl (qui ne contient qu'un bouton pour l'instant) :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
namespace FormsApp {
    public partial class UserControl1 : UserControl {
        public UserControl1() {
            InitializeComponent();
        }
    }
}
Ensuite j'ai compilé mon projet Windows Forms et j'ai copier la DLL à la racine de mon projet ASP.NET.

Et voici le code de ma page ASP.NET :

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
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestActiveX.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
 
            <object id="UserControl1" height="176" width="352" classid="FormsApp.dll#FormsApp.UserControl1" VIEWASTEXT>
            </object>
 
        </form>
    </body>
</html>
Lorsque j’exécute mon projet ASP.NET un carré vide s'affiche.

Dans mon projet Windows Forms j'ai également coché "Register form COM interop" dans les propriétés de compilation.

Est-ce que quelqu'un a une idée ?
Merci d'avance.