.net and COM and server.createobject

Status
Not open for further replies.

kingshaka_1977

Wise, Aged Ars Veteran
102
Hi,

I am implementing a COM component using .net for a few outdated components for a server migration task.

The old component was used to receive an image path on the current server, convert it to a jpeg and save the converted image in the same path.

This is trivial to do in .net, however my main problem is obtaining the server context. I am not sure how to do either one of the following: 1. saving the image to the same path that the original image was retrieved from 2. or sending the image directly to the response stream (avoiding the need to save the converted image)

The component is being called within a class ASP page (yes, unfortunately!) using: Server.CreateObject("Component.Class")

Is there anyway in the implementing .net code that i can obtain a reference to the "server" object that created the component? I was hoping that if I could obtain a reference to the server, I could then obtain the appropriate context to write back to the response stream.

Any help would be greatly appreciated.
 

kingshaka_1977

Wise, Aged Ars Veteran
102
I have worked this out, obtaining a few clues for the internet and google. Thought I should post this in case anyone else has the same problem.

Obtaining the server context was a matter of including the following references:


  • 1. COMSVCLib (should already be in your COM section when adding references to your project)

    2. ASPTypeLibrary: Look for: "Microsoft Active Server Pages Object Library". If you don't see this immediately in your COM section, then you will need to add this from "windows programs and features". Add the following feature: Internet Information Services -> WWW Services -> ASP

Working out the above was the hardest thing :) After that, its very simple to reference your server and other intrinsic ASP objects:

Code:
COMSVCSLib.AppServer aspServer = new COMSVCSLib.AppServer();
COMSVCSLib.ObjectContextoc = aspServer.GetObjectContext();
ASPTypeLibrary.Server server = (ASPTypeLibrary.Server)oc["Server"];

You can do the same with with other ASP objects such as Request and Response.
 

Fristie Blade

Ars Tribunus Militum
1,722
Subscriptor++
[url=http:/civis/viewtopic.php?p=31994003#p31994003:37kbbhdr said:
kingshaka_1977[/url]":37kbbhdr]I have worked this out, obtaining a few clues for the internet and google. Thought I should post this in case anyone else has the same problem.

Obtaining the server context was a matter of including the following references:


  • 1. COMSVCLib (should already be in your COM section when adding references to your project)

    2. ASPTypeLibrary: Look for: "Microsoft Active Server Pages Object Library". If you don't see this immediately in your COM section, then you will need to add this from "windows programs and features". Add the following feature: Internet Information Services -> WWW Services -> ASP

Working out the above was the hardest thing :) After that, its very simple to reference your server and other intrinsic ASP objects:

Code:
COMSVCSLib.AppServer aspServer = new COMSVCSLib.AppServer();
COMSVCSLib.ObjectContextoc = aspServer.GetObjectContext();
ASPTypeLibrary.Server server = (ASPTypeLibrary.Server)oc["Server"];

You can do the same with with other ASP objects such as Request and Response.

ASPTypeLibrary, now that has been a long time since I saw that one.
That's from the time it wasn't obsolete yet, COM programming was still the correct thing to do and when I had this thing for running server side javascript inside a classic ASP environment.
Oh memory lane ...
 

kingshaka_1977

Wise, Aged Ars Veteran
102
[url=http:/civis/viewtopic.php?p=32037687#p32037687:2w6m7s1b said:
Fristie Blade[/url]":2w6m7s1b]
[url=http:/civis/viewtopic.php?p=31994003#p31994003:2w6m7s1b said:
kingshaka_1977[/url]":2w6m7s1b]I have worked this out, obtaining a few clues for the internet and google. Thought I should post this in case anyone else has the same problem.

Obtaining the server context was a matter of including the following references:


  • 1. COMSVCLib (should already be in your COM section when adding references to your project)

    2. ASPTypeLibrary: Look for: "Microsoft Active Server Pages Object Library". If you don't see this immediately in your COM section, then you will need to add this from "windows programs and features". Add the following feature: Internet Information Services -> WWW Services -> ASP

Working out the above was the hardest thing :) After that, its very simple to reference your server and other intrinsic ASP objects:

Code:
COMSVCSLib.AppServer aspServer = new COMSVCSLib.AppServer();
COMSVCSLib.ObjectContextoc = aspServer.GetObjectContext();
ASPTypeLibrary.Server server = (ASPTypeLibrary.Server)oc["Server"];

You can do the same with with other ASP objects such as Request and Response.

ASPTypeLibrary, now that has been a long time since I saw that one.
That's from the time it wasn't obsolete yet, COM programming was still the correct thing to do and when I had this thing for running server side javascript inside a classic ASP environment.
Oh memory lane ...

Yes, brought back memories but I'm not sure if they were good! :) You are right though, at the time it was the "right way to go". Pain did come though, when I started to work on the classic ASP pages that were calling this component... need to convince the customer to move along now... :)
 
Status
Not open for further replies.