Wednesday, May 20, 2009

SharePoint Web-part dev problem - List does not exist

Problem:
I was working on a web-part with a custom ASPX file. It was working just fine for the root site of a site collection, but when testing it on a subsite it failed to load the ASPX file with the following exception:

List does not exist

The page you selected contains a list that does not exist. It may have been deleted by another user.

Solution:
There are few suggestions that didn't help me on the web. With the good old method - remove everything and check what's making the problem I found the perpetrator: in the ASPX page, I used SharePoint:FormattedStringWithListType, which caused the exception.

Using reflector I found that FormattedStringWithListType has a property 'List' which opens SPList with the current SPWeb context (list GUID is taken from the request parameter named 'List'). At this point I noticed that when the ASPX file is opened, it is done from the site collection level & not the sub site level.

From here there are few possible solutions:
*. Open the ASPX file from the subsite level (probably the best solution).
*. Don't use the class FormattedStringWithListType
*. Copy with reflector & fix the problem using SPSite.

Saturday, March 28, 2009

Response.Header.Add doesn't work

I've tried to use:
Response.Header.Add("HeaderKeyName", "KeyValue")

But I got the following exception:
System.PlatformNotSupportedException: This operation requires IIS integrated pipeline mode.
at System.Web.HttpResponse.get_Headers()

The work around:
Response.AddHeader("HeaderKeyName", "KeyValue")

For the least Microsoft could find a better exception description.

Tuesday, March 24, 2009

HyperLinkField not showing as link (ASP.NET)

After binding data to a HyperLinkField in a GridView it didn't show as link but as a normal text. Apparently when using navigation by data fields, the data in the fields set in DataNavigateUrlFields must be validated.

See some more information here:
http://stackoverflow.com/questions/640120/hyperlinkfield-not-showing-as-link

I had a problem when the field was a DateTime field returned by a database query. I've change the field format in the following way to make this work (navigation):
[Date] = convert(VARCHAR, [Date],104)

Tuesday, March 10, 2009

You are not authorized to view this page

Symptoms:

One clear morning, on an operational system (Windows 2003 x64, IIS, ASP.NET, SQL Server 2005) running an ASP.NET application, the users started to get request to fill their credentials, and after few times they got:
You are not authorized to view this page

With more specific notification:
HTTP Error 401.1 - Unauthorized: Access is denied due to invalid credentials.Internet Information Services (IIS)

In the event log of the server I found the following errors:
- System Events - I found warning event 1011 titled "W3SVC":
A process serving application pool 'DefaultAppPool' suffered a fatal communication error with the World Wide Web Publishing Service. The process id was '6756'. The data field contains the error number.

- Application Events - I found error event 1000 titled ".NET Runtime 2.0 Error Reporting":
Faulting application w3wp.exe, version 6.0.3790.3959, stamp 45d691cc, faulting module kernel32.dll, version 5.2.3790.4062, stamp 462643a7, debug? 0, fault address 0x0000000000027d8d.

Resolution:

I followed few wrong leads on the web, such as:

After wasting nearly a day a found the root cause:
The ASP.NET application had a stack-overflow bug.

From here fixing is easy.

The reason that I didn't suspected the ASP.NET application was that the stack-overflow bug was caused by a run time change of the data in the application, and not something new installed/configured.

Monday, January 26, 2009

How to check if the Laptop IR (Infrared) is working

This is really cool - open your Cellular phone camera and point it to the laptop IR sensor. The sensor will blink every 3-4 seconds on the cellular camera screen.

I've been told it also works with remote controls (so you can check the batteries), and I can only guess it's working with any digital camera.

Sunday, January 25, 2009

Windows XP drivers for laptops

As I wrote before I've got HP dv6700 which I've installed win2003 on. Few days ago I've finished the project for which I needed that OS, and I've started to install WinXP on this machine. As I found out HP doesn't really says which drivers I should use for Windows XP. I've tried installing drivers similar to the ones they say for Vista (only WinXP version of them) and they didn't realy want to install...

Anyway, I started to get somewhere only after installing SiSoftware Sandra. An amazing piece of software that just finds out exactly what kind of hardware you got. With this software I found out in minutes which drivers I should use.

Thursday, January 8, 2009

WebPart wsp does not include dependent DLLs

I was trying to develop a webpart for SharePoint 2007 & WSS3 using Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions, Version 1.1.

Everything worked just fine, until I found out that the WSP file created by the add-on does not include dependent DLLs (from other projects in the solution). I could not find any good solution, so finally I had the following options:

1. In post-build event, use ILMerge to merge all the DLLs into a single DLL with the name & key file of the webpart, and replace existing DLL with this new merged DLL.

2. Add the dependent DLL to the project files of the webpart. This way the WSP file includes the dependent DLL. An improvement: add the DLL file in the following directory: bin/Release/ (change the project file with notepad) - this way any new compilation will include the new DLL.

3. Probably the best option - use a 3rd party tool to create the WSP file - WSPBuilder for example.