Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Cache in dnn4.0.2Cache in dnn4.0.2
Previous
 
Next
New Post
3/29/2006 12:47 AM
 

in dnn4.0.2 ,we of ten get NullReferenceException  error  in UrlRewriteModule or in useroline Module,or location Module,this occurs randomly.

it is because of the FileBasedCachingProvider not work  correct . I write a simply module to fix this bug .

create a new project name micsCachingProvider.and add a class like this:


Imports System
Imports System.IO
Imports System.Web
Imports System.Reflection
Imports System.Threading
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Framework.Providers
Imports DotNetNuke.Common
Imports DotNetNuke.Services.Exceptions
Imports System.Web.Caching
Imports System.Xml.Serialization

Namespace DotNetNuke.Services.Cache.micsCachingProvider

    Public Class micsCachingProvider
        Inherits CachingProvider

        Private Const ProviderType As String = "caching"
        Private _providerConfiguration As ProviderConfiguration = ProviderConfiguration.GetProviderConfiguration(ProviderType)
      
        Private Shared _objCache As Hashtable

        Private Shared ReadOnly Property objCache() As Hashtable
            Get
                'create singleton of the cache object
                If _objCache Is Nothing Then
                    _objCache = New Hashtable
                End If
                Return _objCache
            End Get
        End Property

#Region "Abstract Method Implementation"
        Public Overrides Function Add(ByVal Key As String, ByVal Value As Object, ByVal Dependencies As CacheDependency, ByVal AbsoluteExpiration As DateTime, ByVal SlidingExpiration As TimeSpan, ByVal Priority As CacheItemPriority, ByVal OnRemoveCallback As CacheItemRemovedCallback) As Object
            If Not objCache.ContainsKey(Key) Then
                objCache(Key) = Value
            End If
            Return (objCache(Key))
        End Function

        Public Overrides Function GetEnumerator() As IDictionaryEnumerator

            Return objCache.GetEnumerator

        End Function

        Public Overrides Function GetItem(ByVal CacheKey As String) As Object
            Return objCache(CacheKey)
        End Function

        Public Overrides Function GetPersistentCacheItem(ByVal CacheKey As String, ByVal objType As Type) As Object
            Return objCache(CacheKey)
        End Function

        Public Overloads Overrides Sub Insert(ByVal CacheKey As String, ByVal objObject As Object, ByVal PersistAppRestart As Boolean)
            objCache(CacheKey) = objObject
        End Sub

        Public Overloads Overrides Sub Insert(ByVal CacheKey As String, ByVal objObject As Object, ByVal objDependency As CacheDependency, ByVal PersistAppRestart As Boolean)

            objCache(CacheKey) = objObject

        End Sub

        Public Overloads Overrides Sub Insert(ByVal CacheKey As String, ByVal objObject As Object, ByVal objDependency As CacheDependency, ByVal AbsoluteExpiration As Date, ByVal SlidingExpiration As System.TimeSpan, ByVal PersistAppRestart As Boolean)

            objCache(CacheKey) = objObject

        End Sub

        Public Overloads Overrides Sub Insert(ByVal CacheKey As String, ByVal objObject As Object, ByVal objDependency As CacheDependency, ByVal AbsoluteExpiration As Date, ByVal SlidingExpiration As System.TimeSpan, ByVal Priority As CacheItemPriority, ByVal OnRemoveCallback As CacheItemRemovedCallback, ByVal PersistAppRestart As Boolean)

            objCache(CacheKey) = objObject

        End Sub

        Public Overrides Sub Remove(ByVal CacheKey As String)

            If Not objCache(CacheKey) Is Nothing Then
                objCache.Remove(CacheKey)
              
            End If

        End Sub

        Public Overrides Sub RemovePersistentCacheItem(ByVal CacheKey As String)

            If Not objCache(CacheKey) Is Nothing Then
                objCache.Remove(CacheKey)
              
            End If

        End Sub

        Public Overrides Function PurgeCache() As String
            objCache.Clear()
            Return String.Format("Purged  of  cache synchronization files.")
        End Function

        Private Function PurgeCacheFiles(ByVal strFiles() As String) As Integer
            objCache.Clear()
            Return 0
        End Function


#End Region

#Region "Private Methods"

 


#End Region


    End Class

End Namespace

 

build this project. and  change the web.config like this :

<caching defaultProvider="micsCachingProvider">
   <providers>
    <clear/>
    <add name="FileBasedCachingProvider" type="DotNetNuke.Services.Cache.FileBasedCachingProvider.FBCachingProvider, DotNetNuke.Caching.FileBasedCachingProvider" providerPath="~\Providers\CachingProviders\FileBasedCachingProvider\"/>
        <add name="micsCachingProvider" type="DotNetNuke.Services.Cache.micsCachingProvider.micsCachingProvider, DotNetNuke.Caching.micsCachingProvider" providerPath="~\Providers\CachingProviders\micsCachingProvider\"/>
    <add name="BroadcastPollingCachingProvider" type="DotNetNuke.Services.Cache.BroadcastPollingCachingProvider.BPCachingProvider, DotNetNuke.Caching.BroadcastPollingCachingProvider" providerPath="~\Providers\CachingProviders\BroadcastPollingCachingProvider\"/>
   </providers>
  </caching>

now it work correct.but this is not a good class, it not implement  CacheDependency,  AbsoluteExpiration , SlidingExpiration , CacheItemPriority,  CacheItemRemovedCallback. i hope the core team can implement  their own cache .

 
New Post
3/29/2006 11:39 AM
 
know there was an issues with the caching provider in 4.0.2.  They released version 4.0.3 to correct the issue, it might be hte smae fix you have posted. 
 
New Post
3/29/2006 8:24 PM
 
thx your post,but where can i download the 4.0.3 release?
 
New Post
3/29/2006 8:51 PM
 
http://sourceforge.net/project/showfiles.php?group_id=77052

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Cache in dnn4.0.2Cache in dnn4.0.2


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out