Developing Your Own SQL Server Based Data Access Helper using COM+ and VB.NET
(Page 1 of 7 )
This article explains the techniques involved in developing COM+ based data access helpers using VB.NET.
A downloadable file for this article is available
here.
This article is not an introductory piece on COM+ or ADO.NET. If you are very new to COM+, I suggest you go through my previous article at http://www.aspfree.com/c/a/VB.NET/Building-a-Robust-and-Highly-Scalable-
Distributed-Architecture-using-VB-NET/
The entire source code for this article is available in the form of a downloadable zip. The solution was developed using Microsoft Visual Studio 2003 Enterprise Architect with Microsoft SQL Server 2005 Developer Edition on Microsoft Windows Server 2003 Enterprise Edition. Even though I believe that the source code available with this contribution can work with Microsoft Visual Studio.NET 2002, I didn’t really test it in any other environment. I request that you post in the discussion area if you have any problems with execution.
Setting up the COM+ attributes
For any COM+ applications, you need to set up/configure few of the attributes which would affect your application, together with performance and identity. In our case, the following statements will be necessary to configure the COM+ application:
<Assembly: ApplicationName("CoreMSSQLDataAccessHelper")>
<Assembly: ApplicationActivation(ActivationOption.Server)>
<Assembly: AssemblyKeyFile("../../CoreMSSQLDataAccessHelper.snk")>
<Assembly: ApplicationAccessControl()>
The first statement is mainly necessary to provide the name of the application. You can also understand the comment written in the code which looks like an “ApplicationName” attribute; it specifies the name of the COM+ application that will hold assembly components.
The second statement is mainly necessary to make our COM+ application a server based application. The ApplicationActivation.ActivationOption attribute specifies where assembly components are loaded on activation. It could be either Library or Server. The option “Library” makes our application run in the consumer/creator’s process. The option “Server” causes our application to be executed in a separate system process (totally different from the consumer/creator’s process).
The third statement is mainly necessary to make our COM+ application strongly signed. The key file (or Assembly key file) specifies the name of the strong key that will be used to sign the assembly. The sink file must be generated using “sn.exe” as follows:
sn -k CoreMSSQLDataAccessHelper.snk
Every COM+ application is equipped with its own security features by default. To work with default security features, the fourth statement is necessary. There exist several options for security. It may be necessary to deal with a few of them based on your application requirements.
Next: Customizing the COM class a bit >>
More MS SQL Server Articles
More By Jagadish Chaterjee