Do you have a code example that re-creates this problem?
Yes, I experienced this after upgrading to CMS6 R2. I found that I was unable to re-publish any pages with dynamic content if the dynamic content included HTML (i.e. I have a CodeInclude module that would publish successfully with "test", but would throw the "Invalid hash value" exception when I tried to publish "<b>test</b>"). The solution was to encode the HTML string.
However, this solution isn't much good if a lot of dynamic content exists on your site that isn't encoded. As a result, I've simply added try catch statements to the State property to enable the unencoded content to be loaded, and if re-published, it will be encoded. For what it's worth, here's my code (in VB, because alas, that's what we use):
Public Property State As String Implements EPiServer.DynamicContent.IDynamicContent.State Get Try Return Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(strCode.ToString())) Catch ex As Exception Return strCode.ToString() End Try End Get Set(ByVal value As String) If value.Length > 1 Then value = Replace(value, "&", "&") Try strCode.ParseToSelf(ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(value))) Catch ex As Exception strCode.ParseToSelf(value) End Try End If End Set End Property
Has anyone experienced "Invalid hash value" exception when a dynamic content module is loaded? State value is properly saved/retrieved, but immediately after the State setter is invoked an ArgumentException is thrown saying "Invalid hash value".