Introduction :
In my articles How to Use/Access/Invoke/Perform Active X Controls in Asp.Net/C# Application
How to Use/Invoke/Access COM Components Using Asp.Net/RCW(Runtime Callable Wrapper),i explained how to use COM components in asp.net application.In this article,i am going to explain about
how to use asp.net components into COM client.
Main:
We easily exposed COM types using RCW,but Only a few features of .NET assemblies are not accessible via COM,
including parameterized constructors,static methods, and constant fields. Additionally, accessing overloaded
.NET methods from COM requires a little work.
To ensure that a COM client can use your .NET component, there are some requirements on your .NET classes:
1.Here Classes must be public, with a default public constructor
2.Here Since only public types are exported to the type library, consequently, only methods, properties,
and so on, that are public will be visible to COM
Without a default public constructor, it may still be possible for a COM client to create the object by
some other means,
for ex,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GetString1
{
public class WelComeString
{
public string welcomestring()
{
return "I am asp.net Component";
}
}
}
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GetString1 { public class WelComeString { public string welcomestring() { return "I am asp.net Component"; } } } |
now we created a .Net Component,
Next we need to register this Component into system registry using regasm.exe tool,so the COM runtime can easily
access this .net component,
Now we registered the .net component into system registry,
Here i created one sample COM client for accessing .Net Component,
Testing.vbs
Option Explicit
Dim objWelcomeString
Dim lngResult
Set objString=CreateObject("GetString1.WelComeString")
lngResult=objString.WelComeString()
Call MsgBox(lngResult)
Option Explicit Dim objWelcomeString Dim lngResult Set objString=CreateObject("GetString1.WelComeString") lngResult=objString.WelComeString() Call MsgBox(lngResult) |
Conclusion:
Hope this helps,
Happy Coding.

This is a great post, I stumbled across your article while looking for lyrics. Thanks for sharing, I’ll be sure to return regularly.