Tag Archive for 'sharepoint'

How to configure log4net on SharePoint?

Recently I had to add logging feature to the SharePoint project I’ve been developing. I had to use log4net. I followed my friend’s advice but for some reason it wouldn’t work in my case. I didn’t get any errors or exceptions. Simply nothing was logged to the file, which by the way would not be even created. All in all it looked like a problem with applying the configuration from log4net.config. Indeed, when I looked at the logger object if it’s been configured (log.Logger.Repository.Configured) and it said false.

It turned out the log4net.config was deployed in a wrong location. Apparently, it should be placed there: C:\Inetpub\wwwroot\wss\VirtualDirectories\80.

 How to configure log4net on SharePoint?

Problems with UpdatePanel on SharePoint

If you want to add some AJAX flavour to your ASPX pages running on SharePoint you need to perform a few actions:

  • install ASP.NET AJAX on servers in your farm
  • extend SharePoint web.config file with Microsoft ASP.NET AJAX
  • add ScriptManager either in the master page you’re using (prefferable) or in all pages that employ AJAX

The above listed steps are well described in the following article: Integrating ASP.NET AJAX with SharePoint.

However, at the end of the day you may (and probably will) end up with some problems during development. In short, not all works as it’s supposed to and how it does in a regular web project. One of the issues I had recently was UpdatePanel which made my page not working after a while.

Basically, I had an ASPX with some controls that had event handlers assosiated with them (e.g. buttons with onclick’s). There too was an UpdatePanel which was triggered by an event, let’s say “Click” perfomed on a button. This event made the UpdatePanel reload, BUT ONLY FOR THE FIRST TIME. Once reloaded, none of the handlers assosiated with any of the controls on the page worked.

I did a lot of googling but finding the answer was not that easy. Finally my friend gave me the link to this article. The solution is described in section “Using UpdatePanels within SharePoint”. The author suggests to add this JavaScript code to the page:

<script type="text/javascript">
    _spOriginalFormAction = document.forms[0].action;
    _spSuppressFormOnSubmitWrapper=true;
</script>

Parser Error Message: This page allows a limit of 200 controls, and that limit has been exceeded.

By default, web.config of SharePoint (should be there: C:\Inetpub\wwwroot\wss\VirtualDirectories\80) defines the maximum number of controls as 200. Should you define more on a page you’ll probably get an error similar to this:

spscreen 350x140 Parser Error Message: This page allows a limit of 200 controls, and that limit has been exceeded.

Solution

In order to fix it, edit this web.config. Find configurationSharePoint\SafeMode tag and change the MaxControls attribute to a bigger number. Once you do this, reload the page. It should help.

The feature name XXX already exists in SharePoint. You need to rename the feature before solution deployment can succeed.

From time to time when I try to deploy a SharePoint project from Visual Studio 2005 I’m getting this error:

The feature name XXX* already exists in SharePoint. You need to rename the feature before solution deployment can succeed.

Solution
Whenever I get this (annoying) error I go to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\ and remove the directory named XXX*. Sometimes then I need to restart Visual Studio or even log off and on again (on my Windows account).

17/102008
Sometimes restarting Visual Studio does the job.

* is the name of the module that should be deployed

 The feature name XXX already exists in SharePoint. You need to rename the feature before solution deployment can succeed.

Visual Studio: The language-neutral solution package was not found.

I’m getting this (and a few more, which maks me frustrated) error from time to time when I try to deploy a SharePoint project from Visual Studio 2005 (under Windows Server 2003 RC2)…

Solution:
Restart Visual Studio…

ASPX running on Sharepoint – display stack trace

Should you need to see the stack trace when an error on an APSX page hosted by Sharepoint occurs do the following:

  • SharePoint\SafeMode: AllowPageLevelTrace="true" and CallStack="true"
  • system.web\customErrors:mode="Off" or mode="RemoteOnly"

Yet the standard error page usually does not tell aything that can suggest the reason for the error…