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

Question  135
 You work for a software company that sells Web Parts to customers. You designed the first version of a Web Part named Weather 1.0. The company has already sold several hundred licenses of the Web Part. You designed a new solution package for Weather 2.0. Some customers who are already using Weather 1.0 will install Weather 2.0 in the same Web application as Weather 1.0. You need to design your package so that the functionality of Weather 1.0 will not be affected by the installation of Weather 2.0 in the same Web application. Which approach should you recommend?
A. Use the same assembly name and namespace for Weather 2.0 that you used for Weather 1.0. Create a new .web part file. Increment the version number in the .web part file.
B. Use the same assembly name and namespace, but increment the version number of the assembly package. Use the same .web part file that you used for Weather 1.0.
C. Use the same assembly name and namespace, but increment the version number of the assembly package. Configure assembly binding redirection from version 1.0 of the assembly to version 2.0. Use the same .web part file that you used for Weather 1.0.
D. Use the same assembly name and namespace, but increment the version number of the assembly package. Create a new .web part file.


解析:
  你为一家专门为客户提供Web part产品的公司开发了一个名为Weather 1.0版本的Web Part,此公司已经卖出去了几百套此Web Part, 你现在开发了此Web Part的新版本Weather 2.0,以前已经使用Weather 1.0的老客户需要在他们应用的环境中安装Weather 2.0,你需要保证Weather 1.0的运行功能不会因为Weather 2.0的安装受影响。你该采用何种措施来达成此目的呢?
   顾名思义,WebPart就是组成网页(Web)的部件(Part),它是SharePoint站点WebPartPage的基本构建块。直观的看,在SharePoint网站的页面上,数据的显示、数据的编辑,都是通过一个一个的WebPart来完成的;实质上,WebPart是ASP.NET自定义控件,都是由一个WebPart说明文件(.dwp)和WebPart程序集(.dll)组成。
   如果你对早先部署的WebPart程序集(.dll)进行了升级,那么原先添加的Web Part就会停止工作,因为Sharepoint找不到针对原先Web part的程序集了。【这也是本题要求尽量避免的】
   由于.NET支持并行存储和执行同一程序集的不同版本,这种支持内置于运行时基础结构中。 因为强名称程序集的版本号是其标识的一部分,所以运行时能够在全局程序集缓存中存储同一程序集的多个版本,并且在运行时加载这些程序集。根据这一特性,我们就可以创建一个新的Feature,但使用相同的程序集签名和不同的版本号,这样我们就解决了WebPart程序集(.dll)升级后找不到原程序集而造成的已安装Web Part运行失效的问题。 而备选项中,选项D符合这样的操作。
  选项A. 修改.web part文件中的Version并不影响程序集的Version,如果程序集的Version不变就会覆盖掉原来的WebPart程序集(.dll),造成已部署Web Part的停工,所以排除。
  选项B. 如果使用的是与Weather 1.0相同的.web part(内有Web Part版本号)文件,那还叫什么功能升级呢?所以排除。
  选项C. 犯了与选项B一样的错误,使用的是与Weather 1.0相同的.web part文件。所以排除。
 

因此本题答案应该选  D

参考 
http://blogs.msdn.com/b/andrasg/archive/2011/07/19/the-good-solution-for-versioning-sharepoint-2010-webparts.aspx
http://msdn.microsoft.com/en-us/library/cc768621(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/ff407219(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/ms227561.aspx
http://msdn.microsoft.com/zh-cn/library/vstudio/fdhkd3a5.aspx


Question  136
 You are designing a SharePoint 2010 application. You have a requirement to allow access to a Microsoft  Windows .NET Framework assembly across multiple Web applications in a farm. An assembly element has been added to the solution manifest (manifest.xml). You need to ensure that the deployment of the assembly meets the requirements. Which approach should you recommend?
A. Specify a Deployment Target of GlobalAssemblyCache.
B. Specify a Deployment Target of Web Application.
C. Specify a Location of GlobalAssemblyCache.
D. Specify a Location of Web Application.


