有个什么工具吧。可以把com转换成net的组件偶忘记叫什么名字了。

解决方案 »

  1.   

    com组件是需要通过注册之后才能用的
      

  2.   

    请引用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;
                }
          }
    }
      

  3.   

    WinForm地方程序可以配置在 "应用程序名".config应用程序配置文件的名称和位置取决于应用程序的宿主,可以是下列情况之一: 可执行文件承载的应用程序。 
    由可执行文件宿主承载的应用程序的配置文件与该应用程序位于同一目录。配置文件的名称是带有 .config 扩展名的该应用程序的名称。例如,名为 myApp.exe 的应用程序可以与名为 myApp.exe.config 的配置文件关联。 ASP.NET 承载的应用程序。 
    ASP.NET 配置文件叫做 Web.config。ASP.NET 应用程序中的配置文件继承该 URL 路径中的配置文件的设置。例如,假设有 URL www.microsoft.com/aaa/bbb,其中 www.microsoft.com/aaa 是 Web 应用程序,与该应用程序关联的配置文件位于 www.microsoft.com/aaa。位于子目录 /bbb 中的 ASP.NET 页,既使用应用程序级的配置文件的设置,又使用位于 /bbb 中的配置文件的设置。 有关 ASP.NET 配置文件的更多信息,请参阅 ASP.NET 配置 Internet Explorer 承载的应用程序。 
    如果 Internet Explorer 承载的应用程序有配置文件,那么该文件的位置在 <link> 标记中指定,其语法如下: <link rel="ConfigurationFileName" href="location"> 在该标记中,location 是指向该配置文件的 URL。它设置了应用程序基。配置文件必须位于与应用程序所在的同一 Web 站点中。 请你好好看看MSDN:
    ms-help://MS.VSCC/MS.MSDNVS.2052/cpguide/html/cpconconfiguringnetframeworkapplications.htm
    谁说"Soapsuds 都需要建立web service",还是请你好好看看MSDN:
    ms-help://MS.VSCC/MS.MSDNVS.2052/cptools/html/cpgrfsoapsudsutilitysoapsudsexe.htm
      

  4.   

    想要动态调用,可以通过Reflection 实现
    通过 System.Reflection.Assembly.LoadFrom 可以得到一个 System.Reflection.Assembly的object A ,再通过该GetType() ,可以得到某个Class 的 type ,然后调用A的CreateInstance方法创建对象
    string DllName = "x.dll";
    string ClassName = "MySample.Test";System.Reflection.Assembly dllFile
    try
    {
      dllFile = System.Reflection.Assembly.LoadFrom(DllName);
    }
    catch(System.IO.FileNotFoundException ec)
    {
        return false;
    }
    System.Type theType = dllFile.GetType(ClassName);
    if(theType != null)
    {
    System.Object obj = dllFile.CreateInstance(theType.FullName);
    }
     else
    {
         return false;
    }
      

  5.   

    不好意思,各位写的我都不太明白,可能是我没有说清楚,我现在还没有到使用组件的那一步。目前我还处在开发客户端程序的第一步(为了方便使用,我需要将我写的COM+的引用加入我的工程),但就是在将它加入工的工程时提示了我所说的那个错误。我现在是想问:为什么我不能通过使用COM的形式增加引用,但我后来试了一下,我可以通过.Net的形式加入(切到.Net页面,然后Browse,选择那个文件)。
      

  6.   

    在.net 下面创建组件 这个组件写成COM+ 就能引用 否则不行
      

  7.   

    用TlbImp 把你的COM+ dll 封装成 .NET dll 
    在客户端引用那个封装的dll
      

  8.   

    我的组件本来就是使用.Net创建的,所以应该不需要再使用TlbImp了吧
      

  9.   

    搂主你真的很笨:第一步: regsvr32 -i xxx.dll 来注册你的 DLL
    第二步:Add Reference,点击 COM 标签,在列表框找到你注册的 DLL 的标题,确定。
      

  10.   

    谢谢大家的参与,这个问题我已基本搞定了:
    To FJGoodGood(_FJ_强中强):可能是我初学.NET的原因,我不知道怎样使用regsvr32 -i来注册我的dll,如果我使用regsvr32来注册,它会提示我找不到DllRegisterServer入口,而我发现只能使用regsvcs来注册我的dll,这样注册后在组件服务管理器里能看到我的组件,但现在如果要加入组件的引用则会出现我前面说的问题。
    我的方法是这样的(不一定是正确的,但可以使用):不注册组件,直接在Add Reference对话框中,使用Browse功能,然后选中我的那个dll,这样就可以了。