Common error types and solutions in SharePoint development!

Source: Internet
Author: User

Some Problems and Solutions encountered in SharePoint Development

1. Error Type:

The security validation for this page is invalid. Click back in your web browser, refresh the page, and try your operation again.

Solution:

Microsoft. Sharepoint. Administration. spwebapplication webapp = site. Site. webapplication;
Webapp. formdigestsettings. Enabled = false;
Spfile = site. Files. Add (fileupload. filename, contents );
Spfile. item. Update ();
Webapp. formdigestsettings. Enabled = true;
Web. allowunsafeupdates = true;
Site. allowunsafeupdates = true;

2. Error Type:

Unknown error reported in SharePoint

Solution:

Modify the following nodes in the configuration file of the site

1. <safemode maxcontrols = "200" callstack = "false" directfiledependencies = "10" totalfiledependencies = "50" allowpageleveltrace = "false">
Changed:
<Safemode maxcontrols = "200" callstack = "true" directfiledependencies = "10" totalfiledependencies = "50" allowpageleveltrace = "false">

2. <customerrors mode = "on"/> changed to: <customerrors mode = "off"/>

3. <compilation batch = "false" DEBUG = "false"> changed to; <compilation batch = "false" DEBUG = "true">

After modification, the error source will be displayed, which is always better than "Unknown error!

3. Error Type:

Unable to serialize the session state. in 'stateserver 'and' SQL Server' mode, Asp. net will serialize the session State objects, and as a result non-serializable objects or externalbyref objects are not permitted. the same restriction applies if similar serialization is done by the custom session State store in 'custom' mode.

Solution:

The used class must be marked as serializable!

4. Error Type:

If Sharepoint is configured, users are added to the member group of the website in the same domain, but Members in the Group still cannot access

Solution:

Disable the firewall .! [If access is restricted, add members to the member group of the website]

4. Error Type:

Operation is not valid due to the current state of the object

Solution: Improve Permissions

Spsecurity. runwithelevatedprivileges (delegate (){

Spsite site = new spsite (http: // jianghao: 9000 );

Spweb web = site. openweb ();
Using (SITE)

//...

});

Or:

Private string getpictureurl (string loginname)
{

Spsite site = NULL;
Spweb web = NULL;
Using (Site = new spsite (mysiteurl ))
{
Using (Web = site. rootweb)
{
Web. allowunsafeupdates = true;
Servercontext CTX = servercontext. getcontext (SITE );
Userprofilemanager profilemgr = new userprofilemanager (CTX );
If (httpcontext. Current! = NULL)
{
If (httpcontext. Current. items ["httphandlerspweb"] = NULL)
{
Httpcontext. Current. items ["httphandlerspweb"] = web;
}
If (httpcontext. Current. items ["Microsoft. Office. servercontext"] = NULL)
{
Httpcontext. Current. items ["Microsoft. Office. servercontext"] = CTX;
}
}
If (profilemgr. userexists (loginname ))
{
// Microsoft. Sharepoint. Portal. userprofiles. USERPROFILE up = upman. getuserprofile (loginname );
Microsoft. Office. server. userprofiles. USERPROFILE up = profilemgr. getuserprofile (loginname );
If (! String. isnullorempty (up [propertyconstants. pictureurl]. value as string ))
{
Return up [propertyconstants. pictureurl]. value. tostring ();
}
Else {return "" ;}}

Note: you cannot undo permission escalation because after permission escalation, all operations are performed by the system account user! For example, the people who reply to blogs and discussions are "System Account! Of course this is wrong!

5. Error Type: illegal characters in path. [The path contains invalid characters .]

A: When configuring usercontrol in SharePoint

<% @ Register src = "~ /_ Controltemplates/revolution9000/[new line feed]
Groupblogpostinfo. ascx "tagname =" groupblogpostinfo "tagprefix =" uc1 "%> to wrap a line feed, you can wrap it in the tagname! The value of each attribute cannot be truncated. This problem is abnormal! This problem is depressing! I still found it from my colleague Bobby. I don't have that patience.

6. Error Type: Visual Studio 2008 code measurement and referenced assembly

In the earlier process of different creations today, I accidentally found an error and used the code measurement function in Visual Studio 2008. Click the analysis menu, and then click the calculation solution of the code measurement. The solution errors in several projects are similar to the following: when an error occurs, calculate the "e "in the target file: \ notbackedup \... 'Project... when reading the following error, the module 'Microsoft. sharePoint ': resolution type :? Why? Object Model ?. English error: [Project: Revolution. Website
Configuration: Debug
Scope: None
Assembly: C: \ Users \ Hao. Jiang \ Desktop \ 2010-01-06 \ kkjhjhjhjhjhjhjhjhjhk \ sharepointobject \ revolution. Website \ bin \ revolution. Website. dll
Maintainability Index:
Cyclomatic complexity:
Depth of inheritance:
Class coupling:
Lines of code:
Message: An error occurred while calculating code metrics for target fil 'C: \ Users \ Hao. jiang \ Desktop \ 2010-01-06 \ kkjhjhjhjhjhjhjhjhjhjhjhjhk \ sharepointobject \ revolution. website \ bin \ revolution. website. DLL 'in project revolution. website. the following error was encountered while reading module 'Microsoft. sharePoint ': cocould not resolve type: T objectmodel.]

(Don't ask me ,'? 'Indicates-I just copied and pasted them directly from Visual Studio .)
It turns out that this is a known error in Visual Studio 2008. Due to the default setting, family members are allowed to use it in a project without explicitly referencing them.

The solution is to explicitly add the dependent assembly to the project.

After the reference, it is clear that Microsoft. Sharepoint. Security is included in the project with the error! Add reference!

7. Error Type:

Failed to Load file or assembly "Microsoft. Sharepoint. Library, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" or one of its dependencies. The system cannot find the specified file.

No SharePoint environment! You must run it on a machine that has a Sharepoint environment!

8. Error Type:

View the SharePoint website on the local machine, for example, http: // jinho: 9000. The error "Service unavailable" is returned! [503] I have met for the second time!

Open Server Manager and check whether the service on port 9000 is enabled! If enabled, the problem still persists! Check the application pool [application pool]. It is very likely that the Service on port 9000 in application pools is not started! Right-click to start

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.