Showing posts with label Troubleshooting. Show all posts
Showing posts with label Troubleshooting. Show all posts

Thursday, 19 February 2015

Permission denied when pushing to GitHub remote repository

When I tried to push code to GitHub recently, I got the following error despite running PuTTY and loading the SSH key that was associated with my GitHub account:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

It turned out that one of my settings in Git Extensions had reverted. I went into Settings, Settings, Ssh and selected the option against PuTTY. I was then able to push successfully.

Friday, 19 July 2013

RESTORE cannot process database 'X' because it is in use by this session

When running a restore database query, I got the above error in SQL Management Studio. This was due to having the database 'X' selected in the dropdown list of databases, as suggested by the second part of the error message, which stated "It is recommended that the master database be used when performing this operation."

I changed the dropdown to another database 'Y' and was able to re-run the query without error.

Tuesday, 9 July 2013

Missing Context Menu on Item in Team Development for Sitecore (TDS)

I recently had a problem in which I tried to "get" items from Sitecore using TDS. The item I was trying to get had several immediate children; however, the get only fetched the top item. When I right-clicked it to try to delete, no context menu appeared. I checked the file system and found that the .item file did not physically exist, so I reloaded the Visual Studio solution. This removed the item from the Solution Explorer, but did not explain what had gone wrong.

I eventually discovered the issue was due to having an alias item of the same name at the same level in Sitecore. Once I'd renamed the alias, I could correctly get the item and all of its children.

Wednesday, 13 July 2011

Lucene: Compression support not configured

I got this error when trying to extract Hits.Doc from Lucene:

Compression support not configured

at SupportClass.CompressionSupport.CheckCompressionSupport()
at SupportClass.CompressionSupport.Uncompress(Byte[] input)
at Lucene.Net.Index.FieldsReader.Uncompress(Byte[] input)
at Lucene.Net.Index.FieldsReader.AddField(Document doc, FieldInfo fi, Boolean binary, Boolean compressed, Boolean tokenize)
at Lucene.Net.Index.FieldsReader.Doc(Int32 n, FieldSelector fieldSelector)
at Lucene.Net.Index.SegmentReader.Document(Int32 n, FieldSelector fieldSelector)
at Lucene.Net.Index.IndexReader.Document(Int32 n)
at Lucene.Net.Search.IndexSearcher.Doc(Int32 i)
at Lucene.Net.Search.Hits.Doc(Int32 n)


The solution was to add the following missing keys into Sitecore AppSettings.config:

<add key="Lucene.Net.FSDirectory.class" value="Sitecore.Data.Indexing.FSDirectory, Sitecore.Kernel" />
<add key="Lucene.Net.CompressionLib.class" value="Sitecore.IO.Compression, Sitecore.Kernel" />

Tuesday, 17 May 2011

The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.

I get this error from time to time when editing plain text files in Visual Studio. I tried correcting it by going to File, Save As, Save with Encoding (in the Save dropdown). This seemed to do the trick about 50% of the time. However, it would seem this was just coincidence. Latest findings suggest it is a Firefox cache problem. I tried the same URL in another browser and it worked. Fingers crossed this is a fix.

Friday, 14 January 2011

Non white space characters cannot be added to content.

When trying to initialise an XDocument with a string containing XML, I kept getting the error:

Unhandled Exception: System.ArgumentException: Non white space characters cannot be added to content.

With help from a colleague, and recalling how I'd got around this error previously, the solution is to use the static XDocument.Parse( string ) method. Eg:

var myXDoc = XDocument.Parse( xmlString );

Wednesday, 1 December 2010

SOAP header Security was not understood

XML Web services seem to be declining in use, so finding information on this SoapHeaderException proved to be a bit difficult. I added in <soapextensionimportertypes> and installed WSE 3.0, but it made no difference. What worked for me was adding the following line to my code:
webService.SoapVersion =
System.Web.Services.Protocols.SoapProtocolVersion.Soap12;


[Edit 9 Dec 2010]

Actually, this was a red herring. It worked by adding a "service reference", rather than a old-fashioned "web reference".

Tuesday, 15 June 2010

Sitecore link fields put /home in the target URL's href

When using sc:fld('fieldname', ., 'url') in an XSLT rendering to get a link field's target URL, you will find that the href includes '/home'. This is rarely desirable. Thankfully, it's easy to solve. Simply use sc:fld('fieldname', ., 'id') instead to get the target ID. You can then pass the ID to sc:path().

Tuesday, 17 November 2009

The solution is offline because its associated Team Foundation Server is offline

When opening a solution in Visual Studio 2008, I kept getting the following message in the Output window:

