Completing Your Own SQL Server Based Data Access Helper using COM+ and VB.NET
(Page 1 of 6 )
This article explains the techniques you need to use when developing COM+ based data access helpers using VB.NET.
A downloadable file for this article is available
here.
This article is not an introductory article to COM+ or ADO.NET. If you are very new to COM+, I suggest you to go through a previous article of mine that serves as more of an introduction here.
The entire source code for this article is available in the form of a downloadable zip file. 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.
This article is the second of two parts. You can find the first part here.
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 that the comment written in the code which looks like an “ApplicationName” attribute 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 the 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