26.02.2015 Views

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

√<br />

√<br />

√<br />

Using Type library import tool. Tlbimp.exe yourname.dll.<br />

Using interopservices.System.runtime.Interopservices namespace contains class<br />

TypeLib Converter which provides methods to convert COM classes and interface in<br />

to assembly metadata.<br />

Make your custom wrappers.If your COM component does not have type library<br />

then the only way to communicate is writing custom wrappers. That means<br />

communicating directly with COM components.<br />

(I) Once i have developed the COM wrapper do i have to still register the<br />

COM in registry?<br />

Yes.<br />

(A)How can we use .<strong>NET</strong> components in COM?<br />

Twist :- What is CCW (COM callable wrapper) ?, What caution needs to be taken in<br />

order that .<strong>NET</strong> components is compatible with COM ?<br />

.<strong>NET</strong> components can not be used in straight forward way with COM.You will need to create<br />

CCW in order that COM components communicate with .<strong>NET</strong> assemblies.Following are the<br />

different approaches to implement it :-<br />

√<br />

Explicitly declare interfaces..<br />

Public Interface ICustomer<br />

Property CustomerName() As String<br />

Property CustomerCode() As String<br />

Sub AddCustomer()<br />

End Interface<br />

Public Class Customer<br />

Implements ICustomer<br />

Private PstrCustomerName As String<br />

Private PstrCustomerCode As String<br />

Public Sub AddCustomer() Implements ICustomer.AddCustomer<br />

Try<br />

‘ addin of database code can go here<br />

Catch ex As Exception<br />

Throw ex<br />

End Try<br />

39

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

Saved successfully!

Ooh no, something went wrong!