cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

String Passed from DotNetCoCreateObject Results in Large Number of Nulls

String Passed from DotNetCoCreateObject Results in Large Number of Nulls

Summary

When using DotNetCoCreateObject, string values passed are padded by a large number of nulls.

Synopsis

Strings passed using DotNetCoCreateObject results in a large number (up to a buffer of 1024 characters) of nulls.

Discussion

The InstallScript engine stores the strings as BSTRs and uses them directly when calling COM methods (either a COM object or a .NET assembly that was loaded with the DotNetCoCreateObject function), as the data is language independent. As BSTRs can contain any number of nulls, the BSTRs will retain them. In situations where a large number of nulls follow a string, the empty values are stored as nulls.

The TrimEnd method can be added to the .NET code to remove the excess nulls from the string value.
FilePath = <FilePath>.TrimEnd('\0');

Additional Information

Additional information on the TrimEnd Method can be found here.
Was this article helpful? Yes No
No ratings
Version history
Revision #:
1 of 1
Last update:
‎Jul 19, 2018 04:41 PM
Updated by: