在asp.net中怎么使用com组件?请大侠们指教?

sdcqsy 2009-08-24 09:18:54
我现在遇到一个这样的问题,我注册了一个dll的组件,做winform程序时可以加裁到工具箱里,但是在做web站点时,却加裁不进去了,请问这是什么原因?有没有解决办法?
...全文
113 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
bigmingming 2009-08-25
  • 打赏
  • 举报
回复
sdcqsy 2009-08-24
  • 打赏
  • 举报
回复
我现在用的图王(vg.dll),应该是C++写的
qingwa008 2009-08-24
  • 打赏
  • 举报
回复
你这个com是啥写的?c++?delphi?有啥功能?
regasm tlbExp regsvr32
sdcqsy 2009-08-24
  • 打赏
  • 举报
回复
我注册了一个dll组件,随便建了一个web站点,在工具箱中加裁该组件的时候,什么提示也没有,仔细查看工具箱之后,里面根本就没有加裁进去
xycit 2009-08-24
  • 打赏
  • 举报
回复
up
bigmingming 2009-08-24
  • 打赏
  • 举报
回复
这个组件应该是FOR WINDOWS的。不支持ASP.NET
Lovely_baby 2009-08-24
  • 打赏
  • 举报
回复
请引用System.EnterpriseServices.dll   

然后using System.EnterpriseServices

从ServiceComponent类派生一个类就可以使用Com+服务了,具体内容请参考:
ms-help://MS.VSCC/MS.MSDNVS.2052/cpguide/html/cpconwritingservicedcomponents.htm


示例:
BankComponent 服务器

[Visual Basic]
Imports System.EnterpriseServices
Imports System.Runtime.CompilerServices
Imports System.Reflection

' Supply the COM+ application name.
<assembly: ApplicationName("BankComponent")>
' Supply a strong-named assembly.
<assembly: AssemblyKeyFileAttribute("BankComponent.snk")>

Namespace BankComponent
<Transaction(TransactionOption.Required)> _
Public Class Account
Inherits ServicedComponent
<AutoComplete()> _
Public Sub Post(accountNum As Integer, amount As Double)
' Updates the database; no need to call SetComplete.
' Calls SetComplete automatically if no exception is generated.
End Sub
End Class
End Namespace
[C#]
using System.EnterpriseServices;
using System.Runtime.CompilerServices;
using System.Reflection;

// Supply the COM+ application name.
[assembly: ApplicationName("BankComponent")]
// Supply a strong-named assembly.
[assembly: AssemblyKeyFileAttribute("BankComponent.snk")]

namespace BankComponent
{
[Transaction(TransactionOption.Required)]
public class Account : ServicedComponent
{
[AutoComplete]
public bool Post(int accountNum, double amount)
{
/* Updates the database; no need to call SetComplete.
Calls SetComplete automatically if no exception is
generated. */
return false;
}
}
}
BankComponent 客户端

[Visual Basic]
Imports BankComponent
Public Class Client
Shared Sub Main()
Dim Account As New Account()
' Post money into the account.
Account.Post(5, 100)
End Sub
End Class
[C#]
using BankComponent;
namespace BankComponentConsoleClient
{
class Client
{
public static int Main()
{
Account act = new Account();
// Post money into the account.
act.Post(5, 100);
return 0;
}
}
}
hero7750 2009-08-24
  • 打赏
  • 举报
回复
你添加Com引用的时候提示什么?

62,072

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