This solution is offline. [Team Foundation Server:
http://server:8080/]
The solution is offline because its associated
Team Foundation Server is offline.

I kept having to go into the "change source control" and re-bind the solution. After a while, this began to get annoying. Then I found this post: http://www.eggheadcafe.com/software/aspnet/33487526/connecting-automatically.aspx. It turned out the solution was to set some registry keys. I navigated to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers\ and changed "Offline" to 0 and "AutoReconnect" to 1. I've no idea how these got reset! (Please back-up your registry first if you want to try the same.)

Friday, 13 November 2009

System.ArgumentException: Illegal characters in path

This exception caused me a headache for an hour today on a development web site. After various rebuilds failed to cure the issue, I found out that the aspnet_wp.exe process had somehow become corrupted. Re-saves of the web.config file didn't help, so I opened Task Manager, killed the process and was back up and working again.

Friday, 14 August 2009

Write to Sitecore log file from XSLT

It is simple to write to the Sitecore log file from within an XSLT file without having to write any custom code. We can just hook up to the Sitecore.Diagnostics.Log class and call one of its methods.

In the web.config, define the extension under <xslextensions>:

<extension mode="on"
type="Sitecore.Diagnostics.Log, Sitecore.Kernel"
namespace="http://www.sitecore.net/log"
singleInstance="true" />

Within the XSLT file, add a prefix that matches the namespace you used in the above step:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sc="http://www.sitecore.net/scReal"
xmlns:dot="http://www.sitecore.net/dot"
xmlns:log="http://www.sitecore.net/log"
exclude-result-prefixes="dot sc log">

The Log class contains a number of overloads for Info, Warn, Error and so on. Some of these expect an exception as a parameter, so we cannot call these direct from XSLT. We can, however match the overloads that expect a string and an object (eg. Warn( String, Object )):

<xsl:value-of select="log:Warn('Warning message', 'Another string... perhaps the name of your rendering file')" />

That's it! Now you can log whatever you like from within your renderings.

Tuesday, 28 July 2009

The type initializer for 'Sitecore.Search.SearchManager' threw an exception

If you get this (or similar) error, check that the version of the Sitecore.Kernel.dll referenced by class libraries is the same as used by the web site. It fixed a problem I had anyway!

Tuesday, 14 July 2009

Using a Clean Sitecore Client for Authoring

I had a situation this week where I could not get the Sitecore client to work on my local machine. Although I could browse the end web site, I got the dreaded vague null reference exception when trying to browse to /sitecore. As the web site was fairly complex, I was finding it very painful to try to re-contruct from new. In the end, it dawned on me that all I needed to do was install a clean Sitecore client that was completely separate from the web site. This gave me the ability to change content, while the end web site enabled me to view the effect of code changes. This set-up has other benefits too; the Sitecore client runs unimpeded by any custom code (unless you are using pipelines, etc.). This makes it easier to identify/eliminate custom code as a possible cause for any slowness. Similarly, you can readily identify if any errors in the log are due to your code.

Thursday, 9 July 2009

Value cannot be null

When trying to open the Sitecore client (ie. by putting /sitecore in the URL), I got the following exception:

Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: item
Source: Sitecore.Kernel
at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
at Sitecore.Web.UI.HtmlControls.Menu.AddFromDataSource(Item item, String target)
at Sitecore.Web.UI.HtmlControls.DataContextMenu.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I noticed that the URL had changed to /sitecore/shell

With so few clues as to the cause, I simply entered the full path to the log-in screen (/sitecore/login). The log-in screen loaded and I was able to log in successfully.

Out of curiosity, I logged out again and then re-tried /sitecore on its own. The log-in screen opened OK that time. I've no idea as to the cause and I don't fancy investigating. If you're having the same problem, why not try what I did? Good luck.

Wednesday, 15 April 2009

SqlParameter is Already Contained in Another SqlParameterCollection

This exception occurred between calls to a method I used to populate a SqlCommand object.

SqlCommand cmd = conn.CreateCommand();

...

foreach (SqlParameter sqlParameter in sqlParameters)
{
cmd.Parameters.Add(sqlParameter );
}


The solution was to clear the parameter collection at the end of the method (in a finally block, actually):

cmd.Parameters.Clear();

Thursday, 9 April 2009

Button click event handler fires twice

I had a simple button on a form together with its click event handler. On debugging, I noticed that the event handler was firing twice. After a long investigation, I decided to check the HTTP headers. These revealed that the "Display Page Validation" option I was using in the Tools menu of the Web Dev toolbar in Firefox was the culprit.



When switched on, this runs the handler a second time, submitting the results to a validator at w3.org. This is something to bear in mind, particularly for code that must only run once, such as handling credit card payments.

Friday, 19 December 2008

Loading this assembly would produce a different grant set from other instances

If you get this exception message when trying to browse an ASP.NET site you are developing, first stop the site in IIS, then clear out the ASP.NET Temporary Files folder that relate to your site (default location is under C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files). Then start IIS and try browsing the site.

Thursday, 4 September 2008

CustomValidator does not fire

Recently, I needed to ensure that a user fill in one of two TextBox controls on a form I was designing. I couldn't use two RequiredFieldValidator controls as that would mandate that both fields be completed. I therefore created a CustomValidator control and added it to the page. It did not work. There was a flaw in my thinking. The control did not ever fire when needed (ie. when both fields are blank), because the control does not, by default, validate blank fields. Thankfully, there is a way to change this. You can set the ValidateEmptyText to true:

<asp:CustomValidator ID="myValidator" runat="server" ErrorMessage="Error message" OnServerValidate="myValidator_ServerValidate ValidateEmptyText="true"></asp:CustomValidator>

Wednesday, 3 September 2008

Windows does not shut down

Slightly off-topic, but if your computer does not respond to an ordinary shutdown command, you can force a shutdown. To do this, select Start, Shutdown in the usual way and, as you click OK, hold down the control key. Use with care as this might terminate processes uncleanly. Always back up your data.

Thursday, 21 August 2008

FindControl Causes Null Reference Exception with NMock

When using NMock on code that uses FindControl, a null reference exception is thrown:

PlaceHolder placeHolder =

(PlaceHolder) _view.MyPanel.FindControl("myplaceholder");

You could use the indexer instead:

PlaceHolder placeHolder =

(PlaceHolder) _view.MyPanel.Controls[0];

But if you insert another control in the panel, you break your code. So, the alternative is to loop through the controls and find a match by ID:

ControlCollection ctrls = _view.MyPanel.Controls;

foreach( Control ctrl in ctrls )
{
if( ctrl.ID == "myplaceholder" )
{
placeHolder = (PlaceHolder) ctrl;
break;
}
}