提交 3abd28ce 编写于 作者: P Paul Harrington

Use CreateStreamOnHGlobal instead of SHCreateStream

SHCreateStream isn't available on server OS
上级 91cb21d1
......@@ -55,8 +55,15 @@ internal sealed class PdbWriter : IDisposable
private uint[] _sequencePointEndLines;
private uint[] _sequencePointEndColumns;
[DllImport("shlwapi.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
private extern static IStream SHCreateMemStream([In] IntPtr pInit, [In] uint cbInit);
[DllImport("Ole32", ExactSpelling = true)]
private static extern int CreateStreamOnHGlobal(IntPtr hGlobal, bool fDeleteOnRelease, out IStream stream);
private static IStream CreateNativeStream()
{
IStream stream = null;
Marshal.ThrowExceptionForHR(CreateStreamOnHGlobal(IntPtr.Zero, fDeleteOnRelease: true, stream: out stream));
return stream;
}
public PdbWriter(string fileName, Func<object> symWriterFactory = null)
{
......@@ -600,7 +607,7 @@ public void SetMetadataEmitter(MetadataWriter metadataWriter)
// and the resulting PDB has Age = existing_age + 1.
// PERF: Use a native stream for the write and copy it at the end. This reduces the total GC
// allocations for the COM interop and geometric growth of the underlying managed stream.
_nativeStream = SHCreateMemStream(IntPtr.Zero, 0u);
_nativeStream = CreateNativeStream();
instance.Initialize(new PdbMetadataWrapper(metadataWriter), _fileName, _nativeStream, fullBuild: true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册