title: Can only read/write 21 chars to InstallShield property from VB.NET
body: <p>I'm using <strong>VB.NET</strong> and a <strong>custom action</strong> from within <strong>InstallShield</strong> to update some properties during an install.</p>
  
  <p>Everything works as long as I don't try to read or write more than 21 characters into the property, in which case it crashes.</p>
  
  <p>Just to be clear, if I enter this string "123456789112345678921" into the property via IS, then try to read it from VB.NET, everything works. If I add another char and read that, it crashes.
  Writing is similar - if I write (from VB.NET) the first string above it works. If I add another char it fails.</p>
  
  <p>My suspicion is that I have the MsiSetProperty and MsiGetProperty defined incorrectly:</p>
  
  <pre class="lang-vb prettyprint-override"><code>&lt;DllImport(MSI_LIB, EntryPoint:="MsiSetProperty", CharSet:=CharSet.Auto)&gt; _
  Public Shared Function MsiSetProperty(hInstall As IntPtr, name As String, value As String) As UInteger
  End Function
  </code></pre>
  
  <pre class="lang-vb prettyprint-override"><code>&lt;DllImport(MSI_LIB, EntryPoint:="MsiGetProperty", CharSet:=CharSet.Auto)&gt; _
  Private Shared Function MsiGetProperty_Core(hInstall As IntPtr, szName As String, &lt;Out&gt; szValueBuf As StringBuilder, ByRef pchValueBuf As Integer) As Integer
  End Function
  </code></pre>
  
  <pre class="lang-vb prettyprint-override"><code>Public Shared Function MSIGetProperty(hMSI As IntPtr, PropertyName As String) As String
   Try
    Dim MSIProp As New StringBuilder()
    Dim stringSize As Integer = 256
    Dim value As Integer = MsiGetProperty_Core(hMSI, PropertyName, MSIProp, stringSize)
    Return MSIProp.ToString()
   Catch
    Return "-1"
   End Try
  End Function
  </code></pre>
  
  <p>This is how i'm accessing the fields:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Public Property ReportServerURL As String
    Get
      Return MSIFunctions.MSIGetProperty(_msiHandle, "REPORTSERVERURL")
     End Get
     Set(value As String)
      MSIFunctions.MsiSetProperty(_msiHandle, "REPORTSERVERURL", value)
     End Set
  End Property
  </code></pre>
  
  <p>Any ideas on what's going on?</p>