[英]Server.CreateObject + Server Context + COM :-)
I am implementing a COM component using .net for a few outdated components for a server migration task.我正在使用 .net 为服务器迁移任务的一些过时组件实现 COM 组件。
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.旧组件用于接收当前服务器上的图像路径,将其转换为 jpeg 并将转换后的图像保存在同一路径中。
This is trivial to do in .net, however my main problem is obtaining the server context.这在 .net 中很简单,但是我的主要问题是获取服务器上下文。 I am not sure how to do either one of the following:
我不确定如何执行以下任一操作:
The component is being called within a class ASP page (yes, unfortunately!) using:该组件在类 ASP 页面中被调用(是的,不幸的是!)使用:
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?无论如何,在实现 .net 代码中,我可以获得对创建组件的
Server
对象的引用吗? 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.我希望如果我能获得对服务器的引用,我就能获得适当的上下文来写回响应流。
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:获取服务器上下文是包含以下参考的问题:
Working out the above was the hardest thing :-) After that, its very simple to reference your server and other intrinsic ASP objects:解决上述问题是最困难的事情:-) 在那之后,引用您的服务器和其他内部 ASP 对象非常简单:
COMSVCSLib.AppServer aspServer = new COMSVCSLib.AppServer();
COMSVCSLib.ObjectContext oc = aspServer.GetObjectContext();
ASPTypeLibrary.Server server = (ASPTypeLibrary.Server)oc["Server"];
You can do the same with with other ASP objects such as Request and Response.您可以对其他 ASP 对象(例如请求和响应)执行相同操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.