ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 9235|回复: 13

加载宏的改进

[复制链接]

TA的精华主题

TA的得分主题

发表于 2006-7-27 11:15 | 显示全部楼层 |阅读模式

Managed Add-In Improvements
加载宏的改进

(译者:原文中有多处出现Managed,笔者认为直译出来反而会很绕口,忽略它也不会影响理解。)


Today we have the second of two guest posts from Patrick Smith, a program manager on the Office Programmability team.
今天,我们发表两篇客串帖子中的第二篇,来自Patrick Smith,Office 程序开发小组的程序经理。

Overview and Background
概述和背景


Managed code is becoming more and more prevalent in add-ins written for Microsoft Office products.  Also shipping around the same time frame as the 2007 Microsoft Office System is the next version of Visual Studio Tools for Office (VSTO).   The next version of VSTO has added support for creating application level add-ins.  The demand for better support of managed add-ins is clear since with Office 2003, there are a few challenges when running managed code.  Among these challenges are security, resiliency, administration, and isolation.  Most of these challenges are the result of add-ins based on mscoree.dll which is the loader used by the default VS.NET add-in template.
代码在为Office成品编写的加载宏里变得越来越流行了。Visual Studio Tools for Office (VSTO)下个版本和Office 2007大概在同一时间段上市。VSTO的下个版本增加了对在应用软件级创建加载宏的支持。自从Office 2003开始,代码的更好支持的需求就已经清楚了,但是,运行代码时会有一些挑战。在这些挑战中有安全,恢复,管理和隔离。这些挑战中的大多数都是由于加载宏基于mscoree.dll而导致,mscoree.dll是缺省的VS.Net加载宏模板使用的加载器。
While there are workarounds to these barriers such as creating a separate unmanaged “shim” to use in place of mscoree.dll, we wanted to make this process better for the products in the 2007 Microsoft Office System.  We’ve done exactly that!  
有些工作区域是针对这些障碍的,例如创建一个单独的“shim”来代替mscoree.dll,我们想要让Office 2007系统中的这个过程变得更好一些。我们正是那样做的!

The Improvements
As a developer, you can now design your add-in to use a new AddinLoader supplied in a new version of  VSTO.   This new AddinLoader helps overcome these historical challenges when running managed code in Office:


改进

作为一名开发者,你现在可以使用VSTO新版本提供的AddinLoader来设计你的加载宏了。在Office里运行代码时,新的AddinLoader帮助克服那些历史挑战。
• The security model – Microsoft Office System 2003 products bases all add-in security decisions based on mscoree.dll which cannot be signed.  Because of this security model, the add-in itself can be signed but the Office product would not know it because it is only looking at mscoree.dll. and since it’s only looking at mscoree.dll, no add-in can run when the Office application is set to High security.   Now, if an add-in is based on the AddinLoader, the 2007 Microsoft Office System will be able to defer to the .NET security model to make the security decisions for the add-in.  This is only possible by using AddinLoader.
• 安全模式——Office系统2003产品架构里的所有加载宏的安全决定都是基于mscoree.dll,它是不可签名的。正因为该安全模式,加载宏本身不可签名,而Office产品也不会知道,因为它只看mscoree.dll,并且,因为只看mscoree.dll,所以当Office应用软件设置安全性为高时,没有加载宏可以运行。现在,如果加载宏是基于AddinLoader的话,那么Office 2007系统就能够区别.NET安全模式,为加载宏决定安全性。只有使用AddinLoader,这才是可能的。
• The resiliency model – Microsoft Office System 2003 products will automatically disable add-ins that fail to load so that future problems with the add-in can be prevented, however, since the add-in is actually seen as mscoree.dll, mscoree.dll is the add-in that is disabled rather than the actual managed COM add-in that is causing a problem.  This prevents any other mscoree.dll based add-ins from loading as well because the loader itself is disabled.  Now the add-in is seen rather than the loader and ill-behaving add-ins can be disabled individually rather than the loader.
• 恢复模式——Office 2003系统的产品会自动禁用加载失败的加载宏,因此,就可以避免该加载宏以后的问题,然而,因为该加载宏实际上是被看作mscoree.dll的,mscoree.dll是被禁用的加载宏,而不是实际上导致该问题的COM加载宏。这就会防止任何基于mscoree.dll的加载宏加载,因为加载器本身被禁用了。现在,看的是加载宏而不是加载器,具体有错误行为的加载宏被禁用,而不是加载器被禁用。
• Administration – When viewing the Add-Ins dialog box, mscoree.dll is seen as the add-in name rather than the actual managed COM add-in that is running within mscoree.dll.  Once you are running more than one add-in, it becomes difficult to discern which one is which.  Now the name of the actual add-in is displayed.
• 管理——当查看加载宏对话框时,mscoree.dll就会被看作是加载宏名称,而不是实际在mscoree.dll里运行的COM加载宏。一旦你在运行多个加载宏,就很难辨别哪个是哪个了。现在,显示的是实际的加载宏的名称了。
• Runtime Isolation – mscoree.dll loads all add-ins into the default AppDomain.  Therefore, with no memory isolation, add-ins can step on each other and affect objects that are shared between add-ins.  The new AddinLoader will use separate AppDomains for the add-in and therefore provide isolation to that add-in.
• 运行时间隔离——mscoree.dll将所有加载宏加载到默认的AppDomain。因此,没有内存隔离,加载宏可以相互步入,影响加载宏之间共享的对象。新的AddinLoader将给每个加载宏使用独立的AppDomains,因此,实现了对该加载宏的隔离。


