Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Search Your Question

Monday, May 5, 2008

Can we use .net components in vb? Explain how ?

.NET components can be invoked by unmanaged code through COM Callable Wrapper (CCW) in COM/.NET interop.

There are two prerequisites to creating .NET component, to be used in unmanaged code:

1. .NET class should be implement its functionality through interface. First define interface in code, then have the class to imlpement it. This way, it prevents breaking of COM client, if/when .NET component changes.

2.Secondly, .NET class, which is to be visible to COM clients must be declared public. The tools that create the CCW only define types basedon public classes. The same rule applies to methods, properties, and events that will be used by COM clients.

Implementation Steps -

1. Generate type library of .NET component, using TLBExporter utility. A type library is the COM equivalent of the metadata contained withina .NET assembly. Type libraries are generally contained in files with the extension .tlb. A type library contains the necessary information to allow a COM client to determine which classes are located in a particular server, as well as the methods, properties, and events supported by those classes.

2. Secondly, use Assembly Registration tool (regasm) to create the type library and register it.

3. Lastly install .NET assembly in GAC, so it is available as shared assembly.

No comments:

Archives