 |
| C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 24th, 2008, 11:46 AM
|
|
Authorized User
|
|
Join Date: Apr 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
cache problem
hi,
i am trying to use the cache, but when i want to add an object using the insert method, it returns object reference not set to an instance of an object, i can't figure it out yet why, if i am declaring my cache variable...
i am doing something like this:
Cache myCache = new Cache();
myCache.Insert("object", myObject);
what do you think is happening??
|
|

April 24th, 2008, 04:18 PM
|
|
Authorized User
|
|
Join Date: Apr 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
that's not working... the available methods without instantiate are: Equals, NoAbsoluteExpiration, NoSlidingExpiration and ReferenceEquals
i am doing this:
using System.Web.Caching;
...
...
...
Cache.Insert("myObject", myOtherObject);
and returns this error: An object reference is required for the nonstatic field, method, or property 'System.Web.Caching.Cache.Insert(string, object)'
|
|

April 24th, 2008, 05:06 PM
|
|
Authorized User
|
|
Join Date: Apr 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
it's a web project by the way...
|
|

April 25th, 2008, 01:01 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Could you provide more information? What kind of web project? Are you running this code in the Code Behind of a page? Or maybe in a code file in App_Code?
In the former case, my code should work. In the latter case, try this:
System.Web.HttpContext.Current.Cache.Insert(...);
Hope this helps,
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
|
|
 |