简体   繁体   English

经典ASP,Cookie和VB.NET COM +对象

[英]Classic ASP, Cookies, and VB.NET COM+ objects

This is tangled. 这很纠结。

I've been handed a web site written in classic ASP, with a lot of behind the scenes stuff done in VB6 COM+ objects called from the ASP pages via Server.ObjectCreate() instantiations. 我已经得到了一个用经典ASP编写的网站,其中很多幕后工作都是通过Server.ObjectCreate()实例化从ASP页调用的VB6 COM +对象完成的。 For this incarnation, the VB6 routines have been converted to VB.NET simply by running the Visual Studio 2003 converter tool on them, and then upgrading that solution file to VS 2008. So there's a thousand and one possible sources for error. 为此,只需在它们上运行Visual Studio 2003转换器工具,然后将解决方案文件升级到VS 2008,即可将VB6例程转换为VB.NET。因此,有千一百种可能的错误源。

One of the VB6 Modules that is giving me trouble clears a bunch of Response cookies by lines of the following form: 给我带来麻烦的VB6模块之一通过以下形式的行清除了一堆Response Cookie:

ASPResponse.Cookies("SysUserCode") = ""

Where ASPResponse is defined as : 其中ASPResponse定义为:

Private ASPResponse As ASPTypeLibrary.Response

And was set up on Object Activation by: 并通过以下方式设置了对象激活功能:

Set ASPResponse = objContext("Response")

In the VB.NET conversion of this module, those lines became 在此模块的VB.NET转换中,这些行变为

ASPResponse = ContextUtil.GetNamedProperty("Response")

and

ASPResponse.Cookies("SysUserCode")() = ""

(note the extra pair of parentheses. Not being much of a VB person, I'm not real sure what that syntax means.) (请注意额外的一对括号。由于不是VB人士,我不确定该语法的含义。)

Okay, here's the question: When this code executes on MY machine, that line is giving a VB error 13, with the Error.Description being "Specified cast is not valid." 好的,这是一个问题:当此代码在我的计算机上执行时,该行给出了VB错误13,其中Error.Description为“指定的强制转换无效”。 Huh? ?? What cast? 什么演员?

Incidentally, this module runs fine on a co-workers machine, and he cannot see any difference in the configuration of my machine and the relevant components from his. 顺便说一句,该模块在同事机器上运行良好,他看不到我的机器和相关组件的配置有任何差异。

I'm totally at a loss here. 我完全不知所措。 Googling it has given me a bunch of stuff on VB.NET cookies, or COM components with VB.NET, but nothing related to classic ASP cookies. 谷歌搜索它给了我很多关于VB.NET cookie或带有VB.NET的COM组件的信息,但是与经典ASP cookie没有任何关系。

Is... 是...

Private ASPResponse As ASPTypeLibrary.Response
Set ASPResponse = objContext("Response") 

... Post VB.NET conversion? ... 发布 VB.NET转换? If so, you'll need to explicitly cast objContext("Response") into the ASPTypeLibrary.Response object. 如果是这样,则需要将objContext("Response")显式转换为ASPTypeLibrary.Response对象。 This especially applies if Option Strict is on. 如果启用Option Strict则尤其适用。 eg 例如

ASPResponse = CType(objContext("Response"), ASPTypeLibary.Response)

Also, Set and Let statements aren't supported in VB.NET. 另外,VB.NET不支持SetLet语句。

This MAY have to do with the way the COM component's host is activated. 这可能与激活COM组件的主机有关。 I read another post ([Klaus H. Probst]) 1 that indicated that, in order to access the Response element, the COM component had to be activated as a Library (as opposed to Server) so that it was running in the ASP process space. 我读了另一篇文章([Klaus H. Probst]) 1 ,该文章指出,为了访问Response元素,必须将COM组件激活为库(与Server相对),以便它在ASP进程中运行空间。 So I tried changing the Activation type of the Component's hosting application to library, resetting and rebuilding a few times, and now I'm able to access the Cookies element of the Response. 因此,我尝试将组件的宿主应用程序的激活类型更改为库,并进行了几次重置和重建,现在,我可以访问响应的Cookies元素了。 However, my co-worker is still running the host application as a Server, and has no problem. 但是,我的同事仍将主机应用程序作为服务器运行,并且没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM