locked
Issue using Azure Caching RRS feed

  • Question

  • I have been trying to just get the Azure Caching working on any project.  I recieve the following error:

    ================================================================================================

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    Type 'Microsoft.ApplicationServer.Caching.HostNodeDomainConfigurationElementCollection' is an invalid collection type since it does not have a valid Add method with parameter of type 'System.Object'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Runtime.Serialization.InvalidDataContractException: Type 'Microsoft.ApplicationServer.Caching.HostNodeDomainConfigurationElementCollection' is an invalid collection type since it does not have a valid Add method with parameter of type 'System.Object'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

    Stack Trace:


    [InvalidDataContractException: Type 'Microsoft.ApplicationServer.Caching.HostNodeDomainConfigurationElementCollection' is an invalid collection type since it does not have a valid Add method with parameter of type 'System.Object'.]
       System.Runtime.Serialization.CollectionDataContract.GetValidContract(SerializationMode mode) +2639496
       System.Runtime.Serialization.DataContract.CheckAndAdd(Type type, Dictionary`2 typesChecked, Dictionary`2& nameToDataContractTable) +87
       System.Runtime.Serialization.XmlObjectSerializerContext.GetDataContractsForKnownTypes(IList`1 knownTypeList) +173
       System.Runtime.Serialization.DataContractSerializer.get_KnownDataContracts() +35
       System.Runtime.Serialization.XmlObjectSerializerContext.GetDataContractFromSerializerKnownTypes(XmlQualifiedName qname) +43
       System.Runtime.Serialization.XmlObjectSerializerContext.ResolveDataContractFromKnownTypes(XmlQualifiedName typeName) +2635431
       System.Runtime.Serialization.XmlObjectSerializerContext.ResolveDataContractFromKnownTypes(String typeName, String typeNs, DataContract memberTypeContract, Type declaredType) +76
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType) +150
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType) +280
       System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) +2638814
       System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) +57
       System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) +645
       System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph) +133
       System.Runtime.Serialization.XmlObjectSerializer.WriteObject(Stream stream, Object graph) +220
       Microsoft.ApplicationServer.Caching.Utility.DataContractSerialize(Object obj, IEnumerable`1 knownTypes) +252
       Microsoft.ApplicationServer.Caching.Utility.DataContractSerialize(Object obj) +65
       Microsoft.ApplicationServer.Caching.RequestBody.CreateWcfMessage(ClientVersionInfo versionInfo) +201
       Microsoft.ApplicationServer.Caching.WcfClientChannel.SendMessage(EndpointID endpoint, ICreateMessage data, TimeSpan timeout, WaitCallback callback, Object state, Boolean async, UniqueId id) +1089
       Microsoft.ApplicationServer.Caching.WcfClientChannel.Send(EndpointID endpoint, ICreateMessage message, TimeSpan timeout) +106
       Microsoft.ApplicationServer.Caching.WcfClientChannel.Send(EndpointID endpoint, ICreateMessage message) +79
       Microsoft.ApplicationServer.Caching.SimpleSendReceiveModule.Send(EndpointID endpoint, RequestBody request, Int32 retries) +191
       Microsoft.ApplicationServer.Caching.SimpleSendReceiveModule.SendMsgAndWait(EndpointID endpt, RequestBody reqMsg, TimeSpan requestTimeout, IRequestTracker& tracker) +784
       Microsoft.ApplicationServer.Caching.DataCacheFactory.SendMessage(EndpointID endPt, RequestBody request, SimpleSendReceiveModule sendRcvModule) +185
       Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCacheProperties(RequestBody request, SimpleSendReceiveModule sendRcvModule) +641
       Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName) +701
       Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler`1 fetchingHandler, EventHandler`1 fetchedHandler) +95
       Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateInternalProvider(IHttpRuntime httpRuntime, SessionInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +145
       Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetInternalProvider() +206
       Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateNewStoreData(HttpContext context, Int32 timeout) +19
       System.Web.SessionState.SessionStateModule.InitStateStoreItem(Boolean addToContext) +160
       System.Web.SessionState.SessionStateModule.CompleteAcquireState() +363
       System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1296
       System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +115
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +354

     


    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17020

     

    ================================================================================================

    My Web.config:

    ================================================================================================

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <configSections>
        <section name="dataCacheClients"
                 type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core"
                 allowLocation="true" allowDefinition="Everywhere"/>
      </configSections>
     
      <system.diagnostics>
        <trace>
          <listeners>
            <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
              <filter type="" />
            </add>
          </listeners>
        </trace>
      </system.diagnostics>
     
      <appSettings/>
      <connectionStrings/>
      
      
     
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
     
        <sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider" compressionEnabled="false">
          <providers>
            <add name="AppFabricCacheSessionStoreProvider"
                 type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache"
                 cacheName="default"
                 useBlobMode="true"
                 dataCacheClientName="default"/>
          </providers>
        </sessionState>
     
     
      </system.web>
     
      <dataCacheClients>
        <dataCacheClient name="default">
          <hosts>
            <host name="xxxx.cache.windows.net" cachePort="22233" />
          </hosts>
          <securityProperties mode="Message">
            <messageSecurity
              authorizationInfo="xxxxxxx=">
            </messageSecurity>
          </securityProperties>
        </dataCacheClient>
     
        <dataCacheClient name="SslEndpoint">
          <hosts>
            <host name="xxxxxx.cache.windows.net" cachePort="22243" />
          </hosts>
          <securityProperties mode="Message" sslEnabled="true">
            <messageSecurity
              authorizationInfo="xxxxxxx=">
            </messageSecurity>
          </securityProperties>
        </dataCacheClient>
      </dataCacheClients>

    ================================================================================================

    Any ideas?  I am using Windows 7 x64.

     

    Thank you,

    Frank

    Wednesday, January 4, 2012 3:54 AM

Answers

  • Hi Frank,

    According to you exception message, it seems the Microsoft.ApplicationServer.Caching.HostNodeDomainConfigurationElementCollection get errors with Add method, the rumtime could not find Add method with a object parameter. I suggest you check your code and assemblies is imported.

    You can also provide a test application or some code snippets to us for further debugging.

    Hope it can help you.

     


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework
    • Edited by Arwind - MSFT Thursday, January 5, 2012 9:17 AM
    • Proposed as answer by Arwind - MSFT Monday, January 9, 2012 10:11 AM
    • Marked as answer by Arwind - MSFT Tuesday, January 10, 2012 2:08 AM
    Thursday, January 5, 2012 2:45 AM