Live RSS Feeds

Subscribe to my feed Subscribe to my RSS Feed by selecting the orange image (left) or selecting the links at the bottom of the page.

Posted by David Kiff (RSS@Davidkiff.co.uk) on 27 July 2008 01:18 in the ASP.NET category

Generate Local Resource - Missing/Greyed out

For some reason my "Generate Local Resource" disappeared from the Tools menu in Visual Studio 2008. To correct this follow these steps:

  1. Go to Tools > Customise > Commands Tab
  2. Select the Tools Category on the left
  3. Rearrange Commands > Select the "Add..." button
  4. Select the "Tools" option on the left (in Categoris list box)
  5. Under commands select "Generate Local Resource"
  6. Select the Ok button then close the remaining windows.

After adding the command back to the tools menu, it appeared Greyed out. If you open an ASPX page and select Designer Mode, it will become active!

Posted by David Kiff (RSS@Davidkiff.co.uk) on 23 March 2008 09:54 in the General category

New smarter re-write!

DavidKiff.co.uk has undergone a radical new re-write so it’s now easier to update and runs on a sturdy SQL Server backend rather than the old Access one!

I hope you like the new look!

Posted by David Kiff (RSS@Davidkiff.co.uk) on 17 February 2008 06:31 in the WCF category

WCF Open Service Host Error

WCF "Your process does not have access rights to this namespace"

