Put back Open key signing on the SOS.NETCore assembly. (dotnet/coreclr#6905)
authorMike McLaughlin <mikem@microsoft.com>
Thu, 25 Aug 2016 16:47:52 +0000 (09:47 -0700)
committerWes Haggard <weshaggard@users.noreply.github.com>
Thu, 25 Aug 2016 16:47:52 +0000 (09:47 -0700)
Fix failure in SOS if System.Reflection.Metadata is missing.

Commit migrated from https://github.com/dotnet/coreclr/commit/4f0fbd0cbb8606055b222300d68ecd2f44ee2ca4

src/coreclr/src/ToolBox/SOS/NETCore/SOS.NETCore.csproj
src/coreclr/src/ToolBox/SOS/NETCore/SymbolReader.cs

index e8e2b7e..bd9d239 100644 (file)
@@ -11,6 +11,7 @@
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <NoStdLib>true</NoStdLib>
     <NoCompilerStandardLib>true</NoCompilerStandardLib>
+    <UseOpenKey Condition="'$(UseOpenKey)'==''">true</UseOpenKey>
   </PropertyGroup>
 
   <!-- Default configurations to help VS understand the options -->
index c4c1dc8..bfd4c2b 100644 (file)
@@ -144,22 +144,29 @@ namespace SOS
         internal static IntPtr LoadSymbolsForModule(string assemblyPath, bool isFileLayout, IntPtr loadedPeAddress, int loadedPeSize, 
             IntPtr inMemoryPdbAddress, int inMemoryPdbSize, ReadMemoryDelegate readMemory)
         {
-            TargetStream peStream = null;
-            if (assemblyPath == null && loadedPeAddress != IntPtr.Zero)
+            try
             {
-                peStream = new TargetStream(loadedPeAddress, loadedPeSize, readMemory);
+                TargetStream peStream = null;
+                if (assemblyPath == null && loadedPeAddress != IntPtr.Zero)
+                {
+                    peStream = new TargetStream(loadedPeAddress, loadedPeSize, readMemory);
+                }
+                TargetStream pdbStream = null;
+                if (inMemoryPdbAddress != IntPtr.Zero)
+                {
+                    pdbStream = new TargetStream(inMemoryPdbAddress, inMemoryPdbSize, readMemory);
+                }
+                OpenedReader openedReader = GetReader(assemblyPath, isFileLayout, peStream, pdbStream);
+                if (openedReader != null)
+                {
+                    GCHandle gch = GCHandle.Alloc(openedReader);
+                    return GCHandle.ToIntPtr(gch);
+                }
             }
-            TargetStream pdbStream = null;
-            if (inMemoryPdbAddress != IntPtr.Zero)
+            catch
             {
-                pdbStream = new TargetStream(inMemoryPdbAddress, inMemoryPdbSize, readMemory);
             }
-            OpenedReader openedReader = GetReader(assemblyPath, isFileLayout, peStream, pdbStream);
-            if (openedReader == null)
-                return IntPtr.Zero;
-
-            GCHandle gch = GCHandle.Alloc(openedReader);
-            return GCHandle.ToIntPtr(gch);
+            return IntPtr.Zero;
         }
 
         /// <summary>
@@ -493,7 +500,7 @@ namespace SOS
                 provider = MetadataReaderProvider.FromPortablePdbStream(pdbStream);
                 result = new OpenedReader(provider, provider.GetMetadataReader());
             }
-            catch (BadImageFormatException)
+            catch (Exception e) when (e is BadImageFormatException || e is IOException)
             {
                 return null;
             }