FIX: BSTR Passed to Method is Truncated at Double NULL When Marshalled in COM+ (277660)
The information in this article applies to:
- Microsoft COM+ 1.0, when used with:
- the operating system: Microsoft Windows 2000
This article was previously published under Q277660 SYMPTOMS
When using a BSTR to hold binary data, if the BSTR is passed into or out of a configured COM+ component, the string is truncated at the first occurrence of a double NULL byte sequence (that is, a single Unicode NULL character).
This problem only occurs when the method is called across contexts (that is, when marshalling the BSTR), and only in components that are configured for COM+ and Microsoft Transaction Server (MTS). The same code works in a non-configured Component Object Model (COM) and Distributed Component Object Model (DCOM) application.
RESOLUTIONTo resolve this problem, obtain the latest service pack for Windows 2000. For additional information, click the following article number to view the article in the
Microsoft Knowledge Base:
260910 How to Obtain the Latest Windows 2000 Service Pack
If you are a developer who is building components that take BSTR arguments that contain binary data, you might consider one of the following alternatives to work around this issue:
- Arguments passed by reference (that is, BSTR* pbstr, or sVal as String) are not affected and can be used to pass the data instead of by value (BSTR bstr, or ByVal sVal As String).
- Use a binary array (SAFEARRAY of type VT_UI1) or an IStream* to pass the binary data.
- Encode the binary data so that it does not have two NULL bytes in mid-stream (for example, use Base64 encoding). Then decode the string to convert it back to the native binary. This solution requires extra work by both sender and receiver.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Windows 2000 Service Pack 2.
Modification Type: | Major | Last Reviewed: | 5/28/2003 |
---|
Keywords: | kbAutomation kbbug kbfix kbWin2000PreSP2Fix KB277660 |
---|
|