Search code examples
c#iisserializationweb-config

Which config file is used by w3wp.exe process in an application?


I have a issue where I get SerializationException The internal array cannot expand to greater than Int32.MaxValue elements..

The solution to this is adding the below line in the config file.

<AppContextSwitchOverrides value="Switch.System.Runtime.Serialization.UseNewMaxArraySize=true" />

But the problem is even after adding this in web.config file the issue is not getting resolved. .Net version is 4.8 and also restarted the IIS after making changes.

I have used procmon to see the config file used by the w3wp, it shows the config file path as: For some process: C:\inetpub\temp\apppools\Archer\Archer.config For some other process: C:\inetpub\temp\apppools\DefaultAppPool\DefaultAppPool.config

Please help me to know which configuration file is used by the w3wp.exe process as it got reported that particular process.

Here is the stack trace:

<InnerException>
    <ExceptionType>System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
    <Message>Unable to find html field value for typename 'Field'</Message>
    <Source>CompanyTech.Notifications</Source>
    <StackTrace>  at CompanyTech.Notifications.xslt.NotificationXslExtensions.LookupValue(XPathNodeIterator lookupDefinition, XPathNodeIterator objectIdXPath, String pluginPrefix)</StackTrace>
    <InnerException>
        <ExceptionType>System.Runtime.Serialization.SerializationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
        <Message>The internal array cannot expand to greater than Int32.MaxValue elements.</Message>
        <Source>mscorlib</Source>
        <StackTrace>  at System.Runtime.Serialization.ObjectIDGenerator.Rehash()

  at System.Runtime.Serialization.ObjectIDGenerator.GetId(Object obj, Boolean&amp; firstTime)

  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.InternalGetId(Object obj, Boolean assignUniqueIdToValueType, Type type, Boolean&amp; isNew)

  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Schedule(Object obj, Boolean assignUniqueIdToValueType, Type type, WriteObjectInfo objectInfo)

  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteMembers(NameInfo memberNameInfo, NameInfo memberTypeNameInfo, Object memberData, WriteObjectInfo objectInfo, NameInfo typeNameInfo, WriteObjectInfo memberObjectInfo)

  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteMemberSetup(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo, String memberName, Type memberType, Object memberData, WriteObjectInfo memberObjectInfo)

  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo, String[] memberNames, Type[] memberTypes, Object[] memberData, WriteObjectInfo[] memberObjectInfos)

  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)

  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)

  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)

  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)

  at CompanyTech.Notifications.ContentRender.LevelRecordDataContainerDeepCopy(LevelRecordDataContainer levelRecordDataContainer)

  at CompanyTech.Notifications.ContentRender..ctor(IRenderEngine engine, Content content, LevelRecordDataContainer levelRecordDataContainer)

  at CompanyTech.Notifications.Rendering.RenderEngine.GetFieldHtml(Int32 contentId, Int32 fieldId)

  at CompanyTech.Notifications.Providers.Value.ArcherContentNotificationValueProvider.GetHtmlReplacement(String objectId, ValuePlaceholder valuePlaceholder)

  at CompanyTech.Notifications.xslt.NotificationXslExtensions.LookupValue(XPathNodeIterator lookupDefinition, XPathNodeIterator objectIdXPath, String pluginPrefix)</StackTrace>
    </InnerException>
</InnerException>

Solution

  • After adding the below line in the Web.Config the issue got resolved.

    <appSettings>
        <add key= "AppContext.SetSwitch:Switch.System.Runtime.Serialization.UseNewMaxArraySize" value = "True"/>
    </appSettings>