상세 컨텐츠

본문 제목

SharePoint Development and Programming FAQ

MOSS

by happynuri 2009. 6. 11. 16:33

본문


출처 : This solution contains two assemblies with the same name, or the SharePoint server already has


Question 1:

What resources are available for new SharePoint developers?


Answers:

SharePoint Developer Introduction for .NET Developers

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

 

SharePoint 2007 Videos and Webcasts
http://msdn.microsoft.com/en-us/office/aa940989.aspx

Microsoft SharePoint Team Blog

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


Best Practices Resource Center for SharePoint 2007 (NEW)
http://technet.microsoft.com/en-us/office/sharepointserver/bb736746.aspx

Arpan Shaw's Blog
http://blogs.msdn.com/arpans/

Paul Andrew's Blog
http://blogs.msdn.com/pandrew/

SharePoint Practice and Guidance
http://msdn.microsoft.com/en-us/library/dd203468.aspx
http://www.codeplex.com/spg

 

Question 2:

When developing against the SharePoint object model 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” or another generic error message.

 

Answer:

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.

 

Microsoft Office 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

 

Question 3:

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

 

Answer:

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

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

 

 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" />

 

Reproduce the problem and the true exception will be displayed.

 

Question 4:

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

 

Answer

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

 

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" />

 

Question 5:

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

 

Answer

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

 

See the following article for detailed configuration settings:

http://msdn.microsoft.com/en-us/library/bt727f1t(VS.80).aspx

 

Once the debugger is configured you will need to select Debug -> Attach to Process. You should see a list of processes appear. You will need to select w3wp.exe (there may be multiple instances and yes you can multi-select) and click “Attach”.

 

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

For web parts this could be refreshing the page

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

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


Note if you are debugging across different domains try the following guidance:

 

On your development workstation create a local account with the same name and password as your domain account then add it to the administrators group.

 

On the remote server create a matching domain account (same username and password) and add it the administrators group.

 

Configure the Visual Studio Remote Debugger Service on the remote server to login as the domain account.

 

Question 6:

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

 

Answer:

Add a catch handler to your web service call and handle the exception. 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

}

 

 

Question 7:

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.

 

Answer:

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

 

Question 8:

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

 

Answer:

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.

Question 9:

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.

 

Answer:

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

 

Question 10:

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.

 

Answer:

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. 

 

Question 11:

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.

 

Answer:

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)

 

Question 12:

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.”

 

Answer:

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

 

Question 13:

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

 

Answer:

This is a known 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.

 
Question 14:

My webpart is essentially "frozen" or dead after I write a file to the client using Response.WriteFile or .End or .Flush etc..

Answer:

http://msmvps.com/blogs/laflour/archive/2008/06/06/page-events-stop-working-after-using-output-stream-for-binary-download.aspx

Question 15:

You receive a 401 Access Denied when calling web services and you know permissions are configured correctly. 

Answer:

http://support.microsoft.com/default.aspx/kb/896861

관련글 더보기

댓글 영역