473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Non-web version of System.Web.Caching.Cache

I have an ASP.NET app that calls into some VB.NET components. It passes in
the current application's cache (HttpContext.Current.Cache).

These VB.NET components also get called by a non-ASP.NET application (in
this case a VB.NET windows service). I'd like to create something like the
cache in this service to hold application-wide information (like database
connection strings) and then pass that into the components.

As a test, I tried creating a 'new' System.Web.Caching.Cache object in a
test VB.NET windows app, but I get an error when I try and insert something
into the Cache object created in this way (System.NullReferenceException)
which I assume is because I'm not in a proper HTTP Context etc.

Any suggestions as to the best way to architect this ?

Thanks

Steve
Nov 19 '05 #1
2 3080
Instead of passing in the cache, simply use
HttpRuntime.Cache from the components...you'll need to include the
system.web dll..but everything should work..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Steve W" <Bu*********@community.nospam> wrote in message
news:Ow**************@TK2MSFTNGP15.phx.gbl...
I have an ASP.NET app that calls into some VB.NET components. It passes in the current application's cache (HttpContext.Current.Cache).

These VB.NET components also get called by a non-ASP.NET application (in
this case a VB.NET windows service). I'd like to create something like the cache in this service to hold application-wide information (like database
connection strings) and then pass that into the components.

As a test, I tried creating a 'new' System.Web.Caching.Cache object in a
test VB.NET windows app, but I get an error when I try and insert something into the Cache object created in this way (System.NullReferenceException)
which I assume is because I'm not in a proper HTTP Context etc.

Any suggestions as to the best way to architect this ?

Thanks

Steve

Nov 19 '05 #2
Hi Steve,

Thanks for your posting. As for the HttpContext.Cache or the
System.Web.Caching.Cache class, it is a particular class which is designed
to be used only in ASP.NET enviroment, also, each ASP.NET web application
will has a global cache itself, so when the Cache class instance need to
have a HttpContext to associate with it. Also, we can't directly use it in
a non-ASP.NET appliation since there is no ASP.NET host environment in
those application. If you do need to do some caching work in non-asp.net
application, we may need to implement our own caching mechanism. The
Caching Application Block in MS's application blocks provide such a custom
caching framework, you may have a look to see whether it helps:

#Caching Application Block
http://msdn.microsoft.com/library/en...asp?frame=true

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: lothar | last post by:
re: 4.2.1 Regular Expression Syntax http://docs.python.org/lib/re-syntax.html *?, +?, ?? Adding "?" after the qualifier makes it perform the match in non-greedy or minimal fashion; as few...
5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
25
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
14
by: Patrick Kowalzick | last post by:
Dear all, I have an existing piece of code with a struct with some PODs. struct A { int x; int y; };
11
by: ypjofficial | last post by:
Hello All, So far I have been reading that in case of a polymorphic class ( having at least one virtual function in it), the virtual function call get resolved at run time and during that the...
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
12
by: puzzlecracker | last post by:
is it even possible or/and there is a better alternative to accept input in a nonblocking manner?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.