This is the second time I've run into this exception when trying to update the Sitecore installation using the provided package.
- Sitecore Certified Developers Forum: Receiving Error: "Could not access value needed to update license snapshot"
This is the second time I've run into this exception when trying to update the Sitecore installation using the provided package.
I've run into this a couple of times now. An ASP.NET control, say the FormView, posts back to the server to change the page contents, say transitioning from the view to edit mode. The page loads, but some of the state or the postback event get lost along the way.
If the same control/code works just fine outside of Sitecore start looking for a solution with the rendering/typesThatShouldNotBeExpanded element in the web.config.
According to ListView and DataPager under Sitecore context"
As Sitecore runs [the] "layout pipeline" during [the] page rendering process, some of the complex ASP.NET controls may fail due to changes in the control tree. Adding type to the mentioned list allows affected ASP.NET controls to work the way they were initially designed.
<!-- RENDERING -->
<rendering>
<typesThatShouldNotBeExpanded>
<type>System.Web.UI.WebControls.DropDownList</type>
<type>System.Web.UI.WebControls.GridView</type>
<type>System.Web.UI.WebControls.Repeater</type>
<type>System.Web.UI.WebControls.DataList</type>
<type>System.Web.UI.WebControls.FormView</type>
<!-- Fix issue with the LoginStatus logout link not working when nested in a LoginView -- >
<type>System.Web.UI.WebControls.LoginView</type>
</typesThatShouldNotBeExpanded>
</rendering>
See also:
When using the Page.Header.StyleSheet.CreateStyleRule method I ran into a limitation of the System.Web.UI.WebControls.Style class. I could only set a small subset of the available CSS attributes. In particular, I couldn't set text-align using the WebControls.Style class.
By overriding the Style.FillStyleAttributes method I can add additional CSS attributes to the CssStyleCollection.
class ExtendedStyle : Style
{
private Dictionary<System.Web.UI.HtmlTextWriterStyle, string> extendedAttributes;
public string TextAlign
{
get
{
return GetAttribute(System.Web.UI.HtmlTextWriterStyle.TextAlign);
}
set
{
SetAttribute(System.Web.UI.HtmlTextWriterStyle.TextAlign, value);
}
}
private string GetAttribute(System.Web.UI.HtmlTextWriterStyle attribute)
{
return (extendedAttributes.ContainsKey(attribute))?extendedAttributes[attribute]:null;
}
private void SetAttribute(System.Web.UI.HtmlTextWriterStyle attribute, string value)
{
if (value == null)
{
extendedAttributes.Remove(attribute);
}
else
{
extendedAttributes[attribute] = value;
}
}
public ExtendedStyle()
{
extendedAttributes = new Dictionary();
}
protected override void FillStyleAttributes(System.Web.UI.CssStyleCollection attributes, System.Web.UI.IUrlResolutionService urlResolver)
{
base.FillStyleAttributes(attributes, urlResolver);
foreach (System.Web.UI.HtmlTextWriterStyle attribute in this.extendedAttributes.Keys)
{
attributes[attribute] = extendedAttributes[attribute];
}
}
}
Which allows me to do the following:
Page.Header.StyleSheet.CreateStyleRule(new ExtendedStyle() { TextAlign = "right" }, this, ".foobar");
using System.Drawing;
//...
[TestMethod]
public void ColorTest()
{
//HTML hex color values and expected int conversions
Dictionary<string, int> testValues = new Dictionary<string, int> {
{ "#000000", 0 },
{ "#000001", 1 },
{ "#000100", 256 },
{ "#010000", 65536 },
{ "#666666", 6710886 },
{ "#AAAAAA", 11184810 },
{ "#FFFFFF", 16777215 },
{ "#C25454", 12735572 },
{ "#54C254", 5554772 }
};
foreach (string htmlColor in testValues.Keys)
{
//Drop the #
string hexString = htmlColor.Substring(1);
//convert the 6 char hex color value to an int
//similar to the JavaScript parseInt(hexString, 16) function
int convertedValue = Convert.ToInt32(hexString, 16);
int convertedValueAlternative = int.Parse(hexString, System.Globalization.NumberStyles.HexNumber);
Assert.AreEqual(convertedValue, convertedValueAlternative);
//convert the int to the 6 char hex color value
string hexStringFromInt = convertedValue.ToString("X").PadLeft(6, '0');
Assert.AreEqual(hexString, hexStringFromInt);
//Check that the converted value matches the expected value
int expectedValue = testValues[htmlColor];
Assert.AreEqual(expectedValue, convertedValue);
//Get the System.Drawing.Color from the hex color value
Color c = ColorTranslator.FromHtml(htmlColor);
//Get the hex color value from the System.Drawing.Color
string htmlHexColor = ColorTranslator.ToHtml(c);
Assert.AreEqual(htmlColor, htmlHexColor);
}
}
The Sitecore version appears on the shell Login page. Which is typcally at http://domain/sitecore/login/
It may also pay to check the DLL versions as the interface might be lying about the actual version.
From code try:
I ran into an issue when writing unit tests code that used the Sitecore CMS6 Sitecore.Disagnostics.Log class. My App.config had a log4net section but nothing was being logged to the appenders.
Using reflector I found out the Sitecore.Diagnostics.Log.Enabled returns Sitecore.Configuration.Settings.ConfigurationIsSet. So I added the configSection:
<section name="sitecore" type="Sitecore.Configuration.ConfigReader, Sitecore.Kernel" />
and a stub sitecore section to get things working.
SettingsPropertyValue settingsPropertyValue = new SettingsPropertyValue(settingsProperty);
settingsProperty.PropertyType = typeof(string); //Must set the type to use the PropertyValue
settingsPropertyValue.PropertyValue = "FooBar";
Assert.AreEqual("FooBar", settingsPropertyValue.PropertyValue);
If the SettingsProperty.PropertyType isn't set you will get a NullReferenceException when trying to access the PropertyValue.
See Also: Profile Provider Exception