代码改变世界

在 Windows Server 2003 SP2 下部署使用 C# 开发的 MMC 控制台程序

2008-11-11 17:46  Scott Wong  阅读(1818)  评论(2编辑  收藏  举报

从微软网站上把 Windows SDK for Windows Server 2008 and .NET Framework 3.5 下载回来安装好之后,使用 Microsoft Visual Studio 2008 打开 C:\Program Files\Microsoft SDKs\Windows\v6.1\Samples\SysMgmt\MMC3.0\ExtendingComputerManagementSample 示例,编译生成 ExtendingComputerManagementSample.dll 文件。在 Vista 下使用 InstallUtil.exe 工具部署成功,但在 Windows Server 2003 下使用 InstallUtil.exe 工具部署时却遇到 System.Reflection.ReflectionTypeLoadException 异常。

 

————————————————————我是传说中的分割线————————————————————

 

Microsoft Windows [版本 5.2.3790]
(C) 版权所有 1985-2003 Microsoft Corp.

C:\Documents and Settings\Administrator>cd C:\WINDOWS\Microsoft.NET\Framework\v2
.0.50727

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>InstallUtil.exe C:\ExtendingComput
erManagementSample.dll
Microsoft (R) .NET Framework 安装实用工具版本 2.0.50727.3053
版权所有(C) Microsoft Corporation。保留所有权利。

正在运行事务处理安装。

正在开始安装的“安装”阶段。
查看日志文件的内容以获得 C:\ExtendingComputerManagementSample.dll 程序集的进度。

该文件位于 C:\ExtendingComputerManagementSample.InstallLog。
正在安装程序集“C:\ExtendingComputerManagementSample.dll”。
受影响的参数是:
   logtoconsole =
   assemblypath = C:\ExtendingComputerManagementSample.dll
   logfile = C:\ExtendingComputerManagementSample.InstallLog
试图在 C:\ExtendingComputerManagementSample.dll 程序集中查找安装程序时发生异常。

System.Reflection.ReflectionTypeLoadException: 无法加载一个或多个请求的类型。有
关更多信息,请检索 LoaderExceptions 属性。
正在中止安装 C:\ExtendingComputerManagementSample.dll。

在“安装”阶段发生异常。
System.InvalidOperationException: 无法获得 C:\ExtendingComputerManagementSample.
dll 程序集中的安装程序类型。
引发了内部异常 System.Reflection.ReflectionTypeLoadException,错误消息如下: 无法
加载一个或多个请求的类型。有关更多信息,请检索 LoaderExceptions 属性。。

正在开始安装的“回滚”阶段。
查看日志文件的内容以获得 C:\ExtendingComputerManagementSample.dll 程序集的进度。

该文件位于 C:\ExtendingComputerManagementSample.InstallLog。
正在回滚程序集“C:\ExtendingComputerManagementSample.dll”。
受影响的参数是:
   logtoconsole =
   assemblypath = C:\ExtendingComputerManagementSample.dll
   logfile = C:\ExtendingComputerManagementSample.InstallLog
试图在 C:\ExtendingComputerManagementSample.dll 程序集中查找安装程序时发生异常。

System.Reflection.ReflectionTypeLoadException: 无法加载一个或多个请求的类型。有
关更多信息,请检索 LoaderExceptions 属性。
正在中止安装 C:\ExtendingComputerManagementSample.dll。
在 System.Configuration.Install.AssemblyInstaller 安装程序的“回滚”阶段发生异常

System.InvalidOperationException: 无法获得 C:\ExtendingComputerManagementSample.
dll 程序集中的安装程序类型。
引发了内部异常 System.Reflection.ReflectionTypeLoadException,错误消息如下: 无法
加载一个或多个请求的类型。有关更多信息,请检索 LoaderExceptions 属性。。
在安装的“回滚”阶段发生异常。将忽略该异常并继续回滚。但是,在完成回滚后计算机可
能无法完全还原到它的初始状态。

“回滚”阶段已成功完成。

已完成事务处理安装。
安装失败,已执行回滚。

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>

 

————————————————————我是传说中的分割线————————————————————

 

问题很好解决,只要先运行一下 C:\WINDOWS\system32\mmcperf.exe 程序,再用 InstallUtil.exe 工具部署就可以了。(确实很好解决,但是找到这个方法却花了我整整两天的时间)

 

相关下载:

Microsoft .NET Framework 3.5 Service Pack 1(完整软件包)
http://download.microsoft.com/download/2/0/e/20e90413-712f-438c-988e-fdaa79a8ac3d/dotnetfx35.exe

Microsoft .NET Framework 3.5 SP1 语言包

http://download.microsoft.com/download/7/7/b/77b96978-c805-4674-a9b0-43351e86b41f/dotnetfx35langpack_x86zh-CHS.exe