Some Sharepoint problems and resolutions

 

Some Sharepoint problems and resolutions

I just surfed on this on the sharepoint forum so i decided to share

It can save a lot of time though

Getting Started Topics


SharePoint Developer Introduction for .NET Developers

http://www.microsoft.com/click/SharePointDeveloper/

 

Microsoft SharePoint Team Blog

http://blogs.msdn.com/sharepoint/

 

Troubleshooting Topics

Problem Area: Debugging and Troubleshooting

Problem

When developing against the SharePoint object model in an application outside of IIS (service, console, Winforms etc..) on a machine that is not part of a SharePoint farm you receive the error “Unhandled Exception: System.TypeInitializationException: The type initializer for 'Microsoft.SharePoint.CoreResource' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly”

Resolution

The SharePoint object model can only be used when the application is run on a server in the SharePoint farm. It cannot be executed remotely. If it is not possible to run the application on a SharePoint farm server you should investigate using the SharePoint web services instead.

The Windows SharePoint Services and Microsoft Office SharePoint Services web services are documented in the following SDK’s.

SharePoint Server 2007 SDK: Software Development Kit

http://www.microsoft.com/downloads/details.aspx?FamilyId=6D94E307-67D9-41AC-B2D6-0074D6286FA9&displaylang=en

Windows SharePoint Services 3.0: Software Development Kit (SDK)

http://www.microsoft.com/downloads/details.aspx?FamilyID=05e0dd12-8394-402b-8936-a07fe8afaffd&DisplayLang=en

Problem

You receive “The "yourWebPartName" Web Part appears to be causing a problem” or a generic error message when developing a web part.

Cause

Exceptions are caught by SharePoint and a friendly error message is displayed instead of a stack trace.

Resolution

To configure SharePoint to display the full exception needed for debugging make the following changes to your SharePoint site’s web.config file (typically located in /Inetpub/wwwroot/wss/VirtualDirectories/yoursite).

·          Find:   <SafeMode CallStack="false" />

·          Replace with: <SafeMode CallStack="true" />

·          Find:   <customErrors mode="On" />

·          Replace with: <customErrors mode="Off" />

·          Find:   <compilation debug="false" />

·          Replace with: <compilation debug="true" />

Problem

You receive “Unknown Error” or another generic error message when developing aspx pages beneath _layouts.

Cause

Application pages beneath _layouts have a separate web.config file that needs updated to enable more detailed error messages.

Resolution

Open /Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/LAYOUTS/web.config

Add the following XML block immediately after the <configuration element.

  <SharePoint>

    <SafeMode CallStack="true">

      <PageParserPaths>

      </PageParserPaths>

    </SafeMode>

  </SharePoint>

·          Find:   <compilation debug="false" />

·          Replace with: <compilation debug="true" />

 

Problem

You are developing a SharePoint component on an XP or Vista client and you need to debug to troubleshoot your component.

Resolution

Enable Visual Studio 2005 or 2008 Remote Debugging to enable remotely setting breakpoints and single step debugging through your code.

A high level overview of how to do this:

·          Install the remote debugging components onto the development server (note this doesn’t require a full VS.NET install)

·          Run the Visual Studio 2005 Remote Debugger Configuration Wizard on the development server

·          Visual Studio 2005 Remote Debugger on the development server

·          Install a debug version of your component on to the server along with the symbol files (.pdb). For debugging, deploying to the /bin directory is preferable.

o    Note: If you install your assembly to the global assembly cache (GAC) you will need to copy the .pdb to the directory where the assembly is installed.

§   You can find this out from a command line by typing in the following commands:

·          cd /windows/assembly

·          dir /s YourAssemblyName.dll

·          Copy the .pdb files out of your /debug directory to this directory to enable debugging.

·          Ensure that debug=”true” is enabled in your SharePoint sites web.config

·          Open the project in Visual Studio on your client (ensure this is the exact same version/build of the assembly that is deployed – do not rebuild)

·          Click Debug -> Attach to Process -> change the text in the “Qualifier” text box to be the remote server’s name then click the “Refresh” button.

o    Ensure that “Managed” is checked in the “Attach To” area.

o    Note: If there are connection problems at this point see the following KB articles for additional configuration steps.