解析:
  你开发了一个Sharepoint2010应用程序,在你开发的解决方案的manifest.xml中你加入了程序集元素(assembly element),你需要保证在场内的不同Web Application之间可以访问这个开发的Microsoft  Windows .NET Framework的程序集,你该如何部署你的开发才能满组上述需要呢?
  本题使用到了解决方案文件manifest.xml:解决方案指令清单(通常称为 manifest.xml)存储在解决方案文件的根位置。此文件定义要处理的功能、网站定义、资源文件、Web 部件文件和程序集的列表。 在manifest.xml的assembly元素中指定要包含在解决方案中的程序集。 

<Solution SolutionId="4AFC1350-F354-4439-B941-51377E845F2B" xmlns="http://schemas.microsoft.com/sharepoint/">
  <FeatureManifests>
    <FeatureManifest Location="FeatureLibrary\feature.xml"/>
  </FeatureManifests>
  <TemplateFiles>
    <TemplateFile Location="ControlTemplates\Featurelibraryform.ascx"/>
  </TemplateFiles>
  <RootFiles> 
  <!-- These files go into the 12\ directory and can be used for Web services and global resources -->
    <RootFile Location="ISAPI\MyWebService.asmx">
  </RootFiles>
  <Assemblies>
    <Assembly  DeploymentTarget="GlobalAssemblyCache" 
Location="ms.samples.sharepoint.myFeature.dll"/>
  </Assemblies>
</Solution>

其中DeploymentTarget属性:为可选属性,类型为 Text。程序集部署的首选目标。将程序集复制到由 DeploymentTarget 属性(对于 Web 应用程序)或全局程序集缓存(对于服务器场)指定的目标。可能的值:
GlobalAssemblyCache   如果程序集是一种场功能,则将其复制到全局程序集缓存。
WebApplication   如果程序集是一种 Web 应用程序功能,则将其复制到虚拟服务器的 bin 目录。
 由于本题要求在场内的不同Web Application之间可以访问这个开发的Microsoft  Windows .NET Framework的程序集,所以应该部署在全局程序集缓存中,即此属性值为GlobalAssemblyCache 。

因此本题答案应该选  A

参考 
http://msdn.microsoft.com/zh-cn/library/ms442108(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/ms468837.aspx


Question  137
 You are designing a SharePoint 2010 application. You need to plan the deployment of a user control named MyControlTemplate.ascx as a control template. What should be added to the solution manifest (manifest.xml) to achieve this goal?
A. Add a Template File element, specifying a Location of MyControlTemplate.ascx.
B. Add a Template File element, specifying a Location of Control Templates\MyControlTemplate.ascx.
C. Add a Root File element, specifying a Location of MyControlTemplate.ascx.
D. Add a Root File element, specifying a Location of Control Templates\MyControlTemplate.ascx.

解析:
  你想要把一个名为MyControlTemplate.ascx的用户自定义控件部署成一个控件模板,你该如何添加此元素到解决方案的manifest.xml文件中呢?
  此题的备选项涉及解决方案指令清单(manifest.xml)中的Template File元素与Root File元素。
 Root File元素: 指定将解决方案文件复制到的根路径。使用此元素可部署由多个功能共享的本地化资源。共享的本地化资源位于 %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\Resources 文件夹中。例如,以下 XML 部署三个共享的本地化资源文件。

<RootFiles>
  <RootFile Location="Resources\wingtip.resx" />
  <RootFile Location="Resources\wingtip.en-US.resx" />
  <RootFile Location="Resources\wingtip.es-ES.resx" />
</RootFiles>

Template File元素:指定要包括在该解决方案中的模板文件。Sharepoint的模板文件一般都是放在Template目录下,而控件模板则放在此目录下的ControlTemplates文件夹下(目录位置如图)。

 <TemplateFiles>
    <TemplateFile Location="ControlTemplates\Featurelibraryform.ascx"/>
 </TemplateFiles>


因此本题答案应该选 B

参考 
http://msdn.microsoft.com/zh-cn/library/ms450312(v=office.14).aspx
http://msdn.microsoft.com/zh-cn/library/aa543424(v=office.14).aspx

posted @ 2014-03-19 13:46  wsdj  阅读(468)  评论(0编辑  收藏  举报