Sharepoint学习笔记—习题系列--70-576习题解析 -(Q19-Q20)

Question 19
You are designing a custom SharePoint 2010 solution package. It will include a feature that contains a Web Part,which requires a custom assembly for its functionality. You need to design the feature based on the following requirements:
.The Web Part must be a partial trust application and support a custom Code Access Security (CAS) policy.
.The solution package must be deployed without the need of farm-level administrator permissions.
Which approach should you recommend?
A. Create the Web Part feature and deploy the required assembly to the bin directory of only the Web applications that require it. Then delegate administration to the site administrator. Lastly, create a custom CAS policy file and point to it the web.config file of the application.
B. Create the Web Part feature assembly with a strong name and deploy it using a .wsp file to the _app_bin directory of all Web applications where it is needed. Then activate it using delegated administration.
C. Create an assembly with a strong name and deploy it to the global assembly cache at the farm level. Activate the feature at the site collection level with delegated administration.
D. Create the Web Part feature as a sandboxed solution.


解析:
 本题需要你创建一个包含有WebPart的解决方案,此Webpart需要基于客户定义的程序集实现其功能。解决方案需要满足如下条件:
  要求1. 此WebPart必须实现的是部分信任的应用,并支持代码访问安全性策略(CAS)
 要求2.此解决方案不需要场管理员的支持就能部署。
 看到上面的要求,尤其是第2个要求,马上就应该反应出SandBox Solution了。本题的备选项只有选项D使用了沙盒方案,所以应该是选项D。
  但是我们还是需要过一遍其它备选项以肯定我们的判断:
  选项 A. Create the Web Part feature and deploy the required assembly to the bin directory of only the Web applications that require it. Then delegate administration to the site administrator. Lastly, create a custom CAS policy file and point to it the web.config file of the application.
本选项把WebPart部署到Bin目录,我们来了解下这种情况。
在 SharePoint 网站内,可以将 Web 部件程序集部署到多个位置。
1.解决方案库 – 解决方案库是使用沙盒解决方案部署 Web 部件时的建议位置。默认情况下,它为 Web 部件提供监视和安全性。
2. bin 目录 — bin 目录是一个存储在 Web 应用程序根目录下的文件夹。在 Internet Information Services (IIS) 中创建网站时将确定此文件夹的位置。在 SharePoint Foundation 中,可以通过管理中心网站或通过在 IIS 管理器中手动创建新网站来实现此目的。
 重要信息:如果 bin 目录不存在,您必须手动添加一个 bin 目录。请不要在本地 _app_bin 目录中存储 Web 部件,此目录是专为 Microsoft 保留的。
3.全局程序集缓存 — 可用于部署已签名程序集的全局位置。利用全局程序集缓存,可以跨多个应用程序共享程序集。全局程序集缓存将随 .NET 运行库一起自动安装。通常,组件将存储在 C:\WINNT\Assembly 文件夹中。
其中,针对本选项所采取的第2种方式即bin目录方式,其优点是:默认情况下,程序集以部分信任的形式运行。从该目录运行的代码具有较低级别的代码访问安全性 (CAS) 权限。由于管理员必须明确提升已向 Web 部件授予的权限以使该部件能够正常运行,因此他们通常更愿意程序集在 bin 目录中通过已知的必需 CAS 权限集运行。每个 Web 应用程序都有一个 bin 目录。这样,就可以隔离特定 Web 应用程序的代码。但缺点是:为了使此 Web 部件能够在多个 Web 应用程序中运行,您必须将此 Web 部件部署到全局程序集缓存中。【这句就是破解本选项的要点,既然要求部署到全局程序集缓存中,那就不可能脱离场管理员的支持了】

选项B. Create the Web Part feature assembly with a strong name and deploy it using a .wsp file to the _app_bin directory of all Web applications where it is needed. Then activate it using delegated administration.
此选项就更直接,我们来看看微软的说明:” Web 部件程序集可以安装在 Web 应用程序的 bin 目录或全局程序集缓存中,如果 bin 目录不存在,您必须手动添加一个 bin 目录。请不要在本地 _app_bin 目录中存储 Web 部件,此目录是专为 Microsoft 保留的。” 所以仅就这一句就可以排除本选项了。

选项C. Create an assembly with a strong name and deploy it to the global assembly cache at the farm level. Activate the feature at the site collection level with delegated administration.
  本选项也与选项A类似,都要涉及到全局程序集缓存,所以也必然被排除了。

因此本题答案应该选 D

参考 
http://msdn.microsoft.com/zh-cn/library/ff798425.aspx
http://msdn.microsoft.com/zh-cn/library/cc768621(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/bb815365(v=office.12).aspx

Question 20
A SharePoint 2010 server farm has a custom feature installed that provides specialized business logic for a SharePoint solution package. The solution package is being updated to include additional functionality. Your job isto specify a deployment method for the updates that will:
.Add the additional application business logic to the solution package.
.Provide the least downtime for the application.
.Automate the application upgrade a much as possible.
You need to update the solution package with additional business logic and meet all these requirements. Which
approach should you recommend?
A. Create a new feature containing the new business logic. Use the feature upgrade process to deploy the solution package by incrementing the version number of the feature in the Feature.xml file.
B. Add the new business logic to the existing feature. Use the feature upgrade process to deploy the solution package by incrementing the version number of the feature in the Feature.xml file.
C. Use Visual Studio 2010 to add the new business logic to the existing code in the .wsp package for the feature. Create two timer jobs - one to retract the current solution package and one to deploy the solution package with
the updated feature.
D. Use the object model to create a custom feature receiver to increment the version property of the SPFeatureDefinition class. Increment the version number of the current solution in the Feature.xml file.

