How to fix the enumeration name problem between. NET and COM (continued)

Source: Internet
Author: User

In the previous article "how to fix the enumeration name problem between. NET and com ",ArticleBut run-time error "429" may occur during running. ActiveX cannot be created. The key issue is that. netProgramThe reason why the set is not registered, You need to register it through regasm. The procedure is as follows:

1. Compile the. NET Program

2. Use the following batch to export TLB files

@ Echo off

Set bindir = "C: \ Program Files \ microsoft sdks \ windows \ v7.0a \ bin"

% Bindir % \ tlbexp pctseventlog. dll

% Bindir % \ tlbexp pctsauditlog. dll

Rem "C: \ WINDOWS \ Microsoft. NET \ framework \ v2.0.50727 \ regasm" pctseventlog. dll/regfile: pctseventlog. Reg

Rem "C: \ WINDOWS \ Microsoft. NET \ framework \ v2.0.50727 \ regasm" pctsauditlog. dll/regfile: pctsauditlog. Reg

Call "C: \ Program Files \ microsoft sdks \ windows \ v7.0a \ bin \ oleview. EXE"

Rem pause

3. Open Ole view, export the IDL file, and compile it using the following command.

@ Echo off

Call "C: \ Program Files \ Microsoft Visual Studio 10.0 \ Vc \ vcvarsall. Bat" x86

Set bindir = "C: \ Program Files \ microsoft sdks \ windows \ v7.0a \ bin"

% Bindir % \ midl pctseventlog. IDL

% Bindir % \ midl pctsauditlog. IDL

Pause

4. After compilation, copy the generated DLL and TLB files to the target machine. Run the following command to register and add the assembly to the GAC (full-set shared cache ):

@ Echo off

Gacutil/I pctseventlog. dll

Gacutil/I pctsauditlog. dll

Gacutil/I InterOP. erconnect. dll

Regasm pctseventlog. dll

Regasm pctsauditlog. dll

Regasm InterOP. erconnect. dll

Rem Regedit/s pctseventlog. Reg

Rem Regedit/s pctsauditlog. Reg

Rem "C: \ WINDOWS \ Microsoft. NET \ framework \ v2.0.50727 \ regtlibv12" "C: \ work \ bin \ release \ net \ pctseventlog. TLB"

Rem "C: \ WINDOWS \ Microsoft. NET \ framework \ v2.0.50727 \ regtlibv12" "C: \ work \ bin \ release \ net \ pctsauditlog. TLB"

Rem regasm pctsauditlog. dll/T

Rem regasm pctsauditlog. dll/T/u

Rem pause

5. You can call the. NET assembly in COM.

7. When you perform multiple modifications and debugging, you can use the following command for reverse registration:

@ Echo off

Gacutil/u pctseventlog

Gacutil/u pctsauditlog

Gacutil/u InterOP. erconnect. dll

Regasm pctseventlog. dll/T/u

Regasm pctsauditlog. dll/T/u

Regasm InterOP. erconnect. dll/u

Rem "C: \ WINDOWS \ Microsoft. NET \ framework \ v2.0.50727 \ regtlibv12"/u pctseventlog. TLB

Rem "C: \ WINDOWS \ Microsoft. NET \ framework \ v2.0.50727 \ regtlibv12"/u pctsauditlog. TLB

Rem pause

Everything is done !!

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.