开发者

Strings can not be read in global.asa

开发者 https://www.devze.com 2023-01-26 01:42 出处:网络
I have an ActiveX control that runs inside global.asa within IIS. The control has some BSTR properties, but in server\'s VBScript they appear to be somehow malformed, as if VBScript does not understan

I have an ActiveX control that runs inside global.asa within IIS. The control has some BSTR properties, but in server's VBScript they appear to be somehow malformed, as if VBScript does not understand they are strings. It is possible to retreive the string property, as well as assign it to another variable, but it's not possible to concatenate two strings. The result can be described as undefined, but is actually the first argument of concatenation. The same code ran fine in earlier version of IIS, but not anymore on Windows Server 2008 2003. What's going on, and how to fix it?

EDIT: The thing that I see is so simple, yet so mysterious. I probably don't look at the right place. In global.asa this is the code:

Dim resultString
resutString = MyControl.String1 & MyControl.String2

Any other workaround does not work too, like first assigning stri开发者_如何学Gongs to temp variables, or wrapping strings into CStr(). In ATL project this is the code (some sample bits):

[id(16), helpstring("property String1")] BSTR String1;
[id(17), helpstring("property String2")] BSTR String2;
...
DISP_PROPERTY_EX_ID(CMyControl, "String1", dispidString1, GetString1, SetString1, VT_BSTR)
DISP_PROPERTY_EX_ID(CMyControl, "String2", dispidString2, GetString2, SetString2, VT_BSTR)
...
BSTR CMyControl::GetString1(void)
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());

   CString strResult;
   ...
   return strResult.AllocSysString();
}


As Rico mentioned in one of the comments, there is a typo that may have just been a copy/paste error when posting the question, but still bears looking at:

Dim resultString
resutString = MyControl.String1 & MyControl.String2

You are copying the strings to a misspelled variable... it may be as simple as that.

If that doesn't fix the issue, you may want to try forcibly converting the values to strings like:

resultString = cStr(MyControl.String1) & cStr(MyControl.String2)

Or

resultString = cStr(MyControl.String1 & MyControl.String2)

The merits of either one can be discussed elsewhere, I don't know that you will see a perceptible performance difference between the two. That's another question for once it is working.

0

精彩评论

暂无评论...
验证码 换一张
取 消