本文整理汇总了C#中IImageStream.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# IImageStream.Dispose方法的具体用法?C# IImageStream.Dispose怎么用?C# IImageStream.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IImageStream
的用法示例。
在下文中一共展示了IImageStream.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// Creates a new <see cref="ISymbolReader"/> instance
/// </summary>
/// <param name="pdbStream">PDB file stream which is now owned by this method</param>
/// <returns>A new <see cref="ISymbolReader"/> instance or <c>null</c>.</returns>
public static ISymbolReader Create(IImageStream pdbStream) {
if (pdbStream == null)
return null;
try {
var pdbReader = new PdbReader();
pdbReader.Read(pdbStream);
return pdbReader;
}
catch (IOException) {
}
catch (UnauthorizedAccessException) {
}
catch (SecurityException) {
}
finally {
if (pdbStream != null)
pdbStream.Dispose();
}
return null;
}
示例2: Create
/// <summary>
/// Creates a new <see cref="ISymbolReader"/> instance
/// </summary>
/// <param name="mdStream">.NET metadata stream which is now owned by this method</param>
/// <param name="pdbStream">PDB file stream which is now owned by this method</param>
/// <returns>A new <see cref="ISymbolReader"/> instance or <c>null</c> if any of the COM
/// methods fail.</returns>
public static ISymbolReader Create(IImageStream mdStream, IImageStream pdbStream) {
ImageStreamIStream stream = null;
PinnedMetaData pinnedMd = null;
bool error = true;
try {
if (pdbStream == null || mdStream == null)
return null;
object mdDispObj;
Guid CLSID_CorMetaDataDispenser = new Guid(0xE5CB7A31, 0x7512, 0x11D2, 0x89, 0xCE, 0x0, 0x80, 0xC7, 0x92, 0xE5, 0xD8);
Guid IID_IMetaDataDispenser = new Guid(0x809C652E, 0x7396, 0x11D2, 0x97, 0x71, 0x00, 0xA0, 0xC9, 0xB4, 0xD5, 0x0C);
int hr = CoCreateInstance(ref CLSID_CorMetaDataDispenser, IntPtr.Zero, 1, ref IID_IMetaDataDispenser, out mdDispObj);
if (hr < 0)
return null;
object mdImportObj;
var mdDisp = (IMetaDataDispenser)mdDispObj;
Guid IID_IMetaDataImport = new Guid(0x7DAC8207, 0xD3AE, 0x4C75, 0x9B, 0x67, 0x92, 0x80, 0x1A, 0x49, 0x7D, 0x44);
pinnedMd = new PinnedMetaData(mdStream);
mdDisp.OpenScopeOnMemory(pinnedMd.Address, (uint)pinnedMd.Size, 0x10, ref IID_IMetaDataImport, out mdImportObj);
Marshal.FinalReleaseComObject(mdDispObj);
ISymUnmanagedReader symReader;
var binder = (ISymUnmanagedBinder)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_CorSymBinder_SxS));
stream = new ImageStreamIStream(pdbStream, null) { UserData = pinnedMd };
hr = binder.GetReaderFromStream((IMetaDataImport)mdImportObj, stream, out symReader);
Marshal.FinalReleaseComObject(mdImportObj);
Marshal.FinalReleaseComObject(binder);
if (hr >= 0) {
error = false;
return new SymbolReader(symReader);
}
}
catch (IOException) {
}
catch (InvalidCastException) {
}
catch (COMException) {
}
finally {
if (error) {
if (stream != null)
stream.Dispose();
if (pinnedMd != null)
pinnedMd.Dispose();
if (mdStream != null)
mdStream.Dispose();
if (pdbStream != null)
pdbStream.Dispose();
}
}
return null;
}
示例3: Create
/// <summary>
/// Creates a new <see cref="ISymbolReader"/> instance
/// </summary>
/// <param name="pdbImpl">PDB implementation to use</param>
/// <param name="metaData">.NET metadata. Only need to be non-null if MS COM API should be used</param>
/// <param name="pdbStream">PDB file stream which is now owned by us</param>
/// <returns>A new <see cref="ISymbolReader"/> instance or <c>null</c> if it's not possible
/// to create a <see cref="ISymbolReader"/>.</returns>
public static ISymbolReader Create(PdbImplType pdbImpl, IMetaData metaData, IImageStream pdbStream) {
switch (pdbImpl) {
case PdbImplType.MicrosoftCOM:
return Dss.SymbolReaderCreator.Create(metaData, pdbStream);
case PdbImplType.Managed:
return Managed.SymbolReaderCreator.Create(pdbStream);
default:
if (pdbStream != null)
pdbStream.Dispose();
throw new InvalidOperationException();
}
}