设为首页 收藏本站
查看: 1134|回复: 0

[经验分享] SharePoint开发中常见的几种错误类型及解决方法!

[复制链接]

尚未签到

发表于 2015-9-26 13:38:44 | 显示全部楼层 |阅读模式
  在sharepoint开发中遇到的一些问题和解决方案
  1.错误类型:
  The security validation for this page  is invalid. Click Back in your Web browser, refresh the page, and try  your operation again.
  解决方案:
    Microsoft.SharePoint.Administration.SPWebApplication  webApp = site.Site.WebApplication;
webApp.FormDigestSettings.Enabled  = false;
SPFile spFile = site.Files.Add(fileUpload.FileName,  contents);
spFile.Item.Update();
webApp.FormDigestSettings.Enabled  = true;
web.AllowUnsafeUpdates = true;
site.AllowUnsafeUpdates =  true;
  2. 错误类型 :
  在 sharepoint中报 未知错误
  解决方案:
  在该站点下的配置文件里面修改以下节点
  
  1.<SafeMode  MaxControls="200" CallStack="false" DirectFileDependencies="10"  TotalFileDependencies="50" AllowPageLevelTrace="false">
改为:
<SafeMode  MaxControls="200" CallStack="true" DirectFileDependencies="10"  TotalFileDependencies="50" AllowPageLevelTrace="false">
  
  2.<customErrors  mode="On " /> 改为:<customErrors mode="Off " />
  
  3.<compilation  batch="false" debug="false ">改为; <compilation batch="false"  debug="true ">
  修改后就会把错误源显示出来,总比报"未知错误"好吧!
    3. 错误类型 :
  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  MarshalByRef objects are not permitted. The same restriction applies if  similar serialization is done by the custom session state store in  'Custom' mode.
  解决 方案:
  被 使用的类必须标记为可序列化!
  4.错误类型 :
  如果配置好的sharepoint,也在 同一个域,把用户加进了网站的成员组里面,但是该组里面的成员还是不能访问
  解决方案:
   请关闭防火墙。![如果报访问受限,则把成员加进网站的成员组里面]
    4. 错误类型 :
  Operation is not valid due to the  current state of the object
  解决方案:提升权限
  SPSecurity.RunWithElevatedPrivileges(delegate()  {
  SPSite site = new SPSite(http://jianghao:9000 );
   SPWeb web = site.OpenWeb();
using (site)
  //...
  });
    或者:
    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 &#8220;&#8221;; } }
  注意,不能乱提升权限,因为提升权限后一切都是System  Account用户的操作!比如是别人回复的博客和 Discussions 的回复人都是"System  Account"这个人!这个当然是不对的了!
  5.错误类型: Illegal characters in path.  【路径中非法字符。】
   A: 在把UserControl配置到sharepoint里面时
    <%@ Register  src="~/_controltemplates/revolution9000/  [这里换行了]
GroupBlogPostInfo.ascx"  tagname="GroupBlogPostInfo" tagprefix="uc1" %> 如果要换行,则可以在 tagname 那里换行!每个属性的值不能截断 这个问题太变态!找这个问题 郁闷惨了!  还是同事Bobby找到的,我可以没有那么好的耐心.
    6.错误类型:Visual Studio  2008的代码度量和引用的程序集
  在不同的创作后的今天早些时候的过程中,我偶然发现一个错误,同时使用代码度量在Visual Studio  2008的功能。 在点击 分析 菜单,然后点击  代码度量的计算解决方案 ,我遇到的解决方案在几个项目的错误类似于以下内容: 发生错误时计算目标文件『E代码度量:\ NotBackedUp \  ...'项目...下面的错误阅读时遇到模块'Microsoft.SharePoint':无法解析类型:?Ť?对象模型?。 英文错误:[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\kkjhjhjhjhjhjhjhjhjhk\SharePointObject\Revolution.WebSite\bin\Revolution.WebSite.dll'  in project Revolution.WebSite. The following error was encountered  while reading module 'Microsoft.SharePoint': Could not resolve type: T  ObjectModel.]
  (不要问我,'?'字的意思应该是 - 我只是复制和粘贴从Visual  Studio中直接完成。)
原来,这是在Visual Studio  2008已知的错误,由于默认设置,允许家属集会在一个项目中使用没有明确引用它们。
    解决方法是明确的依赖程序集添加到项目。
  引用后明确  Microsoft.SharePoint.Security到报错的项目里面!添加引用就可以了!
    7.错误类型:
  未能加载文件或程序集 &#8220;Microsoft.SharePoint.Library, Version=12.0.0.0, Culture=neutral,  PublicKeyToken=71e9bce111e9429c&#8221;或它的某一个依赖项。系统找不到指定的文件。
    没有sharepoint环境!必需运行在装有sharepoint环境的机子运 行!
  8. 错误类型:
  浏览本机上 sharepoint网站:如http://jinho:9000  出现了Service Unavailable 错误![503]  我已经第二次遇到了!
  打开server  Manager,查看9000端口的服务是否启动!如果已开启还是出现了那个问题! 请在查看 application Pool[应用程序池]  很有可能是application Pools里面的9000端口的服务没有启动!右键启动即可

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-119154-1-1.html 上篇帖子: 关闭SharePoint 2010 customErrors 下篇帖子: SharePoint 2007 图片库视图不可用、页面标题不显示
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表