[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Daryl Davis

6/11/2004 2:10:00 AM

Can I get a sample on how to call a com+ componant in a webservice, please?
This is what I have so far and I am getting an error
Run-time exception thrown : System.NullReferenceException - Object reference
not set to an instance of an object.

Imports System.Web.Services

Imports System.Runtime.InteropServices

<WebMethod()> _

Public Function GetRegKey() As String

Dim obj As Object

obj = CreateObject("hallconfigs.clsconfigs", "192.168.10.1")

Return obj.GetRegKey

End Function


4 Answers

Stuart Hemming (via DFN-CIS NetNews Service)

6/11/2004 9:59:00 AM

0

On 11/06/2004, around 08:55, Daryl Davis wrote:=20

DD> Can I get a sample on how to call a com+ componant in a webservice, ple=
ase?
Forgive me if I sound blunt, but you're doing it wrong. If you have
MSDN on you machine go to Visual Studio .Net|Visual Basic and Visual
C#|Programming with Components|COM Interoperability. Failing that,
there's a tutorial starting at the page pointed to on the link below.

http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us...
ml/vcwlkCOMInteropPart1CClientTutorial.asp

--=20
Stuart
See headers for PGP Key.
He who laughs last thinks slowest!

Daryl Davis

6/11/2004 6:24:00 PM

0

Ok, so your as blunt as a rusty sword, go for a tree trunk.
I am searching through the msdn and I am unable to figure out (might just be
early) how to get this to work with a server components.
Daryl

"Stuart Hemming (via DFN-CIS NetNews Service)"
<shemming@estatecomputers.com> wrote in message
news:717182739.20040611085900@estatecomputers.com...
On 11/06/2004, around 08:55, Daryl Davis wrote:

DD> Can I get a sample on how to call a com+ componant in a webservice,
please?
Forgive me if I sound blunt, but you're doing it wrong. If you have
MSDN on you machine go to Visual Studio .Net|Visual Basic and Visual
C#|Programming with Components|COM Interoperability. Failing that,
there's a tutorial starting at the page pointed to on the link below.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkCOMInteropPart1CClientTu...

--
Stuart
See headers for PGP Key.
He who laughs last thinks slowest!


Stuart Hemming (via DFN-CIS NetNews Service)

6/14/2004 2:49:00 PM

0

On 11/06/2004, around 13:36, Daryl Davis wrote:=20

DD> Ok, so your as blunt as a rusty sword, go for a tree trunk.
DD> I am searching through the msdn and I am unable to figure out (might ju=
st be
DD> early) how to get this to work with a server components.
FWIW, here's what I did.

I'm developing on a machine that has the server components on it so
YMMV.

In you VS project right click on 'References' on the project explorer
and select 'Add Reference'. When the dialog box opens, select the
'COM' tab and pick the COM server you're after. Click 'OK'. When the
machine has finished clicking and wrrring you should have a reference
named for your COM server.

Add a 'using' clause you get the thing recognised in your code and
you're away. Here's a simple example of my code accessing a COM server
called ECS ...

public XmlDocument InputValidation(XmlDocument ChangedValues) {
XmlDocument xmlDoc =3D new XmlDocument();
Ecs.EcsApplicationClass thisEcs;

thisEcs.Define("ecs-process", "input-validation");
thisEcs.InputText =3D ChangedValues.OuterXml;
thisEcs.RunProcess();
=20
if (thisEcs.OutputText !=3D null && thisEcs.OutputText !=3D "") {
xmlDoc.LoadXml(thisEcs.OutputText);
// ...
}
return xmlDoc;
}
public void Logout() {
Ecs.EcsApplicationClass thisEcs;
if (Session["ecs"] !=3D null) {
thisEcs =3D (Ecs.EcsApplicationClass)Session["ecs"];
Marshal.ReleaseComObject(thisEcs);
Session.Clear();
}
}

EcsApplicationClass is the constructor if you like, Define, and
RunProcess are methods, InputText and OutputText are properties. Not
that in Logout you have to call Marshal.ReleaseComObject else the
object remains on the server.

I hope this helps.
=20
--=20
Stuart
See headers for PGP Key.
Once, in the Congo, I lost my corkscrew, and was forced to live on
nothing but food and water for days.

Daryl Davis

6/14/2004 7:44:00 PM

0

I wish it did. I can call Dlls fine, except from a WebService...
I tried imitating your code and that did not help me either.
Daryl
"Stuart Hemming (via DFN-CIS NetNews Service)"
<shemming@estatecomputers.com> wrote in message
news:1226961532.20040614134939@estatecomputers.com...
On 11/06/2004, around 13:36, Daryl Davis wrote:

DD> Ok, so your as blunt as a rusty sword, go for a tree trunk.
DD> I am searching through the msdn and I am unable to figure out (might
just be
DD> early) how to get this to work with a server components.
FWIW, here's what I did.

I'm developing on a machine that has the server components on it so
YMMV.

In you VS project right click on 'References' on the project explorer
and select 'Add Reference'. When the dialog box opens, select the
'COM' tab and pick the COM server you're after. Click 'OK'. When the
machine has finished clicking and wrrring you should have a reference
named for your COM server.

Add a 'using' clause you get the thing recognised in your code and
you're away. Here's a simple example of my code accessing a COM server
called ECS ...

public XmlDocument InputValidation(XmlDocument ChangedValues) {
XmlDocument xmlDoc = new XmlDocument();
Ecs.EcsApplicationClass thisEcs;

thisEcs.Define("ecs-process", "input-validation");
thisEcs.InputText = ChangedValues.OuterXml;
thisEcs.RunProcess();

if (thisEcs.OutputText != null && thisEcs.OutputText != "") {
xmlDoc.LoadXml(thisEcs.OutputText);
// ...
}
return xmlDoc;
}
public void Logout() {
Ecs.EcsApplicationClass thisEcs;
if (Session["ecs"] != null) {
thisEcs = (Ecs.EcsApplicationClass)Session["ecs"];
Marshal.ReleaseComObject(thisEcs);
Session.Clear();
}
}

EcsApplicationClass is the constructor if you like, Define, and
RunProcess are methods, InputText and OutputText are properties. Not
that in Logout you have to call Marshal.ReleaseComObject else the
object remains on the server.

I hope this helps.

--
Stuart
See headers for PGP Key.
Once, in the Congo, I lost my corkscrew, and was forced to live on
nothing but food and water for days.