Bug 11362 - Could not retrieve the vtable for type Foo in mono_field_get_value_object
Summary: Could not retrieve the vtable for type Foo in mono_field_get_value_object
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Rodrigo Kumpera
Depends on:
Reported: 2013-03-22 16:33 UTC by Andres G. Aragoneses
Modified: 2013-05-17 11:03 UTC (History)
4 users (show)

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

Testcase (140.00 KB, application/x-tgz)
2013-03-22 16:39 UTC, Andres G. Aragoneses

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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Andres G. Aragoneses 2013-03-22 16:33:57 UTC
When trying to get the value of a static FieldInfo from a type (Foo) loaded via Assembly.LoadFrom(), a null value is returned and this warning is printed in the console:

Could not retrieve the vtable for type Foo in mono_field_get_value_object

The code is more or less like this:

        var types = new List<Type> ();
        foreach (var file in dot_net_assemblies) {
            Assembly asm = Assembly.LoadFrom (file.FullName);
            types.AddRange (asm.GetTypes ());

        foreach (Type type in types) {
            foreach (FieldInfo field in type.GetFields (BindingFlags.Public | BindingFlags.Static)) {
                object schema = field.GetValue (null);

I will be attaching a testcase shortly.

(Feel free to switch product here from runtime to ClassLibraries, I just thought it may be related to the runtime because it mentions the "vtable"?)
Comment 1 Andres G. Aragoneses 2013-03-22 16:39:29 UTC
Created attachment 3682 [details]

This .tar.gz file contains the testcase.

The code that has the reflection usage is "GSettingsSchemaExtractor.cs", you can compile it or just use the "exe" called gsettings-schema-extractor.exe that is also in the package.

To run, use the script "run.sh".
Comment 2 Andres G. Aragoneses 2013-03-22 17:04:23 UTC
(Mono version: 3.0.8 (master/0d3d43f))
Comment 3 Zoltan Varga 2013-03-23 23:49:30 UTC
Could this be caused by a missing assembly ? Try running with MONO_LOG_LEVEL=debug.
Comment 4 Andres G. Aragoneses 2013-03-28 04:22:20 UTC
With that, I get:

Mono: The class Banshee.Configuration.Foo could not be loaded, used in Banshee.Core, Version=, Culture=neutral, PublicKeyToken=null

So I guess what should really happen is a TypeLoadException?
Comment 5 Rodrigo Kumpera 2013-05-16 23:32:02 UTC
Yes, it should raise an exception.
Comment 6 Rodrigo Kumpera 2013-05-17 11:03:42 UTC
Fixed on master.