Marshaling callback to native dll
<p>I am working with callback going from unmanged native library to my managed C# code.
Callback function is declared in header file:</p>

<pre><code>typedef void* (TNotice)(wchar_t *msg, bool error);
</code></pre>

<p>Callback has string parameter msg.I don't khow, why doesn't work declaration in c#:</p>

<pre><code>[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr CallbackDelegate([MarshalAs(UnmanagedType.LPWStr)]string msg, bool error);
</code></pre>

<p>but declaration:</p>

<pre><code>[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr CallbackDelegate([MarshalAs(UnmanagedType.LPWStr)]StringBuilder msg, bool error);
</code></pre>

<p>works fine.</p>
