.NET assembly and COM interoperation

Recently, I just learned how to make .NET assembly visible for COM interoperation. I found that there are several ways to complete this task; on my view, two steps is needed are :

- Signing an assembly with a strong name: we must have a key pair (I can also create a new keypair by using
sn.exe tool ), after that, sign the assembly by Assembly Linker al.exe provided by .Net SDK or use the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute , open the file AssemblyInfo.cs in your project and look at the last, pls read the list of articles below for more info.

- And customize the visible of .Net assembly:
At first, the .net assembly must match the qualify for COM interop. See this article to reach what's qualify : Qualifying .NET Types for Interoperation.
The assembly is OK, and ..in Visual Studio, I open my project ( class library ;) ) and I see there's a property named : "Register for COM interop", if check this, VS auto generates interface, implement in your classes and register your assembly; if success, a tlb ( type library ) is created in your project "bin" directory.
Or I can register manually by using the regasm.exe provided by .Net SDK.

The usually path ;)
sn.exe C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin
al.exe C:\WINDOWS\Microsoft.NET\Framework\(v1.1.4322) (choose .net version)
regasm.exe C:\WINDOWS\Microsoft.NET\Framework\(v1.1.4322)


0 nhận xét:


Coding experience share Copyright © 2010 | Designed by Ipietoon for Free Blogger Template