Use. NET Framework 2.0 and use C # To compile ActiveX Controls (write, deploy, upgrade, and update)

Source: Internet
Author: User
Tags activex update
Turn: http://blog.csdn.net/binwind/archive/2006/05/11/724890.aspx

About a half-month ago, I explored how to use C # To compile ActiveX in. NET 2.0 Framework. I found that there are not many Chinese documents and the Chinese documents widely reprinted are still incorrect (I wonder if it is because of the discrepancy between net 2.0 and 1.0 ). Lori has to do related work recently. Therefore, even if you write a written article for his reference, it is also a summary of the previous work. So that you do not forget it.
This article includes how to write, deploy, and update ActiveX controls.

The article widely reposted in China introduces how to use C #ProgramOfArticleThe source is:
Http://www.cnblogs.com/homer/archive/2005/04/01/86473.html (3 in total)
There is also a Chinese description
Http://www.dvpx.com/index_article_display.aspx? FID = 10 & id = 74
I also started from this article. However, part of the article in ActiveX package is not comprehensive. What's more important is that I don't know whether it is because of the. NET Framework version or the author's negligence. The statement about a comport is incorrect.

First, point out the error:
The IObjectSafety statement in this article is as follows:
[GUID ("CB5BDC81-93C1-11CF-8F20-00805F2CD064"), interfacetype (cominterfacetype. interfaceisiunknown)]
Public interface IObjectSafety
{
// Methods
Void getinterfaccesafyoptions (
System. int32 riid,
Out system. int32 pdwsupportedoptions,
Out system. int32 pdwenabledoptions );
Void setinterfacesafetyoptions (
System. int32 riid,
System. int32 dwoptionssetmask,
System. int32 dwenabledoptions );
}

However, such a statement does not play a corresponding role. An error occurred while declaring the interface. For the correct statement, see the following webpage:
Http://www.pinvoke.net/default.aspx/Interfaces/IObjectSafety.html

Next, let's take a look at the cab package deployment steps.

In this article
[Hook1]
Run = msiexec/I % extract_dir % \ activexinstaller. MSI/Qn
This is the file automatically run after the cab package is decompressed.
While
From the perspective of online query, the deployment of most ActiveX cab packages is demonstrated by the DLL written in C ++, while the DLL written in C # And C ++ is different.
The following is an example of deployment that I have referenced by foreigners.
Http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,df3f1be8-62bc-491c-935e-570ebfe53164.aspx

Now let's talk about my thoughts.

I know two deployment methods.
The first is to use the regasm command for deployment.
People familiar with the deployment of C ++ ActiveX know that regsvr32 is the command to register the ActiveX package written by C ++. Regasm is an ActiveX Command registered under. NET Framework. The specific steps are as follows:
Run = regasm/I % extract_dir % \ XXXX. dll/codebase (XXXX. dll is the packaged DLL file)
(This method is similar to the ActiveX dll written in C ++, but replaces regsvr32 with regasm)

The second and better method (including future updates) is to use the installation program provided by vs for installation.
The specific ideas are as follows:
Add a setup project to ActiveX solution, and add a project output to add ActiveX projects to the project output. The value of the Register attribute is true.
In this case, an installation file can be generated.
In the packaging of the cab package, you should package the package generated by the setup project into the MSI file, package it into the cab package, and write its inf file.
How to create a connection to a cab package
Http://blog.joycode.com/felix/articles/32905.aspx
Cab package format
Http://msdn.microsoft.com/library/default.asp? Url =/Workshop/delivery/download/Overview/infarchitecture. asp? Frame = true
This is an example or written by a foreigner.

Next is the update. The problem with ActiveX written in C # Is that the ActiveX version we see after registration is the. NET Framework version, not the DLL file version. So there is a problem with the original ActiveX update method. However, you can use the update method of setup project. .

Set the removepreviousversion attribute of the setup project to true. The previous version is automatically deleted. The setup project uses a guid to indicate whether it is the same setup project. (Note: it is not the guid of ActiveX ). So when I write a new version. To update the ActiveX of the client, follow these steps:
1. Change the guid of ActiveX (not the guid of setup project.
2. Upgrade the version number of the setup project.
3. Change the classid of ActiveX in the webpage to the new ActiveX ID.

At this time. When you log on to the webpage, a new ActiveX control is displayed, prompting you to download the control (guid changed ). The downloaded installer uses the guid of the setup project to find that the old version has been installed. Uninstall the old version. When uninstalling the SDK, you can install the SDK. ActiveX has been automatically deregistered for a long time.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.