What’s needed
In order to take advantage of these new improvements, you will need to create your add-in using the new version of VSTO.  (There is a technology preview of this version located here.
需要什么

为了利用这些新的改进,你将需要使用VSTO新版本(这里有篇对该版本的技术概述)来创建你的加载宏。
In addition, you’ll need to ensure the following configuration is available on the machine where the add-in is to be loaded:
• Common Language Runtime 2.0 or greater
• VSTO Runtime (from the new version of VSTO)
• CAS policy giving the Add-in full trust

另外,你需要确保在加载宏加载的机器上有下述配置可用:
• Common Language Runtime 2.0或以上版本
• VSTO Runtime(来自VSTO的新版本)
• CAS政策给加载宏充分信任
All of these prerequisites can be configured through the setup project for the add-in you create in VSTO.
所有这些前提条件都可以从你在VSTO里创建的加载宏的安装工程里配置。


Published Wednesday, June 21, 2006 8:06 AM by David Gainer
Filed Under: Programmability

注:本文翻译自http://blogs.msdn.com/excel ,原文作者为David Gainer(a Microsoft employee),Excel Home 授权转载。严禁任何人以任何形式转载,违者必究。

[此贴子已经被Kevin于2006-8-3 20:14:31编辑过]

TA的精华主题

TA的得分主题

发表于 2007-1-20 12:19 | 显示全部楼层

2007里面 怎样启用宏阿?

TA的精华主题

TA的得分主题

发表于 2007-2-11 15:13 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助

学习

TA的精华主题

TA的得分主题

发表于 2007-3-7 20:22 | 显示全部楼层

感謝 先生的好文章。

如此概念運用在舊版本,不知可行否?

TA的精华主题

TA的得分主题

发表于 2007-3-17 21:09 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2007-4-1 11:16 | 显示全部楼层

EXCEL选项-常用-在功能区显示“开发工具”栏选项卡

TA的精华主题

TA的得分主题

发表于 2007-4-15 17:09 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2007-5-12 21:44 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
发帖支持一下

TA的精华主题

TA的得分主题

发表于 2007-6-25 15:08 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2007-7-11 23:41 | 显示全部楼层

现在的宏运行之后,可以撤销吗?

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-7-17 18:02 , Processed in 0.049237 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

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