2014-07-28

Windows 7 Won’t Boot: 0x0000007B

My Windows 7 PC would not boot. It turned out some of the boot files were corrupt or missing, and I got a bluescreen during startup:
https://flic.kr/p/odkE3W.

Also when I tried to fix the problem using automatic recovery I got an error saying “Failed to Save Startup Options”.

Luckily someone else had had the same problem:
http://answers.microsoft.com/en-us/windows/forum/windows_7-system/bootmgr-error-cant-load-windows-automatic-repair/e2f50f68-a49a-4936-8ca6-8d920557262a?rtAction=1406539673501

Solution summary:

1. Open the command prompt from the recovery console.

2. Run: BOOTREC C:\Windows C:

It will create new boot files on your C-drive. The first parameter is your windows folder.

3. If your boot sector is in fact damaged (mine was not) you should probably drill deeper into the Community answer mentioned above and follow the steps.

2014-04-28

System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL

I run into this error message from time to time, and every time I have forgotten what to do, hence I am writing it here.

This is the command:
netsh http add urlacl url=http://+:80/MyUri user=DOMAIN\user

Source:
http://msdn.microsoft.com/en-us/library/ms733768.aspx

2014-02-06

EPiServer PageReference Extension: FindPagesOfType<T>(…)

Here’s my extension method for searching for pages of a given type T under an EPiSever (PageTypeBuilder) Page referred to by the PageReference which this method extends.

public static IEnumerable<T> FindPagesOfType<T>(
this PageReference pageLink, string languageBranch)
where T : TypedPageData
{
    //get page type id from type
    var pageTypeId = PageTypeResolver.Instance.GetPageTypeID(typeof(T));

    if (!pageTypeId.HasValue)
        return new List<T>(); //return empty enumerable

    // Create criteria collection
    var criterias = new PropertyCriteriaCollection
        {
            // Find pages of a specific page type                       
            new PropertyCriteria()
                {
                    Name = "PageTypeID",
                    Condition = CompareCondition.Equal,
                    Required = true,
                    Type = PropertyDataType.PageType,
                    Value =  pageTypeId.Value.ToString("0")
                }
        };

    var pages =
        DataFactory.Instance.FindPagesWithCriteria(
            pageLink,
            criterias,
            languageBranch,
            new LanguageSelector(languageBranch))
            .Cast<T>();

    return pages;
}

Example usage:

var myArticles =
PageReference.StartPage.FindPagesOfType<Article>(CurrentPage.LanguageBranch);

2014-01-28

Invalid User Control Reference added by ReSharper?

ReSharper usually offers nice autocomplete suggestions. However when on a WebForm, adding a WebUserControl and then clicking the autocomplete popup suggestion adds an usnusable Register statement. Here’s an example of such a statement:

<%@ Register TagPrefix="PRE" Namespace="My.Namespace" Assembly="My.Namespace" %>
What happens when this is added is that the compiler thinks everything is fine, but when you try to run it the controls inside your user control will be null.
The proper statement should be like this:
<%@ Register TagPrefix="PRE" TagName="MyControl" Src="~/templates/Units/MyControl.ascx" %>
Ref my Stack Overflow question:
http://stackoverflow.com/questions/13305213/aspnet-webforms-server-control-is-null-in-page-load