一、不生成具有强名称的程序集
1.使用下面这两个命令将COM控件转换成.Net程序集
aximp c:““windows““system““shdocvw.dll
tlbimp mshtml.tlb
aximp将产生两个文件:AxSHDocVw.dll and SHDocVw.dll.
tlbimp将产生MSHTML.dll,它包含了3000多个 DHTMLDOM的接口,所以转换可能需要一些时间.
2. 上面产生的DLL文件直接可由.Net应用程序调用了。
二、生成具有强名称的程序集
1.用sn 命令生成三个snk文件,分别是后面将要生成的程序集的密钥文件
Sn –k AxSHdoc.snk
Sn –k shdocvw.snk
Sn –k mshtml.snk
2.使用上面aximp 和 tlbimp 生成这三个程序集文件,这些命令加上/keyfile:可选项
aximp c:““windows““system““shdocvw.dll /keyfile:AxSHDOC.snk shdocvw.snk
tlbimp mshtml.tlb /keyfile:mshtml.snk
这样就可以生成具有强名称的程序集了。
3.把它们加到程序集缓存中,分别调用
Gacutil axshdocvw.dll
Gacutil shdocvw.dll
Gacutil mshtml.dll
打开全局程序集缓存,就可以看到这三个程序集已经在列表中了。
在C:““winnt““assembly也可以看到了。
调用ActiveX控件编写播放器时,遇到了不少问题!
播放器如
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using MediaPlayer;
namespace AdvancePlayer
{
/**//// summary
/// Form1 的摘要说明。
/// /summary
public class Form1 : System.Windows.Forms.Form
{
private AxMediaPlayer.AxMediaPlayer axWindowsMediaPlayer1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItemOpen;
private System.Windows.Forms.MenuItem menuItemClose;
private System.Windows.Forms.MenuItem menuItemInitSize;
private System.Windows.Forms.MenuItem menuItemFullScreen;
private System.Windows.Forms.MenuItem menuItemShowAudioCtrl;
private System.Windows.Forms.MenuItem menuItemShowPositionCtrl;
private System.Windows.Forms.MenuItem menuItemShowTrackbarCtrl;
private System.Windows.Forms.MenuItem menuItemFile;
private System.Windows.Forms.MenuItem menuItemVideo; [Page]
private System.Windows.Forms.MenuItem menuItemWindow;
/**//// summary
/// 必需的设计器变量。
/// /summary
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/**//// summary
/// 清理所有正在使用的资源。
/// /summary
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();