§   http://support.microsoft.com/kb/910448 How to implement remote debugging in Visual Studio 2005

§   http://support.microsoft.com/kb/908099 How to turn on remote debugging for Visual Studio 2005 in Windows XP with Service Pack 2

§   http://support.microsoft.com/kb/947252 Error message when you try to use the Remote Debugging Monitor in Visual Studio on a Windows Vista-based computer: "The Windows Firewall is currently blocking remote debugging"

·          You should see a list of processes appear. You will need to select w3wp.exe (there may be multiple instances) and click “Attach”.

·          Once attached to the correct instance you can set a break point in the code that you need to debug and reproduce the problem on the server.

o    For web parts this could be refreshing the page

o    For a feature receiver this could be activating or deactivating the feature

o    For an event receiver this could be manipulating data in a list (such as adding, deleting, check-in/check-out) etc…

·          The full detailed approach of configuring remote debugging: http://msdn.microsoft.com/en-us/library/bt727f1t(VS.80).aspx

 

Problem

You are trying to call a SharePoint web service but you are receiving SoapException errors.

Resolution

Add a catch handler to your web service call and handle the SoapException. Inside of the Detail property will be more detailed information to assist troubleshooting.

catch (System.Web.Services.Protocols.SoapException se)

{

        // se.Detail has more information

}

 

 

Problem Area: Memory Leaks

Problem

Your SharePoint site is exhibiting heavy memory usage and is performing slowly or you are experiencing application pool recycles due to out of memory conditions.

Resolution

Please review Roger Lamb’s blog entry “SharePoint 2007 and WSS 3.0 Dispose Patterns by Example” to ensure you are properly utilizing the Dispose method when using the SharePoint object model.

http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx

 

Problem Area: User Profiles

Problem

When using the SharePoint class UserProfileManager to read user profiles you receive the error “Only an administrator may enumerate through all user profiles”.

Resolution

There is now a hot fix available for this. At the time of this writing the KB article is not published but you can call into Microsoft support and request the fix by number 952294.

 

Problem Area: Security

Problem

When calling a web service from within a Web Part or an application outside of IIS you receive the following error:

Unhandled Exception: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.

Resolution

The web service needs credentials to be set before making calls.

Examples:

·          listService.UseDefaultCredentials = true;  // use currently logged on user

·          listService.Credentials = new System.Net.NetworkCredential("user", "pass", "domain"); // use specified user

 

Problem

When developing against the SharePoint object model in an application outside of IIS (service, console, Winforms etc..) you receive the error “FileNotFoundException” when creating an instance of the SPSite object.

Resolution

The user running the application needs to have the following permissions and group membership set:

·          The user is a server farm administrator. 

·          The user has Read and Write permissions on the content database. 

·          The user is a site collection administrator. 

·          The user has permissions to access the Windows SharePoint Services site or the SharePoint Server 2007 site through which the code iterates. 

 

Problem Area: VSEWSS

Problem

You receive the error “This solution contains two assemblies with the same name, or the SharePoint server already has an assembly with the specified name.” when deploying a solution using the Visual Studio Extensions for SharePoint (VSEWSS) after you have already deployed it to a different site on the same server.

Resolution

Remove the solution’s assembly from the Global Assembly Cache (GAC).

·          Gacutil –uf assemblyName   (note: no .dll extension is specified)

·          Rename or Remove the feature from “Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/FEATURES/FeatureName”  (note: FeatureName may not be the same as assembly name – look in your manifest.xml to find the correct name)

 

Problem

When trying to deploy a VSEWSS solution using the Visual Studio “Deploy” command you receive the error “Value does not fall within the expected range.”

Resolution

Remove all projects except the VSEWSS project from the Visual Studio solution then attempt your deployment again.

 

Problem Area: Event Receivers

Problem

You receive the error “Attempted to read or write protected memory.” when trying to cancel a checkout using the ItemCheckingOut Event Receiver.

Resolution

This is a know n issue. To workaround you should set the Status property to SPEventReceiverStatus.CancelNoError instead of SPEventReceiverStatus.CancelWithError or setting properties.Cancel = true;

See http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventreceiver.itemcheckingout.aspx for more details.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章