Saturday, July 30, 2005

Image of Whidbey (VS .NET 2005) Island

Whidbey is the code name for Visual Studio .NET 2005. Whidbey is an island north of Seattle and it looks like this:

Friday, July 01, 2005

COM Interoperability

Using .NET Assembly from COM Client
This article explains about the .NET Interoperability with COM.

Step 1: Creating a .NET Assembly Project

1.1 Visual Studio .NET IDE -> File -> New Project ->
Visual Basic Projects -> Class Library

1.2 Name the Application, for instance NetServer, this will
be our .NET Assembly Project,which will be consisting of at
least one class called Class1.vb.

1.3 Rename the class to NetClass from properties window and manually
in code window.This class will hold all the functionality of .NET Component,
in the form of few functions.



Step 2: Adding Functionality

On the path of achieving COM Interoperability, Microsoft .NET
offers an attribute named ,which is
located inside the Micrsoft.VisualBasic namespace
and it makes the .NET Class available for use by a COM Client.

It’s also a wise choice to add System.Runtime.InteropService namespace to the class, which offers various features to be used.

The figure below shows the whole Code of .NET Assembly.



Step 3: Set Property for COM Interoperability

Select NETServer project from Solution Explorer, Right Click ->
Properties -> Configuration Properties -> Build -> Check on
Register for COM Interop



after setting the property, do Build The Solution. It will create
a NetServer.dll (assembly) in your applications \bin folder.

Step 4: Deploying for COM access

A .NET assembly which has been created can’t be used by a COM Client,
because COM Client can access an object with help of a Type Library,
which tells to the Client about the Object.

In .NET world there is no such concept of Type LIbrary, but because of
COM Interop feature, .NET Framework SDK offers a tool called
RegAsm.Exe which offers to make a type library and
register it in Windows Registry, the very own style of COM.

4.1 Access Command Prompt (cmd)

4.2 Change the path to your application folder
for example : C:\>D: press enter
D:\> cd Net Applications\NetServer\Bin
D:\Net Applications\NetServer\Bin>

4.3 Type the following command to create a
Type Library,which is a COM world’s buzz word and equivalent
to Metadata of a .NET Assembly.

D:\Net Applications\NetServer\Bin> RegAsm /tlb: NetServer.tlb NetServer.dll

This command will create a Type Library named NetServer.tlb
in the \bin folder of .NET Assembly application. Which was
automatically registered in Windows Registry as well.

Now the .NET Assembly is ready to use by a COM Client.

Step 5: VB 6.0 Client to access .NET Assembly

5.1 Open Visual Studio 6.0 -> Visual Basic 6.0 ->
File -> New -> Standard.Exe

5.2 Drag one Label and two Command Buttons onto the form.



Step 6: Set Reference to the Type Library

Before consuming the class you build using .NET

Project -> References -> Find the NetServer and select that.



Step 7: Code to access the .NET Class



after adding the code, run your VB 6.0 and click on the command buttons, you will see that your application communicating with .NET Assembly.

Code Names

Thunder - This was the code name for one of the Most facinating RAD tool Visual Basic(VB).

Lightning - This was the code name for .NET CLR(the most adorable one).

Everett – This was the code name for Microsoft Visual Studio .NET 2003. Everett is a city north of Seattle.

Whidbey – This is the code name for Microsoft Visual Studio .NET 2005. Whidbey is an island north of Seattle (you go through Everett to get the ferry to Whidbey Island).

Yukon - This is the code name of the next version of Microsoft SQL Server, with SQL Server 2005 "Yukon" developers will be able to leverage their existing skills in writing .NET-connected software using the Common Language Runtime (CLR) built into the database engine.Yukon is a place in Northern Canada!

Longhorn – This is the code name for the Next version of Microsoft's 64-bit Windows operating system. Longhorn is a bar close to Whistler and Blackcomb ski resorts.

Orcas – Visual Studio .NET 200X code named "Orcas" will support the managed interfaces, enhanced user interface features and other new capabilities the Longhorn operating system will offer. Orcas is an island in the San Juan group of islands even further north of Seattle.