This is the error message I received when starting a WCF service in windows vista. The problem is down to Vista security restrictions (UAC) not allowing applications to open ports (start listening on a port.

There are a few ways to resolve this issue:

  1. Run the WCF host with administrative rights (not recommended) by right clicking your .exe and selecting “run as administrator”.
  2. Use netsh.exe to allow a user to start listening on the port(s) you specify:
    “netsh http add urlacl url=http://+:8080/ user=COMPUTERNAME\USERNAME”

This example allows the username specified to start listening on port 8080 with any IP address or hostname.

To find a list of commands run “netsh http”.

Domain Users: Replace “COMPUTERNAME” with the name of your domain.

Posted by David Kiff (RSS@Davidkiff.co.uk) on 01 August 2007 01:18 in the ASP.NET category

Global.asax Session_Start Not Fireing

I have spent an hour trying to work out why the session start was not fireing within my global.asax file! It turns out that I was adding it to a pre-complied application!

Dont make my mistake!

Posted by David Kiff (RSS@Davidkiff.co.uk) on 08 July 2007 02:41 in the ASP.NET category

Custom Crumbline based on URL

A few people have asked me how to create a crumbline based on the URL, for example:

www.mydomain.com/Hello_World/MyPage.aspx
www.mydomain.com/DotNet/Examples/FirstExample.aspx

The first one should display:
Home > Hello_World > MyPage.aspx
Second should display:
Home > DotNet > Examples > FirstExample.aspx

Here is a method for doing so:

private string CreateCrumb()
{
    string[] pathNames = Request.RawUrl.Split(‘/’);
    System.Text.StringBuilder crumbLine = new System.Text.StringBuilder();

    for (int i = 1; i < pathNames.Length; i++)
    {
        crumbLine.Append(pathNames.GetValue(i));
        if (i != pathNames.Length - 1)
        {
            crumbLine.Append(" > ");
        }
    }
    return crumbLine.ToString();
}
Posted by David Kiff (RSS@Davidkiff.co.uk) on 03 May 2007 02:44 in the Platforms category

Disabling “Low Disk Space in Vista”

  1. Right- click within the system tray (near the clock)
  2. Select properties from the context menu
  3. Check the “Hide inactive icons” checkbox
  4. Select the “Customise” button
  5. Under “Low Disk Space” select “Hide” for the behavior
  6. Select Ok and you are done. No more alloying messages!
Posted by David Kiff (RSS@Davidkiff.co.uk) on 30 April 2007 11:06 in the Sharepoint category

Creating SharePoint 2007 Themes

  1. Navigate to:
    C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES
  2. Copy and paste a complete theme
  3. Rename the theme
  4. Navigate inside the theme directory
  5. Rename the .inf file to the exact name of the directory
  6. Open the .inf file in Microsoft Notepad
  7. Find and replace the old theme name with the new theme name created
  8. Create a new image to represent the new theme
  9. Navigate to:C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES
  10. Add the new image to the directory and record the filename
  11. Navigate to:
    C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033
  12. Open the file “SPTHEMES.XML” in notepad
  13. Copy and paste an entire Template
  14. Rename “TemplateID” to the name of the directory previously created
  15. Write an appropriate display name and description
  16. Enter the location of the image (images/recordedFilename) created in step 10 under the thumbnail and preview entities

Applying the Theme

  1. Open the SharePoint site
  2. Navigate to “Site Actions”
  3. Select “Site Settings” then “Modify All Site Settings”
  4. Under “Look and Feel” select “Site Theme”
  5. Select the new theme from the list and select “Apply”

Modifying the Theme

Tools such as the CSS Viewer in Mozilla FireFox will prove to be valuable in locating classes.

  1. Ensure the theme is applied
  2. Open the site in Microsoft SharePoint Designer
  3. Navigate to “_Themes” then the new theme folder created earlier
  4. Open the .CSS file ending in 65001.CSS
  5. Modify this file to change the theme
  6. To change the images navigate to the themes directory:C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES\BROADRIDGE
  7. Select an appropriate image and modify as required.
Posted by David Kiff (RSS@Davidkiff.co.uk) on 15 January 2007 04:12 in the Networking category

Problem with ARP Cache

My Windows 2003 virtual server would not allow me to repair a connection, I recieved the error "Problem clearing ARP Cache". Most forums suggest to type the following at the command prompt:

"netsh interface ip delete arpcache"

... however no luck.

I eventually found the problem- "Routing and Remote Access" service needed to be stopped. Here is the fix:

  1. Click the < Start> button
  2. Click the < Control Panel> button
  3. Switch to "Classic View" if you are in "Category View"
  4. Click < Administrative Tools>
  5. Click < Computer Management>
  6. Double-click < Services and Applications>
  7. Double-click < Services>
  8. Scroll down to < Routing and Remote Access>
  9. Double-click < Routing and Remote Access>
  10. Examine the "Start-up Type" (The options are "Automatic", "Manual", and "Disabled")
  11. Set the "Start-up Type" to "Disabled"
  12. Click the < OK> button
Posted by David Kiff (RSS@Davidkiff.co.uk) on 13 January 2007 10:27 in the Visual Studio category

Visual Studio 2005 SP1 for Vista

Whilst trying to install Visual Studio 2005 Service Pack 1 for Vista I recieved the following message:

"The upgrade patch cannot be installed by the Windows Installer service because the program to be upgraded may be missing, or the upgrade patch may update a different version of the program. Verify that the program to be upgraded exists on your computer..."

What I didnt realise was that I must install Visual Studio 2005 SP1 first!

Posted by David Kiff (RSS@Davidkiff.co.uk) on 07 January 2007 04:24 in the Platforms category

Windows Vista

Vista... over three days I spent trying to install this before Christmas. Each install took around 30-50 hours :(! Very frustrating when i find out it fails each time, with no noticable errors. This install was different, i HUNTED for SATA drivers, all I could get is a .exe from intel- no use to load as a driver for vista:(

Finally i found out what files were requried and searched my pc for them, when found I loaded them and vista installed in under 30mins! Wow!- not one problem.

The files I used were:

  • iaahci.inf
  • iaAHCI.cat
  • iaStor.sys
  • iaahci.pnf

Im sure the files will be different depending on your chipset and system. Mine is:

Intel 925 Chipset (Dell Dimension 8400) Intel Pentium 4 3.40 GHz 2046 MB RAM

Posted by David Kiff (RSS@Davidkiff.co.uk) on 06 January 2007 04:16 in the Applications category

Word 2007 line spacing problems

Word 2007 pre-defines a huge line space! This really started to annoy me, as my work seems to spaced out. To correct this issue and have the line spacing the same as previous Word follow the below steps:

  1. Select the "Home" tab on the ribbon.
  2. Under the paragraph section select the line spacing button (figure 1.1).
  3. Select "Line Spacing options...".
  4. Select the "Indents and Spacing" tab (default selected).
  5. Under the "Spacing" heading select type "0pt" in for "After:" (figure 1.2).
  6. Select "Ok" and your finished.
linespacebtn.JPG linespace.JPG

Figure 1.1

Figure 1.2

Posted by David Kiff (RSS@Davidkiff.co.uk) on 04 January 2007 02:51 in the Applications category

Microsoft Office 2007

office2007.JPG

Office 2007! It takes a little getting used to as all the drop down menus have disappeared and we have a more modern easier to use "panel" across the top of the page.

In Word, the default font has changed from Times New Roman to "Calibri" which has a better look than the predecessor, and there is better use of Styles.

Excel can apply some handy formatting to imported data, making it easier to read and understand- prints out well too!

Overall very impressed! Well done Microsoft!

Posted by David Kiff (RSS@Davidkiff.co.uk) on 23 December 2006 04:39 in the .NET category

Appending to the begining of a text file

To add a header row to a CSV file I needed to append to the beginining of the text file, this however is not possible, instead I had to create a new file and write the original files contents to it after the header has been written:

StreamReader reader = new StreamReader(File.Open("Original.csv", FileMode.Open, FileAccess.Read));
StreamWriter writer = new StreamWriter(File.Create("Newfile.csv"));
writer.WriteLine("StudentID, Username, Forename, Surname"); //Write header row.
writer.WriteLine(reader.ReadToEnd()); //Write original file to the new one.
writer.Flush();
writer.Close();
reader.Close();
Posted by David Kiff (RSS@Davidkiff.co.uk) on 16 December 2006 07:28 in the ASP.NET category

Active Directory and ASP.NET Forms

My Final Year Project requires Active Directory Authentication, ASP.NET has a very simple GUI to set this up although I have used LDAP to create finer grained code- more customisable :D. Here is the method I have used:
public bool IsAuthenticated(string domain, string username, string pwd)
{
    string domainAndUsername = domain + @"\" + username;
    DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);
    try
    {
        // Bind to the native AdsObject to force authentication.
        Object obj = entry.NativeObject;
        DirectorySearcher search = new DirectorySearcher(entry);
        search.Filter = "(SAMAccountName=" + username + ")";
        search.PropertiesToLoad.Add("cn");
        SearchResult result = search.FindOne();
        if (null == result) { return false; }
        // Update the new path to the user in the directory
        _path = result.Path;
        _filterAttribute = (String)result.Properties["cn"][0];
    }
    catch
    {
        throw
    }
    return true;
}

If you want to create a simpler AD login we can use the ASP.NET Login control with Memberships.  Example memberships code for the web.config file:
<membership defaultProvider="ADMembershipProvider">
    <providers>
        <clear/>
        <add name="ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ActiveDirectory" connectionUsername="userName" connectionPassword="password" attributeMapUsername="sAMAccountName" enableSearchMethods="true" requiresUniqueEmail="true"/>
    </providers>
</membership>

The Login Control can utilize the membership:
<asp:Login ID="LoginControl" runat="server"
                  EnableTheming="true"
                  DisplayRememberMe="true"
                  FailureText="Login attempt has failed.">
</asp:Login>

To me it seems more beneficial to use the first option, the membership way is easier although you require administraton rights for the connection.
Posted by David Kiff (RSS@Davidkiff.co.uk) on 14 December 2006 04:27 in the General category

New RSS Feeds

DavidKiff.co.uk now has Live RSS feeds!