在vbscritp 中调用 C#生成的dll 组件

环境:vs2005,window XP 

第一步:
  添加一个类库组件,添加cs文件,代码如下:
   using System;
   using System.Collections.Generic;
   using System.Text;

   namespace AspDll
   {
       public class firstDll
       {
           public firstDll()
           { }
           public int Contulation(int a,int b)
           {
                  return a + b; 
           }
           public string returnHello(string name)
           {
               return "Hello" + name;
           }
       }
   }

第二步:
   打开类文件所在项目属性页,选择"生成"标签,把"为COM Interop 注册"勾上.
第三步:
    把AssemblyInfo.cs文件中的[assembly: ComVisible(false)] 改为[assembly: ComVisible(true)]

第四步:编译生成.dll
第五步:在Asp调用:
   set clsa=server.CreateObject("AspDll.firstDll")
        three=clsa.returnHello("china")
    response.Write("<script>alert('"&three&"')</script>")

<完>

原文地址:https://www.cnblogs.com/subingster/p/839144.html