26.02.2015 Views

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

√<br />

The second way to create CCW using InteropServices attributes.Here interfaces are<br />

created automatically.<br />

Following are different type of class attributes :<br />

None :No class interface is generated for the class.This is default setting when you do not specify<br />

anything.<br />

AutoDispatch :- Interface that supports IDispatch is created for the class. However, no type<br />

information is produced.<br />

AutoDual :- A dual interface is created for the class. Typeinfo is produced and made available in<br />

the type library.<br />

In below source code we have used the third attribute.<br />

Imports System.Runtime.InteropServices<br />

_<br />

Public Class ClsCompliant<br />

End Class<br />

Other than class attributes defined up there are other attributes with which you can govern other<br />

part of assembly.Example “GuidAttribute” allows you to specify the GUID,”ComVisibleAttribute<br />

“ can be used to hide .<strong>NET</strong> types from COM etc.All attributes are not in scope of the book as<br />

this is a interview questions book refer MSDN for more details.<br />

√<br />

√<br />

√<br />

Once .<strong>NET</strong> assembly is created using either interface or using interopservices method<br />

we need to create a COM type library using Type library export tool.<br />

Tlbexp (AssemblyName)<br />

The final thing is registering the CCW in registry using regasm tool.<br />

regasm AssemblyName [Options]<br />

Finally refer the TLB in your COM IDE Below is figure showing VB6 IDE referencing<br />

the DLL<br />

Note :- DLL and TLB should be in same directory where the application is executed.<br />

41

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!