.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

Explain custom activities, Explain Custom Activities. In addition to th...

Explain Custom Activities. In addition to the standard activities available within the base activity library, you can make new activities to meet exact business needs. Creating

Multi-threading, What is Multi-threading? Multi-threading process forms...

What is Multi-threading? Multi-threading process forms the subset of Multi-tasking. Inspite of having to switch between programs this feature switches between different parts o

Software bot for domain parking, I have 10 domains which are presently park...

I have 10 domains which are presently parked, now I need a software/Bot which generate clicks on the ads placed on the website. These clicks which are generated should use proxy to

What is xml dom, What is XML DOM? The DOM stands for Document Object Mo...

What is XML DOM? The DOM stands for Document Object Model, which explains the logical formation of documents and provides the way to access and manipulate a document. It suppli

Data set and data reader, What is difference between data set and data read...

What is difference between data set and data reader? Some major differences between dataset and datareader are as folows :- 1) The DataReader gives forward-only and read-onl

Seeking somebody to develop a web-based registration screen, Classic ASP ...

Classic ASP I am seeking somebody to develop a web-based user registration screen (List, New, Modify and Delete) preferably using classic ASP framework. The coding must be st

Basic use of "dataview", What is basic use of "DataView"? The "DataView...

What is basic use of "DataView"? The "DataView" represents the whole table or can be small parts of rows depending on some criteria. It is the best used for sorting and finding

Web based program completed with .net, We have a web based program complete...

We have a web based program completed with .NET C# and Microsoft SQL Server. There are some reports requires to be created. Required Skills. - High Proficiency in .NET C#

Define the term viewstate as used in the asp.net framework, Problem: (a...

Problem: (a) Define the term ViewState as used in the ASP.NET framework. (b) What is a StateBag class? Give a simple example to support your answer. (c) (i) Distingui

Triple constraint traingle, What is triple constraint triangle?   ...

What is triple constraint triangle?   Figure: -Project Management Triangle The Project Management triangle is depicted as Cost, Schedule & scope. These 3 aspects for

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