Skip to content

Commit

Permalink
Add an error dialog when in memory metadata cannot be loaded (refs #249)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Oct 12, 2023
1 parent 02fb851 commit 213b0dc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ bool GoToCore(DbgLoadModuleReference moduleRef, ReadOnlyCollection<object> optio
loadOptions |= DbgLoadModuleOptions.ForceMemory;
bool canShowMessageBox = true;
var md = LoadModule(moduleRef.Module, loadOptions, ref canShowMessageBox);
if (md is null)
if (md is null) {
if (canShowMessageBox)
messageBoxService.Value.Show(dnSpy_Debugger_DotNet_Resources.FailedToObtainValidInMemoryMetadataForModule);
return false;
}

// The file could've been added lazily to the list so add a short delay before we select it
bool newTab = options.Any(a => StringComparer.Ordinal.Equals(PredefinedReferenceNavigatorOptions.NewTab, a));
Expand All @@ -73,8 +76,10 @@ bool GoToCore(DbgLoadModuleReference moduleRef, ReadOnlyCollection<object> optio
}

ModuleDef? LoadModule(DbgModule module, DbgLoadModuleOptions options, ref bool canShowMessageBox) {
if (!module.IsDotNetModule())
if (!module.IsDotNetModule()) {
canShowMessageBox = false;
return null;
}

if (module.IsDynamic && !module.Runtime.IsClosed && module.Process.IsRunning) {
if (canShowMessageBox) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -141,6 +141,9 @@
<data name="DecompilerGeneratedVariablesCanNotBeEvaluated" xml:space="preserve">
<value>Decompiler generated variables can't be evaluated</value>
</data>
<data name="FailedToObtainValidInMemoryMetadataForModule" xml:space="preserve">
<value>Failed to obtain valid in-memory metadata for module!</value>
</data>
<data name="GlyphToolTip_IL_offset_0" xml:space="preserve">
<value>IL offset {0}</value>
</data>
Expand Down Expand Up @@ -186,4 +189,4 @@
<data name="UnknownVariableOrObjectId" xml:space="preserve">
<value>Unknown variable or object ID</value>
</data>
</root>
</root>

0 comments on commit 213b0dc

Please sign in to comment.