This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Possible Bug with Strings?
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 05, 2008
10:23 PM
Possible Bug with Strings?
Hey there,
Try this out, let me know how it works for you.
InstallScript MSI Project
Create a List, within the list add several string values with different lengths on a dialog.
Example:
Administrator
Guest
Within the code behind I add a call to C#. I pass the strings on by and evaluate the data. If I picked "Administrator" first, I get these results:
Administrator - With the length of 1024 because it is padded with nulls.
That is fine, I account for it. I made a method which replaces \0 with string.Empty. After I strip it, I get these results:
Administrator - As the length of 13. Good it works.
Back to the dialog, now choose Guest. Pass that value over and you get the following data.
Guest - With the length of 1024 because it is padded with nulls.
After I strip it of nulls, I get this result:
Guestistrator
It happens on EVERY CASE. Meaning, the longest string seems to be always present while any shorter string gets appended to the difference of any string that was chosen previously.
This has to be a bug.
I am doing nothing but a simple Systems.Windows.Forms.MessageBox.Show(InstallShieldData) in C#. Nothing is customized.
As a temporary solution, I created a different method to strip nulls from InstallShield. I use a substring from the start to the first instance of a null, I pull the string I want out.
It works.
Or maybe I'm doing something wrong. Any insight would be great!
Edit:
private string TrimNulls(string s)
{
if(s == null)
{
return string.Empty;
}
if(s.IndexOf("\0") != -1)
{
return s.Substring(0, s.IndexOf("\0"));
}
else { return s; }
}
Try this out, let me know how it works for you.
InstallScript MSI Project
Create a List, within the list add several string values with different lengths on a dialog.
Example:
Administrator
Guest
Within the code behind I add a call to C#. I pass the strings on by and evaluate the data. If I picked "Administrator" first, I get these results:
Administrator - With the length of 1024 because it is padded with nulls.
That is fine, I account for it. I made a method which replaces \0 with string.Empty. After I strip it, I get these results:
Administrator - As the length of 13. Good it works.
Back to the dialog, now choose Guest. Pass that value over and you get the following data.
Guest - With the length of 1024 because it is padded with nulls.
After I strip it of nulls, I get this result:
Guestistrator
It happens on EVERY CASE. Meaning, the longest string seems to be always present while any shorter string gets appended to the difference of any string that was chosen previously.
This has to be a bug.
I am doing nothing but a simple Systems.Windows.Forms.MessageBox.Show(InstallShieldData) in C#. Nothing is customized.
As a temporary solution, I created a different method to strip nulls from InstallShield. I use a substring from the start to the first instance of a null, I pull the string I want out.
It works.
Or maybe I'm doing something wrong. Any insight would be great!
Edit:
private string TrimNulls(string s)
{
if(s == null)
{
return string.Empty;
}
if(s.IndexOf("\0") != -1)
{
return s.Substring(0, s.IndexOf("\0"));
}
else { return s; }
}
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 06, 2008
10:02 AM
How are you passing the strings to your DLLs? It sounds like they are being treated as character arrays instead of properly sized strings.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 06, 2008
10:33 AM
STRING svUserName;
Object InstallerClass;
set InstallerClass = CoCreateObjectDotNet(SUPPORTDIR ^ "Installation.dll", "Installation.Wrapper" );
[Dialog Loop]
case TextBoxControlID:
CtrlGetText(DialogName, TextBoxControlID, svUserName)
InstallerClass.SaveUserName(svUserName);
[Dialog Loop End]
=============================
C#
namespace Installation
{
class Wrapper
{
private string m_Username = string.Empty;
public void SaveUserName(string Username)
{
// Default value from InstallShield
MessageBox.Show(Username);
// Value from InstallShield after trimming Nulls.
Username = Username.Replace("\0", string.Empty);
MessageBox.Show(Username);
m_Username = Username;
}
}
}
Nothing complex here.
Object InstallerClass;
set InstallerClass = CoCreateObjectDotNet(SUPPORTDIR ^ "Installation.dll", "Installation.Wrapper" );
[Dialog Loop]
case TextBoxControlID:
CtrlGetText(DialogName, TextBoxControlID, svUserName)
InstallerClass.SaveUserName(svUserName);
[Dialog Loop End]
=============================
C#
namespace Installation
{
class Wrapper
{
private string m_Username = string.Empty;
public void SaveUserName(string Username)
{
// Default value from InstallShield
MessageBox.Show(Username);
// Value from InstallShield after trimming Nulls.
Username = Username.Replace("\0", string.Empty);
MessageBox.Show(Username);
m_Username = Username;
}
}
}
Nothing complex here.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 06, 2008
10:34 AM
Also as a note, I have successfully replicated this issue in Combo Boxes, and Text Boxes.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 08, 2008
02:55 PM
Any InstallShield QA's or Devs have anything further on this?