我写了一个COM+组件的程序,并编译生成DLL文件.注册之后在其他程序进行添加引用时出现如下错误:未能添加对"Operation"的引用,将类型库转换为.NET程序集失败.类型库是从CLR程序集导出的,无法将其作为CLR程序集重新导入."Operation" 是我写的DLL文件名.这是怎么回事,请各位帮帮忙啊.谢谢!!

解决方案 »

  1.   

    .net类作为com+,是需要一定条件的例如从System.EnterpriseServices.ServicedComponent 继承等等,给你个地址吧ms-help://MS.MSDNQTR.2003FEB.2052/vbcon/html/vbwlkWalkthroughCreatingTransactionalQueueWithCOMServices.htm
      

  2.   

    有啊,下面是我写的COM+的代码.编译过是成功的.using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.EnterpriseServices;namespace Operation
    {
    //需要新的事物处理
    [Transaction(TransactionOption.RequiresNew)]
    //支持对象池,对象池的最小数量为5,最大为100
    [ObjectPooling(true,5,100)]
    //支持即时激活
    [JustInTimeActivation(true)]
    /// <summary>
    /// Class1 的摘要说明。
    /// </summary>
    public class Operation:System.EnterpriseServices.ServicedComponent
    {
    private SqlConnection m_cnn=null; public Operation()
    {
    string strCnn="server=DB;database=pubs;integrated security=sspi";
    m_cnn=new SqlConnection(strCnn);
    try
    {
    m_cnn.Open();
    }
    catch(Exception Ex)
    { }
    } [AutoComplete]
    public SqlDataReader GetDataReader()
    {
    SqlCommand l_cmmCommand=new SqlCommand("SELECT * FROM pubs",m_cnn);
    SqlDataReader rd=l_cmmCommand.ExecuteReader();
    return rd;
    }
    }
    }