未验证 提交 4490bcce 编写于 作者: A anatawa12 提交者: GitHub

Make ComHost.Create throw InvalidTypeLibraryException if type library is empty file (#90220)

上级 375fe76d
......@@ -11,7 +11,6 @@ namespace Microsoft.NET.HostModel.ComHost
{
public class ComHost
{
private const int E_INVALIDARG = unchecked((int)0x80070057);
// These need to match RESOURCEID_CLSIDMAP and RESOURCETYPE_CLSIDMAP defined in comhost.h.
private const int ClsidmapResourceId = 64;
private const int ClsidmapResourceType = 1024;
......@@ -61,16 +60,15 @@ public class ComHost
try
{
byte[] tlbFileBytes = File.ReadAllBytes(typeLibrary.Value);
if (tlbFileBytes.Length == 0)
throw new InvalidTypeLibraryException(typeLibrary.Value);
updater.AddResource(tlbFileBytes, "typelib", (IntPtr)typeLibrary.Key);
}
catch (FileNotFoundException ex)
{
throw new TypeLibraryDoesNotExistException(typeLibrary.Value, ex);
}
catch (HResultException hr) when (hr.Win32HResult == E_INVALIDARG)
{
throw new InvalidTypeLibraryException(typeLibrary.Value, hr);
}
}
}
updater.Update();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册