日期:2014-05-20  浏览次数:20965 次

.net里那个工具可以让.net的类库变成com组件
如题目

------解决方案--------------------
http://www.cnblogs.com/team/DotNetControls.html
------解决方案--------------------
首先建一个ASP.NET项目(类库):Encode
添加类文件:Encode.cs
using System;
using System.EnterpriseServices;

[Transaction(TransactionOption.NotSupported)]
public class Encode : ServicedComponent
{
public Encode()
{
}
public string Greet()
{
return "hello world! ";
}
}
在引用中添加引用:
System.EnterpriseServices
设置AssemblyInfo.cs:
增加:
[assembly: AssemblyKeyFile( "E:\\liu\\Encode.snk ")]
[assembly: ApplicationName( "Encode ")]
[assembly: ApplicationAccessControl(true)]
[assembly: ApplicationID( "4fb2d46f-efc8-4643-bcd0-6e5bfa6a174c ")]
修改:[assembly: ComVisible(false)]
为true

VS2005命令:
进入 cd e:\liu目录进行以下命令操作:
A.在E:下建立文件夹(作为ASP目录)liu
B.用命令sn生成强命名文件 Encode.snk
sn -k Encode.snk
C.将Encode项目生成,得到Encode.dll,把Encode.dll复制到liu目录下,和Encode.snk同一目录下.
D.用命令regsvcs Encode.dll
完成!