Silverlight + WCF + Sharepoint(Silverlight Web Part) 问题集合

  1. “找不到类型{..} 它在 ServiceHost 指令中提供为 Service 特性值,或在配置元素 system.serviceModel/serviceHostingEnvironment/serviceActivations 中提供。”
    •   确认.svc文件中的<%@ ServiceHost Language="C#" Debug="true" Service="{ServiceName}" CodeBehind="....cs" %>的{ServiceName}是不是跟Web.config中的服务名称一致。
  2. 自定义工具警告: 没有找到与Silverlight 4 兼容的端点。生成的客户端类将不可用,除非通过构造函数提供端点信息。
    •   WCF是否启用了Silverlight支持?WCF有WCF服务,WCF数据服务,在Silverlight中还有启用Silverlight支持的WCF,靠。
    •   [配置服务引用...],取消选择[重新使用引用的程序集中的类型]。
  3. 发布到Sharepoint中的Silverlight调用外域的WCF服务
    •   将添加WCF服务时生成的Reference.cs从Service References移动到项目文件夹下,可以重命名。
    •   修改...Client代码:
      EndpointAddress endPointAddress = new EndpointAddress("{wcf uri}");
                  CustomBinding binding = new CustomBinding();
                  binding.Elements.Add(new BinaryMessageEncodingBindingElement());
                  binding.Elements.Add(new HttpTransportBindingElement());
      
                  Adomd.AnalysisService.AdomdConnectorClient client = new Adomd.AnalysisService.AdomdConnectorClient(binding, endPointAddress);
      

        注意:如果不使用CutomBinding而用BasicHttpBinding就会返回:Not Found错误,主要是协议的问题,这是跟踪HTTP请求时发现的。

    •   在WCF宿主目录下(跟web.config一起)添加跨域策略文件clientaccesspolicy.xml:
    • <?xml version="1.0" encoding="utf-8" ?>
      <access-policy>
          <cross-domain-access>
              <policy>
                  <allow-from http-request-headers="*">
                      <domain uri="*"/>
                  </allow-from>
                  <grant-to>
                      <resource path="/" include-subpaths="true"/>
                  </grant-to>
              </policy>
          </cross-domain-access>
      </access-policy>
      
  4. 如何打开IncludeExceptionDetailInFaults,修改web.config(如果是Sharepoint,那么是在\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebServices\SecurityToken\):
    <configuration><behaviors><serviceBehaviors><behavior name="">
                        ...
                        <serviceDebug includeExceptionDetailInFaults="true" />
    ...
  5. 当发布到Sharepoint中的Silverlight部件调用外部WCF服务时遇到CrossDomainError怎么办,而且已经采用了clientaccesspolicy?
    既然发布了,就别在Uri中使用localhost啦
  6. 收藏:http://www.nanmu.net/sharepoint2010/sharepoint-2010-chinese/default.aspx
  7. [吐血]Sharepoint中使用FBA验证,无法选择人员!
    1. 首先学习http://msdn.microsoft.com/zh-cn/library/bb975136(v=office.12).aspx,正确配置Sharepoint
    2. 无法选择人员的原因,使用ULSViewer看log吧
      1. 提供程序名称不对
      2. 提供的凭证无法访问FBA DB,就这么个问题,折腾我半天啊
  8. Security Token Service 不可用,无法激活服务“/SecurityTokenServiceApplication/securitytoken.svc ?
    1. 一种可能性是因为SecurityTokenServiceApplicationPool的启用32位应用程序=True,需要改成False;
    2. 还有一种原因:Windows密码过期了;
    3. 不过,还有可能就是瞎改SecurityTokenServiceApplication的web.config了,如何重新启用呢?
      1. 参考:http://blogs.msdn.com/b/sowmyancs/archive/2010/07/16/sharepoint-2010-service-applications-bcs-metadata-access-service-are-not-working.aspx
      2. 先使用Sharepoint 2010产品配置向导,可能会有错误导致失败,不过没关系,只是整理下思路;
      3. $sts = Get-SPServiceApplication | ?{$_ -match "Security"}
        
        
        $sts.Provision()
  9. Exception of type 'System.ArgumentException' was thrown. Parameter name: encodedValue  ...蛋疼了,在Sharepoint管理中点什么都错误?

    参考:http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/b90917a4-09f9-47e6-92d1-20496ab88ceb/

    原因:

    This error occurs when your site is configured for claims and you are logged into an account thats isn't being formatted as a proper claim.

    E.g.,

    If your site is claims and you log in VIA Ad and the Welcome control says "Domain\SomeUser" that is not a properly encoded claim, so when the OOTB Claim Provider try's to decode the claim, it errors out with encodedValue.

    The code that processes that encoded value is looking for an "i"  before a "|" in the login name "Domain\UserName" and there isn't one, so it throws an error that the passed in encodedValue is invalid or null etc.

    This usually indicates that your web config files are not properly configured for a site running in claims,  or you could have FBA set up and that's not configured properly either.

    Refer to this link for that,

    http://blogs.technet.com/b/speschka/archive/2009/11/05/configuring-forms-based-authentication-in-sharepoint-2010.aspx

    In some cases, if your using extremely custom authentication logic "like a custom Trusted Identity Provider" then you need to write your own ClaimProvider so sharepoint knows how to encoded/decode the claims.

    When it's result and you log in Via a Windows account, your login name should look something like "i#:w|Domain\UserName" (*spelling*).  And when logged in via fba it should look like "i#:membershipprovidernamehere|usernamehere" (*spelling*)

     

    This error can also occur if you have your SuperReader and Cache Reader accounts configured with improper claim values.  When using a Claims Configuration, your SuperReader and CacheReader account names need to be Encoded Claims like the examples above.  And I bet this is what's happening in your example,

    When you try to get an SPSite, because you have the Cache Accounts configured, it's trying to check the cache to see if the Site exists in the Cache, but when it does it dies when trying to evaluate the SuperReader and SuperUser accounts because it can't decode their claims because their not valid encoded claims, then you get the encodedValue exception.  It works sometimes because the object might not be cached, so it gets a new one, then when the object is cached it dies.

    Or it might work when your logged in via AD but die when logged in via FBA etc (just a hypothetical theory).

    Heres an article on this issue as well. (I struggled with this for a good week before I found this).

    http://technet.microsoft.com/en-us/library/ff758656.aspx

     


    My Blog: http://www.thesug.org/Blogs/ryan_mann1/default.aspx Website: Under Construction

    我把配置FBA时所改的3个web.config都改回去了,当时偷懒了直接使用继承的AspNetSqlRoleProvider,这样是不行。

  10. “An exception occurred when trying to issue security token: The security token username and password could not be validated.”或者“无法验证安全令牌用户名和密码”
    1. 有一种可能:该用户被锁定了,先解锁该用户。还不行的话,就有点麻烦了,继续往下;
    2. FBA的SQL数据库中早先建的用户是不能用的,即使在网站集管理中已经设子,正确步骤:
    3. 正确配置完三个web.config之后,在IIS中对应的Web站点中,设置默认的角色提供者和用户提供者为对应的FBA提供者;
    4. 创建角色和用户;
    5. 将默认的角色提供者和用户提供者改回去;
    6. 参考:http://msdn.microsoft.com/zh-cn/library/gg252020.aspx#ClaimsExample3_Step2
    7. declare @now datetime
      set @now= GETDATE()
       
      exec aspnet_Membership_CreateUser 'MyAppName','bob','pass@word1',
          '','bob@contoso.com','','',1,@now,@now,0,0,null
      exec aspnet_Membership_CreateUser 'MyAppName','mary','pass@word1',
          '','mary@contoso.com','','',1,@now,@now,0,0,null
      exec aspnet_Membership_CreateUser 'MyAppName','jack','pass@word1',
      '','jack@contoso.com','','',1,@now,@now,0,0,null
      
      EXEC aspnet_Roles_CreateRole 'MyAppName', 'Employee'
      EXEC aspnet_Roles_CreateRole 'MyAppName', 'TeamManager'
      EXEC aspnet_Roles_CreateRole 'MyAppName', 'CEO'
      
      EXEC aspnet_UsersInRoles_AddUsersToRoles 'MyAppName', 'bob', 'Employee', 8 
      EXEC aspnet_UsersInRoles_AddUsersToRoles 'MyAppName', 'mary', 'TeamManager', 8 
      EXEC aspnet_UsersInRoles_AddUsersToRoles 'MyAppName', 'jack', 'CEO', 8 
      EXEC aspnet_UsersInRoles_AddUsersToRoles 'MyAppName', 'jack', 'Admin', 8 
  11. Sharepoint Designer 无法打开站点,“服务器不能完成你的请求。有关详细信息请单击‘详细信息按钮
    1. 详细信息啥都没有,ULSView也啥都没有,纠结人呢
    2. Google的结果是http://social.technet.microsoft.com/Forums/en-US/sharepoint2010customization/thread/19628c53-fde2-44b0-806c-64f67263c931/ 。“Sam, there is an issue with web applications that have more than one binding in IIS.  When there is more than one, the site can't be opened.  To get around this, I have extended my web application to a new URL (host header) and used that URL to connect with SPD2010.”,大致意思是IIS中多个主机头绑定,可我没有啊;
    3. 好不容易在系统日志中发现点蛛丝马迹:"

      WebHost 无法处理请求。
      发件人信息: System.ServiceModel.ServiceHostingEnvironment+HostingManager/39147728
      异常: System.ServiceModel.ServiceActivationException: 由于编译过程中出现异常,无法激活服务“/_vti_bin/client.svc”。异常消息为: 无法创建相对 URI,因为“uriString”参数表示绝对 URI。http://xxx:2222/_vti_bin/client.svc。 ---> System.UriFormatException: 无法创建相对 URI,因为“uriString”参数表示绝对 URI。http://xxx:2222/_vti_bin/client.svc
      在 System.ServiceModel.Activation.ApplyHostConfigurationBehavior.ThrowIfAbsolute(Uri uri)
      在 System.ServiceModel.Activation.ApplyHostConfigurationBehavior.FailActivationIfEndpointsHaveAbsoluteAddress(ServiceHostBase service)
      在 System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost)
      在 System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
      在 System.ServiceModel.ServiceHostBase.InitializeRuntime()
      在 System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
      在 System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
      在 System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
      在 System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
      --- 内部异常堆栈跟踪的结尾 ---
      在 System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
      在 System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)
      进程名称: w3wp
      进程 ID: 7828

      "
    4. Client.svc确实没有激活,而管理网站中是可以的。看来问题还是在主机头绑定上
    5. 再次检查web.config,发现<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />,手贱呢,一个晚上就因为这么这原因,删掉就好,嘛的,Sharepoint Designer终于可以连上了。
  12. Windows 7的Sharepoint Foundation 2010不能安装Office Web Apps?
    1. 看这里:http://myriadtech.com.au/blog/James/Lists/Posts/Post.aspx?ID=50
  13. 安装Office Web Apps的怎么老是报"...Windows server features 和 Role Services 没有启用... "?
    1. 重新运行下sharepoint安装时的PrerequisiteInstaller.
  14. iframe中嵌入Excel表单,提示"此内容无法在框架中显示".
    1. http://ventigrate.codeplex.com/wikipage?title=Permissive%20XFrame%20Header
  15. 挖坑ing...
posted @ 2011-12-28 16:22 bengxia 阅读(...) 评论(...) 编辑 收藏
无觅相关文章插件,快速提升流量