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 !!