.net components in com, DOT NET Programming

Assignment Help:

How can we use .NET components in COM

.NET components can't be used in straight forward way with the COM. You will require to create CCW in order to communicate COM components  with .NET assemblies. Following are some of the different approaches to implement it :-

1)Explicitly declare interfaces

Public Interface ICustomer

Property CustomerName() As String

Property CustomerCode() As String

Sub AddCustomer()

 End Interface

Public Class Customer

 Implements ICustomer

Private PstrCustomerName As String

Private PstrCustomerCode As String

Public Sub AddCustomer() Implements ICustomer.AddCustomer Try

 ' addin of database code can go here

Catch ex As Exception

Throw ex

 End Try

End Sub

Public Property CustomerCode() As String Implements

ICustomer.CustomerCode

Get

 Return PstrCustomerCode

 End Get

Set(ByVal value As String)

PstrCustomerCode = value

End Set

End Property

Public Property CustomerName() As String Implements ICustomer.CustomerName

Get

Return PstrCustomerName

 End Get

Set(ByVal value As String) PstrCustomerName = value

End Set

End Property

 Public Sub New()

End Sub

End Class

The above customer class is going to be used by COM components so all the properties and methods are declared in interface and implemented in the customer class.Customer Name.Customer Code &  AddCustomer are Ist declared in ICustomer & then implemented in the Customer Class. Please Note that the class must have a default constructor.

2)The second way to generate  CCW is by using InteropServices attributes. In this interfaces are created automatically.

 Following are the different type of class attributes :

None:-No class interface is generated for  class. This is the default setting when you do not specify anything.

AutoDispatch :- Interface that supports IDispatch is created for class. However, no type information is generated.

AutoDual :- A dual interface is created for the class. Type information is generated and made available in the type library.

Below are the source code we have used the third attribute.

Imports System.Runtime.InteropServices

  _ Public Class ClsCompliant

End Class

Other than class attributes defined up there are some other attributes with which you can govern other part of  the assembly. For Example "GuidAttribute" allows you to specify the GUID, "ComVisibleAttribute" can be used to hide .NET types from COM etc.

a)When  .NET assembly is created using either interface or by using interopservices method we need to create a COM type library using Type library export tool.

Tlbexp (AssemblyName)

b)The final thing is registering the CCW in registry by using regasm tool.

regasm AssemblyName [Options]

c)Finally refer the TLB in your COM IDE Below is figure showing VB6 IDE referencing the DLL

500_.NET components in COM.png


Related Discussions:- .net components in com

What is the meaning of object pooling, What is the meaning of object poolin...

What is the meaning of object pooling? Object pooling is a method of storing a pool (group) of objects in memory that can be reused later as needed. Whenever, a new object is n

I need game development tutorials, I need Game development tutorials Pro...

I need Game development tutorials Project Description: We need video tutorials like lynda for game development using unity. You must have developed games before and need to s

Develop a windows backup application, Develop a Windows Backup Application ...

Develop a Windows Backup Application Application Goal The goal is to prepare an easy to use application that provides the user peace of mind that all of their firewalls are b

Backend solution up integrate it with the frontend, Project Description: ...

Project Description: System is used for tracking company's activities through several projects by keeping track of incomes and expenses per project. This project is fairly ea

Prepare .net twain application, Prepare .NET TWAIN application to control d...

Prepare .NET TWAIN application to control digital imaging sensor Project Description: We are seeking somebody to create a .NET TWAIN application which will activate a digital

Content page creation, NopCommerce v3.10 - Content Page Creation, Product I...

NopCommerce v3.10 - Content Page Creation, Product Import and Site Customization Project Description: I have an existing website with about 800 products and we could like to

Pareto principle, What is pareto principle? The Pareto principle also p...

What is pareto principle? The Pareto principle also paraphrased as 80/20 principle is simple effective problem tackling way in the management. It says that 20% of your problems

Different levels of iis isolation, What are the different levels Of IIS i...

What are the different levels Of IIS isolation?  The IIS consist of 3 level of isolation as shown below:- LOW (IIS process):- In this type of isolation the main IIS proc

How do i send email message from asp.net?, The ASP.NET provides two namespa...

The ASP.NET provides two namespaces. The first is System.WEB.mailmessage class and the second is System.Web.Mail.Smtpmail class.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd