Bug 33411 - Crash: could not resolve field token 0x040000c2
Summary: Crash: could not resolve field token 0x040000c2
Status: NEW
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: 4.0.0
Hardware: All Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-08-27 01:10 UTC by Christian Stewart
Modified: 2015-10-26 06:42 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 33411 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Christian Stewart 2015-08-27 01:10:06 UTC
All,

My code works and runs fine on Windows. It also seems to have run fine on Mono until recently - not sure what changed, even using older commits from the history does not fix this issue.

I've tried re-creating the entire solution using Visual Studio 2015 RC, however it seems to have no effect.

When trying to load my "Any CPU" class library, in "Any CPU" or "x86" or "x64" platforms, I receive the following error:

Unhandled Exception:
System.BadImageFormatException: Could not resolve field token 0x040000c2
File name: 'WLNetwork'
  at WLNetworkRuntime.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.BadImageFormatException: Could not resolve field token 0x040000c2
File name: 'WLNetwork'
  at WLNetworkRuntime.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

I've been unable to find a fix for this for months now (see http://stackoverflow.com/questions/31310686/badimageformatexception-could-not-resolve-field-token). There is no documentation - as far as I can find - that describes this error.

I've filed a bug because of 2 reasons:
 - If this is a bug, it's a breaking one
 - If it isn't a bug, there should be documentation describing the problem and how to fix it.

.. and also because I'm desperate to find a fix at this point.

Thank you.
Comment 1 Jo Shields 2015-08-27 02:24:05 UTC
Is this on an RPM-based distribution?
Comment 3 Christian Stewart 2015-08-27 14:03:41 UTC
Another similar error:

Can't find custom attr constructor image: Path/To/MyAssembly.dll mtoken: 0x0a00037c
* Assertion at class.c:283, condition `!mono_loader_get_last_error ()' not met

Stacktrace:

  at <unknown> <0xffffffff>
  at WLNetworkRuntime.Program.Main (string[]) <0x0000b>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        mono() [0x4b23ac]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x10d10) [0x7f847a488d10]
        /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7f847a0e3267]
        /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7f847a0e4eca]
        mono() [0x629839]
        mono() [0x629a47]
        mono() [0x629b96]
        mono(mono_class_from_typeref_checked+0x109) [0x51dd89]
        mono() [0x51c975]
        mono() [0x560191]
        mono() [0x56050a]
        mono(mono_metadata_parse_mh_full+0x235) [0x560945]
        mono() [0x43e0da]
        mono() [0x42b0df]
        mono() [0x42c89f]
        mono() [0x42d29b]
        mono() [0x4b4961]
        [0x40d7a166]

Debug info from gdb:

Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No threads.

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

[1]    20331 abort (core dumped)  mono MyProcess.exe

Really annoying, any ideas? Using some NuGet packages as well.

This happens on Debian for me. Using latest and/or pinned to version 4.0.0. Tested in docker containers as well as with monodevelop and xcode in both debug and release configs.
Comment 4 Jo Shields 2015-08-27 14:46:36 UTC
is libmono-windowsbase4.0-cil installed?
Comment 5 Christian Stewart 2015-08-27 15:01:01 UTC
Yes.
Comment 6 Christian Stewart 2015-08-28 12:55:43 UTC
Is there anything else you think I could try or test to get this working? It's a huge roadblock for me right now, I can't run anything on Linux anymore.
Comment 7 marxin.liska 2015-10-26 06:42:15 UTC
Hello.

I see very similar problem with mono-nuget:

https://github.com/directhex/xamarin-nuget

Unhandled Exception:
System.BadImageFormatException: Could not resolve field token 0x04000105
File name: 'NuGet.Core'
  at NuGet.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.BadImageFormatException: Could not resolve field token 0x04000105
File name: 'NuGet.Core'
  at NuGet.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

Any ideas how to hunt the problem?
Thanks,
Martin