Original address: http://www.cnblogs.com/zhf/archive/2009/03/02/1401299.html
Development environment for VS 2005,. NET Framework 2.0
Project, new file
The following dialog box pops up
Select Windows Control Library Enter a name TestControl click "OK"
In the design window, drag the control Label1 Timer 2 buttons such as:
1. com's interface and class creation
COM Interface (Interface): IMonitor
Code
COM Class (Class): Monitor
Code
1) The GUID specifies the GUID of the class or interface.
2) Declare the attribute InterfaceType (cominterfacetype.interfaceisdual), ComVisible (true), to support register and unregister.
3) IMonitor is COM interface. C # 's COM Class can inherit from COM interface or not interface.
2 Implementing the IObjectSafety interface
Microsoft IObjectSafety interface definition, GUID fixed value, general do not modify, can also regenerate GUID in menu bar tool, create GUID
Statement:
Objectsafety
Code
Monitor implementation:
Code
IObjectSafety is an interface that exposes its functionality to Internet Explorer's "Set script security" and "Set initialization security" security features.
3. Registration and uninstallation
If the class declaration uses the InterfaceType, ComVisible (True) property, and the Project property page is set to "Register for COM Interop" entry for "production", then the VS compilation item can be automatically registered for class.
You can also use the VS2005 tool Regasm.exe to manually register and uninstall Class, and you can use the VS self-tool oleview to see if the registration is successful
4. Testing and Commissioning
1) Create a test page solution right-click Add New Web site default.aspx
Code
2) Copy the test page to the root directory of localhost (install IIS, set the TestControl root directory for IIS configuration detailed steps skip)
3) can start debugging
5. Release
1) Establish a Windows Setup project and add the main output of the ActiveX control to the project. Then, change the properties of the ActiveX control's main output file to change its Register property to vsdrpcom.
2) Compile the project and get the MSI installation file Classroomviewercontrol.msi
3) Create and write INF file classroomviewercontrol.inf
[version]
Signature= " $CHICAGO $"
Advancedinf=2.0
[Setup hooks]
Hook1=hook1
[Hook1]
Run=msiexec.exe /i "%extract_dir%\classroomviewercontrol.msi " < Span style= "color: #000000;" >/QN&NBSP;
4) Create a CAB file using the tools in the Cab SDK CABARC.EXE (http://support.microsoft.com/kb/310618)
Cabarc. Exe-s 6144 n classroomviewercontrol.cab classroomviewercontrol.msi classroomviewercontrol.inf
-S 6144: Leave 6k space for signature n Create a cab
5) signature, col.pfx as key
signtool sign/f col.pfx classroomviewercontrol.cab
6) Modify the Web PAGE hello.html and copy the cab to the URL specified by the CODEBASE
<object id= "Monitor" classid= "Clsid:627ad403-fa50-4a08-b875-770520865dd6" width= "640" height= "" codebase= "Http://localhost/TestControl/ClassroomViewerControl.cab" > </object>
6. Finally look at the effect
Installation hides the MSI installation interface, similar to the effect of CABARC packaging OCX (click Install after the others have done in the background)
Note: There is no popup in IE. cab installation windows such as:
This requires that you set the security options for IE
Tools in IE browser->internet options--security
Click "Custom Level" to pop up the following window
Enable the ActiveX control and plug-in related options to click OK
Test again if the popup "Windows has blocked this software because the Publisher cannot be verified" prompt
Click "Site"
Add Htt://localhost and http://10.122.89.28/native IP
The check box below is removed to add
VS2005 How to apply custom ActiveX controls in ASP.