COM+ Integration

Topics: Building and extending application blocks, Caching Application Block
Mar 20, 2007 at 11:11 PM
Edited Mar 20, 2007 at 11:26 PM
I'm having problems with the COM+ and the Caching Application Block class. Here's what I've got:

1. I have a COM+ application. Under the Acitivation tab for the properties of this application I have "Server application" selected. I also have the Application Root Directory pointed to a folder that contains an Application.config file and an Application.manifest file.

2. I have a class with methods in it to read/write information to the Caching Application Block. I also have a method that returns the desired connection string using System.Configuration.ConfigurationManager.ConnectionStrings"Remote Cache".

3. I'm using Enterprise Library 2.0, and I have all the Enterprise Library assemblies strong named and residing in the GAC. My class contains a reference to Microsoft.Practices.EnterpriseLibrary.Caching.

4. I have an ASP page that creates an instance of my COM+ application. When I call the method to return the desired connection string it retrieves it just fine. This means that my COM+ application is looking in the correct directory for the Application.config file.

HOWEVER, When I call the method from ASP to write information to the Caching Application Block I get an "Invalid pointer" error. The first line in the method is "CacheManager manager = CacheFactory.GetCacheManager("Remote Cache");". This code works fine when I run it using a Console App.

I believe the problem is that the Caching Application Block is not finding the Application.config file in the folder that I've point my COM+ application to use as its Application Root Directory. What can I do to solve this issue.
Mar 26, 2007 at 6:13 PM
If you are calling a COM+ application from ASP the Caching Application Block will have problems to find the configuration file. To solve this issue you can try to use Enterprise Library Caching without a configuration file.

Check this link for instructions:

http://jelle.druyts.net/2006/03/28/EnterpriseLibraryCachingWithoutConfiguration.aspx

If you try it please let me know if work, I’m very curious about Caching Application Block performance working with COM+.
Mar 26, 2007 at 9:53 PM

andresjoaquin wrote:
If you are calling a COM+ application from ASP the Caching Application Block will have problems to find the configuration file. To solve this issue you can try to use Enterprise Library Caching without a configuration file.

Check this link for instructions:

http://jelle.druyts.net/2006/03/28/EnterpriseLibraryCachingWithoutConfiguration.aspx

If you try it please let me know if work, I’m very curious about Caching Application Block performance working with COM+.


Thanks for the reply. This does seem to work with COM+, however it doesn't write to a DataStore as is. Some code modifications would be needed to make this work.

However, what I'm doing is using Classic ASP to create an object instance of a DLL. The ASP calls the DLL methods that update the cache. This means that on every page when you need the cache you have to do:

 
   Set cache = Server.CreateObject("RemoteCaching")

This means that every page will create a new instance of the cache and not allow the pages to share cache data. This can be overcome though by setting an application variable and checking it at the top of every page:

 
   If Len(Application("cachemanager")) = 0 Then
      Application("cachemanager") = Server.CreateObject("RemoteCaching")
   End If
 
   Set cache = Application("cachemanager")

This will allow for sharing the cache between pages, however I need the data written to a backing store because my web application is on multiple servers for load balancing.

After doing some reading about using Caching Application Block across multiple servers, I've found that it is frowned upon due to some unexpeced behavious that could arise. I've created my own caching class that works side-by-side with the Caching Application Block. It reads the web.config file and gets cache settings defined by the Enterprise Library Configuration tool. The methods of the class (such as Add, GetData, etc.) mirror those of the CacheManager methods, but call the stored procedures that were created when you build the Caching database from the script provided with the Enterprise Library download (I had to create a GetData stored procedure).

My caching class does not utilize an in-memory cache, but that may change in the future. It also doesn't recognize scavenging settings and when you add an item to the cache it sets the scavenging priority to CacheItemPriority.NotRemovable so the record will not be touched by the scavenging process.
Mar 27, 2007 at 10:42 AM
There is no problem using config-files when using Com+.

I've doing this all the time. But there seems to be some problems when using com+ transactioncontext.

Here is an article on the subject: Com+ configuration .Net