解析:
  本题题意是你的服务器场中已经包含了某个功能,此功能是通过一个方案包部署到场中的。现在,你需要在这个原有的功能中加入更多的操作,然后通过更新升级那个原有的方案包以替换成新的这个具有更多操作的功能。要求是:
  要求1. 新的操作逻辑应该被添加到解决方案包中
  要求2 尽量减少已有方案的停用时间
  要求3. 升级操作尽可以自动化
 我们先来回顾一下Sharepoint关于Feature升级的部分:
在 Microsoft SharePoint Foundation 中,每个功能(Feature)都具有一个在与其对应的 Feature.xml 文件中指定的版本号。在某个特定范围内激活一个功能时,会创建一个与该功能的版本关联的功能实例。利用 SharePoint Foundation 中的功能版本控制,可轻松跟踪功能及其关联实例。之后,当您部署新版本的功能时,SharePoint Foundation 检测到关联的功能也需要进行升级,因为功能实例的版本号小于当前的 Feature.xml 文件中指定的新版本号。
 注释: 最佳做法是,决不将 FEATURES 文件夹中的功能文件与解决方案部署文件或解决方案升级文件分开放置,因为功能升级是一个高级部署选项,它不会在部署期间验证功能 XML。
在运行功能升级时,还会根据新 Feature.xml 文件中指定的升级操作对需要升级的功能实例进行升级。
  接下来分析各备选项:
选项A. Create a new feature containing the new business logic. Use the feature upgrade process to deploy the solution package by incrementing the version number of the feature in the Feature.xml file.
   此选项是重新创建一个新的Feature,这显然不符合在原有Feature的基础上进行升级的要求。而且如上面描述:决不将 FEATURES 文件夹中的功能文件与解决方案部署文件或解决方案升级文件分开放置。另一个层面,你不需要重新定义一个新的Feature来实现升级。所以本选项应该被排除。
选项B. Add the new business logic to the existing feature. Use the feature upgrade process to deploy the solution package by incrementing the version number of the feature in the Feature.xml file.
  在已有的Feature代码中添加新的操作,然后通过Feature升级的相关处理以替换更新原有的Feature。符合上面Feature升级描述。

选项C. Use Visual Studio 2010 to add the new business logic to the existing code in the .wsp package for the feature. Create two timer jobs - one to retract the current solution package and one to deploy the solution package with the updated feature.
本选项试图在VS2010中修改wsp包的代码,向其中添加新的操作逻辑。我们知道,所谓wsp包就是解决方案包, 是一个分发包,可将您的 SharePoint Foundation 2010 自定义开发工作成果分发到服务器场中的 Web 服务器或应用程序服务器。使用解决方案可打包和部署自定义功能、网站定义、模板、布局页、Web 部件、级联样式表和程序集。解决方案包是一个扩展名为 .wsp 的 CAB 文件和一个指令清单文件。可以打包到解决方案中的组件包括:
1 .NET Framework 程序集,通常是 Web 部件程序集和事件接收器程序集。
2.部署文件,例如资源文件、网页或其他帮助程序文件。
3.功能,使您能够激活和停用网站中的代码,并提供包括自定义列表、库、字段和内容类型等元素的功能。
4.新的模板和网站定义。
5.必须在 Web 服务器级别执行的配置,例如,将自定义项部署到 Web.config 文件,以用于注册 Web 部件。您还可以使用随功能分发的功能修改这些配置。
6.被称为网页的 Web 内容(如网页和图像)。如果您必须在断开连接的环境中部署 Web 内容,应该使用内容部署包。
Sharepoint支持创建和部署自定义 Web 部件解决方案包。
本题的目标是,你需要添加新的操作逻辑去升级原有的Feature,因此,本选项的局限在于:1.通过直接修改wsp包的代码是无法添加新的操作逻辑的,因为这些操作逻辑很大程度上是需要被重新编译的,而这样一来,就需要重新生成wsp包,而不仅仅是修改其内部的代码来直接达到。2. 仅添加新的business logic并没有解决如何对Feature进行升级的操作。而至于后续的timer jobs也只是去完成wsp包的卸载与重新安装部署,我们当然可以通过Replacements 方式去升级一个Solution,但这种方式必须要重启我们的IIS,由此会造成downtime时间,这也是本题所不想要的。所以,本选项也应该被排除。
选项D. Use the object model to create a custom feature receiver to increment the version property of the SPFeatureDefinition class. Increment the version number of the current solution in the Feature.xml file.
   本选项没有解决向原有Feature中添加新的操作,只是围绕着如何通过修改版本属性来影响升级,所以也应该被排除。
因此本题答案应该选 B

参考 
http://msdn.microsoft.com/zh-cn/library/ee535723(v=office.14).aspx
http://technet.microsoft.com/zh-cn/library/ff607688(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/aa544500.aspx
http://msdn.microsoft.com/zh-cn/library/ee535708(v=office.14).aspx

 

posted @ 2013-09-16 07:44  wsdj  阅读(412)  评论(2编辑  收藏  举报