ActiveX, l’installation ne fonctionne pas

Je veux créer et déployer un plug-in ActiveX, quelque chose de vraiment petit. Je veux juste afficher une boîte de message.

J’ai créé un projet de bibliothèque pour cela et je le comstack en DLL. Le plug-in fonctionne lorsque regasm la DLL via la ligne de commande ( regasm ) sur une machine.

Donc, je dois maintenant créer un installateur, le mettre dans un fichier CAB et le signer.

J’ai installé Visual Studio 2008 pour utiliser le projet Setup Project (mais je peux utiliser InstallShield à partir de 2010 si quelqu’un peut expliquer comment le faire). J’ajoute mon dll au dossier d’application et le marque comme Register = vsdrpCOM et je le construis et je reçois un fichier .msi et .exe.

Je pense que je n’ai besoin que du fichier msi et pas de l’exe. J’ai créé un fichier setup.inf avec le contenu suivant:

 [version] signature="$CHICAGO$" AdvancedINF=2.0 [Setup Hooks] hook1=hook1 [hook1] run=msiexec.exe /i "%EXTRACT_DIR%\ActiveInstaller.msi" /qn 

Pour construire le fichier .cab, j’utilise la commande makecab / f build.ddf. Voici mon fichier .ddf:

 .Set DiskDirectoryTemplate=; .Set CabinetNameTemplate=ActiveInstaller.cab ../ActiveInstaller.msi ../setup.inf 

Cela a généré le fichier cab. Maintenant je dois le signer. Pour le moment, j’ai utilisé un certificate auto-signé que j’ai généré et installé sur mon PC (lorsque je vérifie le fichier cab, Windows indique qu’il est sécurisé). J’utilise une autre ligne de commande qui est signtool signwizard (j’essaie également de le signer manuellement ici ). Ensuite, le fichier est signé et je le télécharge sur mon site Web, je lance le site Web, je suis invité à installer le plug-in et je l’installe.

Mais alors, ça ne marche pas, je n’ai aucune idée de pourquoi. J’ai essayé tellement de choses, avec différents installateurs, différentes options, différents fichiers inf, différentes méthodes de signature, etc.

Le seul tutoriel que j’ai trouvé a au moins trois ans, je ne sais pas si quelque chose d’aussi changé depuis qu’ils ont été écrits. Voici le lien principal que j’ai utilisé: http://blogs.msdn.com/b/asiatech/archive/2011/12/05/how-to-develop-and-deploy-activex-control-in-c.aspx et une autre http://www.codeproject.com/Articles/24089/Create-ActiveX-in-NET-Step-by-Step

SOLUTION :

Donc, tout ce que Pepo a dit est vrai alors j’ai marqué sa réponse comme acceptée. J’ai aussi trouvé quelqu’un qui le code source complet (y compris comment créer le fichier .exe qui exécute le msi) ici .

Le problème est peut-être que vous essayez d’exécuter msiexec.exe et que cet exe n’est pas dans le fichier cab. Voir cette question (assurez-vous de faire défiler le code incroyablement utile publié par Roey le 5 août 2009). Essayez de créer un fichier setup.exe exécutant le processus msiexec.exe et installez votre fichier msi ou créez un programme d’installation avec un fichier bootstrap setup.exe et incluez les deux dans la cabine.

En outre, vous souhaiterez peut-être en savoir plus sur les installations non admin actives .

Votre dll ActiveX doit être signé et votre ActiveX doit implémenter cette interface

 ///  /// Options supported for the IObjectSafety interface ///  [Serializable] [ComVisible(true)] public enum ObjectSafetyOptions { ///  /// Indicates that the caller of the interface identified by riid might be untrusted. ///  INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001, ///  /// Indicates that the data passed into the interface identified by riid might be untrusted. ///  INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002, ///  /// Indicates that the caller of the interface identified by riid knows to use IDispatchEx. ///  INTERFACE_USES_DISPEX = 0x00000004, ///  /// Indicates that the data passed into the interface identified by riid knows to use IInternetHostSecurityManager. ///  INTERFACE_USES_SECURITY_MANAGER = 0x00000008 }; ///  /// Provides methods to get and set safety options. /// The IObjectSafety interface should be implemented by objects that have interfaces which support "untrusted" clients, such as scripts. /// It allows the owner of the object to specify which interfaces must be protected from "untrusted" use. ///  [ComImport()] [Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IObjectSafety { ///  /// Gets the safety options supported by an object and the safety options that are currently set for that object. ///  /// An interface identifier for a given object /// Receives the address of a DWORD representing all the options supported for the interface identified by riid. /// Receives the address of a DWORD representing all the options currently enabled for the interface identified by riid. /// Returns one of the following values: /// S_OK - the object is safe for loading /// E_NOINTERFACE - the riid parameter specifies an interface that is unknown to the object [PreserveSig] long GetInterfaceSafetyOptions(ref Guid iid, out int pdwSupportedOptions, out int pdwEnabledOptions); ///  /// Returns whether an object is safe for initialization or scripting, as specified. ///  /// An iInterface identifier for the object to be made safe. /// A mask representing the options to be validated. /// A DWORD representing all the options currently enabled for the interface identified by riid.  /// Returns one of the following values: /// S_OK - the object is safe for loading /// E_NOINTERFACE - the riid parameter specifies an interface that is unknown to the object /// E_FAIL - the dwOptionSetMask parameter specifies an option that is not supported by the object [PreserveSig] long SetInterfaceSafetyOptions(ref Guid iid, int dwOptionSetMask, int dwEnabledOptions); }; 

J’ai utilisé l’installateur avancé pour créer le programme d’installation msi et j’ai défini l’ enregistrement dll . Le programme d’installation avancé a ensuite généré toutes les clés de registre nécessaires.

Dans mon test, le fichier inf final était

 [version] signature="$CHICAGO$" AdvancedINF=2.0 [Deployment] InstallScope=user|machine [Setup Hooks] install=install [install] run="""%EXTRACT_DIR%\runmsi.exe""" """%EXTRACT_DIR%\simpleactivex.msi""" 

S’il vous plaît noter les citations sortingples. Ils sont importants.

J’ai utilisé ce ddl

 .Set DiskDirectoryTemplate=. .Set CabinetNameTemplate=simpleactivex.cab runmsi.exe simpleactivex.msi simpleactivex.inf 

Et je construis cab en utilisant ces commandes

 "c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\signtool.exe" sign /sha1 9A15DC8F51773C557BA2F75CF155F8CBD367A8E1 /tr http://tsa/tsa /d SimpleActiveX /du "http://yourcompany.com" /v runmsi.exe simpleactivex.msi makecab /V3 /F make.ddl "c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\signtool.exe" sign /sha1 9A15DC8F51773C557BA2F75CF155F8CBD367A8E1 /tr http://tsa/tsa /d simpleactivex /du "http://yourcompany.com" /v simpleactivex.cab 

runmsi.exe est un fichier exe factice qui exécute msiexec avec des parameters donnés. Sinon, vous pouvez utiliser l’installateur exe ou l’installateur bootstrap et msi. La partie importante à noter est que IE ne permettra pas d’exécuter quelque chose en dehors du fichier cab. Par conséquent, vous devez faire ce piratage.

Lors du débogage, j’ai utilisé cette page HTML factice

    WebForm1