1. Create a Assembly file using following:
File >> New >> Project >> Class Library >> Name = MyLibCSharp
2. Add a function HelloWorld. Code will look as follows:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace MyLibCsharp
{
[Guid("FE1EB79E-3513-487e-ADFF-2B61C6CB4730")]
[ComVisible(true)]
public class Class1
{
public String HelloWorld(String name)
{
return (“Hellow World; Welcome “ + name);
}
}
}
3. Sign the Assembly (To enable it to be used by multiple Applications):
Go to Project >> MyLibCSharp Properties >> Signing >> Sign the Assembly >> New >> Key.snk
4. Enable for COM Interop:
Go to Project >> MyLibCSharp Properties >> Build >> Output >> Check the “Register for COM interop.
5. Build the Assembly.
6. Add to GAC using “Visual Studio Command Prompt” the assembly is located in DEBUG/RELEASE folder.
gacutil -I MyLibCSharp.dll
7. Execute the following:
Regasm /tlb /codebase MyLibCSharp.dll
8. ASP code:
<%
Dim foo
set foo = Server.CreateObject(“MyLibCSharp.Class1″)
Response.Write (foo.HelloWorld(“test”))
%>
9. To unregister the assembly
Regasm /unregister MyLibCSharp.dll
10. And to remove the same from GAC (Global assembly cache)
Go to
C:\WINDOWS\assembly
find the assembly you want to remove
select it , right click it and select uninstall
Bye
RSS - Posts

Can you help me please?
I am getting the following error:
erver object, ASP 0177 (0×800401F3)
Invalid class string
/com/index.asp, line 10
Marcos de Sousa
By: Marcos de Sousa on March 5, 2008
at 11:08 am
Are you able to debug the dll you create in this example?
By: Luke on July 30, 2008
at 3:25 pm
Hi,
This is excellent help.
Still a question…Is it necessary to put a assembly in GAC?
By: Sagar on December 18, 2008
at 9:33 am
The example works fine, Thanks
By: Pablo on February 12, 2009
at 7:42 pm
This doesn’t appear to work in Vista Business. I get a :
Microsoft VBScript runtime error ‘800a01ad’
ActiveX component can’t create object
depends.exe suggests that this is because gpsvc.dll can’t be loaded, but there appears to be no more information on this anywhere. Any help greatly appreciated.
By: Anonymous on May 5, 2009
at 10:07 am
This doesn’t appear to work in Vista Business. I get a :
Microsoft VBScript runtime error ‘800a01ad’
ActiveX component can’t create object
depends.exe suggests that this is because gpsvc.dll can’t be loaded, but there appears to be no more information on this anywhere. Any help greatly appreciated.
By: Craig Mason-Jones on May 5, 2009
at 10:08 am