Friday, 23 October 2009

IIS, ASP.NET: Could not load file or assembly 'System.Core, Version=, Culture=neutral' or one of its dependencies'

If you receive this error when trying to access a newly deployed application on IIS:

"Could not load file or assembly 'System.Core, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified"

Then check that you have the .NET framework version 3.5 installed. This was the LAST thing I checked after about a million other things - I wish I had checked that first!

I'll know for the next time though!

IIS: "Page cannot be found" error when browsing aspx pages in Windows Server 2003 with IIS 6.0

I was configuring a new application, and had re-registered the .NET framework.

I kept getting a page cannot be found message when I tried to browse aspx pages on Windows Server 2003 with IIS version 6.0 and .NET framework 3.5.

Apparently it's because in Windows 2003, all the webservice extensions are "Prohibited" by default to ensure security. These settings were restored to default when I re-registered the .NET framework.

To resolve this, I did the following:

1. Opened IIS Manager (from a command shell, type inetmgr and press enter).
2. Expanded the appropriate nodes in the IIS to locate the "Webservice Extensions" Node
3. There was a list of "prohibited" extensions in the right.
4. Clicked on ASP.NET and "allow" it

Worked! Well, I was now back to where I was before I started mucking about with .NET.

This article applies to Windows Server 2003, IIS 6.0 environment.

Microsoft Outlook: Attachment field does not appear in header

Being a heavy user of Outlook 2007, I found it really annoying when writing an email and adding an attachment when sometimes it would appear in the body of the email, rather than where it should be; on the attachments bar at the header of the message:

I thought it was a bug so I kept restarting Outlook but it had no effect. When I created a new message and added an attachment, it would behave the way I wanted.

Then I figured out that it's something really straightforward. If the message is in Rich Text Format the attachments will appear in the body of the message (which looks messy), but if you change it back to HTML or Plain Text format they will go back to the attachment bar in the header - where they should be!


Thursday, 22 October 2009

Simple Auto Refresh of ASP.NET Page

I have a 'log viewer' page in one of my projects which I need to refresh every ten seconds.

There are lots of ways to achieve this using JavaScript and nasty code behind bodge jobs but there's a much easier way that only requires one line of code.

<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<!--The next line of code will refresh the page every 10 seconds-->
<meta http-equiv="refresh" content="10">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content=""

Clearly, content="10" means the interval in seconds.

Tuesday, 20 October 2009

Postbacks Not Working in ASP.NET

I was deploying an application to a Development server, and noticed that when I tested anything which caused a postback, the page would simply refresh and the postback would not work.

When accessing the site on the server itself using the localhost address, it worked fine.


Then I checked if it was working in Firefox, and lo and behold - it was!

Even more bizarre.

But apparently, it's something to do with validators which are specific to IE. It detects the browser, then if it's IE it sends specific JavaScript down to cause validation of postbacks.

The solution? Copying the aspnet_client folder into the root of our IIS installation's Default Web Site and restarting IIS. Once I closed my IE session and accessed the site again, the postbacks started working.

Friday, 16 October 2009

SQL Server Agent: Error When Running a DTSX Package to load Excel

When deploying a project onto a 64 bit Windows Server machine, I noticed an issue with scheduling SQL Server Agent to run a DTSX package to load an Excel file. The error is a bit like this:

An OLE DB record is available. Source: "Microsoft OLE DB Service Components" Hresult: 0x80040154 Description: "Class not registered"

I could run the package directly using SQL Server Management Studio without any problems, so it's obvious that the issue is being introduced by SQL Server Agent. After rooting around on the net looking for the answer, it seems that the agent is trying to run the package in 64 bit mode.

There are no 64 bit Excel drivers, so the package fails. For information on the impact that 64 bit architecture has on SSIS, refer to this blog post by Deniz Arkan, the SQL Server Integration Services Program Manager at Microsoft, and this Microsoft article on the subject.

Many forum posts suggest that the package should be run via the Agent using the 32 bit version of DTEXEC rather than the 64 bit version.

By default, a 64-bit computer that has both the 64-bit and 32-bit versions of an Integration Services command prompt utility installed will run the 32-bit version at the command prompt. The 32-bit version runs because the directory path for the 32-bit version appears in the PATH environment variable before the directory path for the 64-bit version. (Typically, the 32-bit directory path is :\Program Files(x86)\Microsoft SQL Server\90\DTS\Binn, while the 64-bit directory path is :\Program Files\Microsoft SQL Server\90\DTS\Binn.)

So if you have both 32 bit and 64 bit versions installed, you have to explicitly point to the 32 bit version of DTEXEC on the command line.

Alternatively, to run a package in 32-bit mode from a 64-bit version of SQL Server Agent, select Use 32 bit runtime on the Execution options tab of the New Job Step dialog box. This depends on your having the 32 bit runtime tools installed.

For a step by step description of how to run a package from an Agent job in 32 bit, refer to this Microsoft KB article.

But after all this reading, I bottled it. I can't be bothered having to get the 32 bit version of the runtime installed on the Dev, UAT and Production boxes so I decided to get the files I needed converted into a flat file format. This won't suit everyone as not everybody can get their input files changed to a different format, but for me it's the best route.

Anyway, clearly I am by no means an expert on this subject, but I reckon that Microsoft are trying to discourage people from using 32 bit architecture on 64 bit machines by making this kind of thing difficult to implement, and by not providing 64 bit drivers for their Office products.

Thursday, 8 October 2009

Locating Duplicates in Excel

If you work with large Excel files regularly, it can be a pain in the neck to find duplicates in a column of data.

You could export the file to a text file and load it into a database, and use a query to find the duplicates - but that's probably the sledgehammer approach.

The problem is that Excel doesn't appear to offer a straightforward way of identifying duplicates, but it can be done using Conditional Formatting.

Rather than reinvent the wheel and write a detailed how-to here, it's a good idea to link to the definitive authority on the subject: Microsoft. So here's a link to an article which shows you how to locate duplicates in a matter of seconds. Hope it's useful.

Wednesday, 7 October 2009

ASP.NET: "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level"

You may get this error when trying to browse an application.

The debug information shows that "This error can be caused by a virtual directory not being configured as an application in IIS."

When you create an new web application using visual, it automatically creates the virtual directory and configures it as an application. However, if you manually create the virtual directory and it is not configured as an application, then you will not be able to browse the application and may get the above error. The debug information you get as mentioned above, is applicable to this scenario.

To resolve it, Right Click on the virtual directory - select properties and then click on "Create" next to the "Application" Label and the textbox. It will automatically create the "application" using the virtual directory's name. Now the application can be accessed.

This solution 'borrowed' from this blog.

IIS 5.1: "MMC has detected an error in a snap-in"

When using IIS Manager on a Windows Server Enterprise Edition box, the error message "MMC has detected an error in a snap-in. It is recommended that you shut down and restart MMC." sometimes appears.

Googled around for a bit, and this seems like a bug that Microsoft know about, but don't care about. Odd! Suppose that's nothing new though: