Menu

 

Saturday, March 7, 2009

Creating COM From Csharp and VB.net

Hi,

Recently I have Create COM Object Using Dotnet ...
Know I will Show U Step By Step How Create Com Object...

I am Using Vs2008 This can follwed in Vs2005,Vs2003
I will Create "Hello Word Kind of Project"

Let Start...

1} Create Simple Dll Project From Dotnet
















2} Know Writing Function To Show On
Classic Asp page
















3} Know Creating Class COM Object
COM Visible
















4}Know Creating Strong Key
Name For COM















5} Know Adding Strong Key
To Dll

















6} Know Adding Your Dll For
Classic Asp


Regasm \codebase is Command Used for Registering
Your Dll For Classic Asp















Once You Have Registered Your Dll Know Restart
Your IIS
(It is Reqirment for Refesing COM Object")

7) Know Adding Dll To GAC
















8} Know Adding Asp Code


set OInstr = Server.CreateObject("AspCom.HelloWorld")
str_msg = OInstr.strMYname("Avinash") Response.Write(str_msg)
'How to Acess Other Class Ib COM Object
str_msgMe = Ostr.MessageFromSecondClass("Avinash") Response.Write(str_msgMe)


9}Code OF Csharp Main Code :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AspCom
{
public class HelloWorld
{
public string strMYname(string strName)
{
string straMyname = "";

straMyname = "Hello World I Came From Csharp=" + strName;
return straMyname;
}
public string MessageFromSecondClass(string str_message)
{
string str_mess = "";
test testme = new test();
str_mess = testme.TestSecondClass(str_message);

return str_mess;
}
}
}

10} Test Class Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AspCom
{
class test
{
public string TestSecondClass(string strMsg)
{
string strName = "";
strName = "Hello I am From Second Class" + strMsg;
return strName;
}
}
}



11} Know UnRegistrating The Dll
















12} Know Unstialling From GacUtil















<
14} How To Acess The Database In Com..
If Looop Data in Recordset Then pass in form of XML...
U want Insert,Update or Delete Data From database
U have Pass Parameter as U passwed Hello world Project
and create Login of Add Modif Or delete as U do normally in
Dotnet.
Page..
Pass The parameter and Manuplate as U want..

Hope It Help Some Body



No comments:

Post a Comment

All Menu