mono fails with FileNotFoundException: Could not load file or assembly 'System, Version=2.0.0.0

500 views
Skip to first unread message

the_fiddler

unread,
Jul 8, 2014, 10:08:57 AM7/8/14
to native-cli...@googlegroups.com
Hello everyone,

I am trying out mono under nacl. The sample projects work, but they fail as soon as I modify them to use types that don't exist in mscorlib.dll.

For example, adding the following (bolded) line to the hello_world sample causes a failure:

static void Main()
{
    System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.ConsoleTraceListener());
}

System.Diagnostics.Trace is a type that resides in System.dll, which exists under my naclmono installation (~/nacl/naclmono_31/lib/mono/2.0). However, the application fails with:

DEBUG_POSTMESSAGE: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. File name: 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

I am launching the nexe using the following command:

NACL_DEBUG_ENABLE=1 PPAPI_BROWSER_DEBUG=1 NACL_PLUGIN_DEBUG=1 NACL_PPAPI_PROXY_DEBUG=1 NACL_EXE_STDOUT=DEBUG_ONLY:dev://postmessage NACL_EXE_STDERR=DEBUG_ONLY:dev://postmessage open -a "/Applications/Google Chrome.app" http://localhost:8080/hello_world/hello_world.html

Any ideas what I am doing wrong? What is the correct way to load assemblies for nacl mono applications?

Elijah Taylor

unread,
Jul 14, 2014, 1:47:49 PM7/14/14
to native-cli...@googlegroups.com
Hi,


On Tue, Jul 8, 2014 at 7:08 AM, the_fiddler <stap...@gmail.com> wrote:
 
Any ideas what I am doing wrong? 

If you're just modifying the naclmono_samples, then System.dll is not being loaded up.  mscorlib.dll is loaded for each sample, and then a corresponding .exe is loaded for the specific sample.  This exe loading is done through a Javascript postmessage to the plugin, and the actual loading is handled through utility functions in mono_helpers.c.

> What is the correct way to load assemblies for nacl mono applications

There's not necessarily a "correct" way to load assemblies, but the way I did it for these samples is to load the assembly via the URLLoader interface, read all the data from the file, then load the assembly from memory via the mono API.  This is not very elegant, but it works, and doesn't require additional dependencies to create the appearance of a filesystem.  The downside is that you have to manually load all of the dependent assemblies your code needs ahead of time.

-Elijah

Stefanos A.

unread,
Jul 15, 2014, 10:54:05 AM7/15/14
to native-cli...@googlegroups.com

Thanks for your answer.

That was one of the things I tried, actually:

    load_assembly("System.dll""System.dll");
    // which is equivalent to:
    load_file_from_url(
"System.dll", load_assembly_from_memory, strdup("System.dll"));
    load_file_from_url("mscorlib.dll", finish_mono_initialization, domain_copy);

But I am still getting the same error.

I haven't had much luck looking for documentation on this, but it may be that I am looking in the wrong place. The most relevant document I found was the Embedding Mono page, which appears to be using a somewhat different interface ("mono_domain_assembly_open()").

I made sure that System.dll is copied into the application directory. Is this the correct approach? there something else I need to do?

Elijah Taylor

unread,
Jul 15, 2014, 1:28:18 PM7/15/14
to native-cli...@googlegroups.com
On Tue, Jul 15, 2014 at 7:53 AM, Stefanos A. <stap...@gmail.com> wrote:

That was one of the things I tried, actually:

    load_assembly("System.dll""System.dll");
    // which is equivalent to:
    load_file_from_url(
"System.dll", load_assembly_from_memory, strdup("System.dll"));
    load_file_from_url("mscorlib.dll", finish_mono_initialization, domain_copy);

But I am still getting the same error.

Is it definitely the same error, that it can't find the System assembly?
 

I haven't had much luck looking for documentation on this, but it may be that I am looking in the wrong place. The most relevant document I found was the Embedding Mono page, which appears to be using a somewhat different interface ("mono_domain_assembly_open()").

Yeah, I think the functions I had to use are somewhat undocumented, but part of the API mono exports for embedding.
 

I made sure that System.dll is copied into the application directory. Is this the correct approach? there something else I need to do? 

I'm not sure if there is good error handling on URL loading, you might check the network tab (or the HTTP server logs) to make sure that System.dll is being loaded correctly.   There may also be ordering issues with loading System.dll before mscorlib.dll.

Stefanos A.

unread,
Jul 15, 2014, 3:55:33 PM7/15/14
to native-cli...@googlegroups.com
I made sure that System.dll is copied into the application directory. Is this the correct approach? there something else I need to do? 

I'm not sure if there is good error handling on URL loading, you might check the network tab (or the HTTP server logs) to make sure that System.dll is being loaded correctly.   There may also be ordering issues with loading System.dll before mscorlib.dll.

Cheers, the network tab showed that Chrome had cached a previous version of System.dll and was trying to load that. (This does not generally work, as you need mscorlib and System must come from the same version/release of mono, in this case from the nacl version.)

The second issue was that mscorlib has to be loaded first.

Fixing those issues removes the DllNotFoundException I was getting before. Of course, things are never that simple - in its place I am getting a different error now:

DEBUG_POSTMESSAGE:* Assertion at /mnt/data/b/build/slave/linux-sdk-mono64/build/src/native_client_sdk/src/build_tools/mono_build/nacl-mono-x86-32/mono/metadata/domain.c:1381, condition `mono_defaults.object_class != 0' not met

Google does not return anything relevant on this message... Any ideas?

Joe Dluzen

unread,
Jul 16, 2014, 8:53:37 AM7/16/14
to native-cli...@googlegroups.com
DEBUG_POSTMESSAGE:* Assertion at /mnt/data/b/build/slave/linux-sdk-mono64/build/src/native_client_sdk/src/build_tools/mono_build/nacl-mono-x86-32/mono/metadata/domain.c:1381, condition `mono_defaults.object_class != 0' not met
I had to dive in to the code, but it seems that it can't load System.Object.

Elijah Taylor

unread,
Jul 16, 2014, 2:23:06 PM7/16/14
to native-cli...@googlegroups.com
I tried adding your line of code from the first message to reproduce, but I didn't get the error you got.  I needed to add System.dll and System.Configuration.dll (I added them to the HTML/JS loading path, I'm not sure how you added them, but if you tried to just add a line after the loading of mscorlib that is going to be racey because the loads happen asynchronously).  Modified handleMessage:

  handleMessage = function(message) {
    if (message.data === 'Mono Initialized') {
      document.getElementById('status').innerHTML = 'Mono initialized, no assembly loaded';
      plugin.postMessage('loadAssembly System.dll');
    } else if (message.data === 'Loaded Assembly /System.dll') {
      document.getElementById('status').innerHTML = 'Mono initialized, System.dll loaded';
      plugin.postMessage('loadAssembly System.Configuration.dll');
    } else if (message.data === 'Loaded Assembly /System.Configuration.dll') {
      document.getElementById('status').innerHTML = 'Mono initialized, System.Configuration.dll loaded';
      plugin.postMessage('loadAssembly hw.exe');
    } else if (message.data === 'Loaded Assembly /hw.exe') {
      document.getElementById('status').innerHTML = 'Mono initialized, hw.exe loaded';
      plugin.postMessage('executeAssembly hw');
    } else {
      document.getElementById('output').innerHTML += message.data + '<br>';
    }
  }


Then I get this error:


Unhandled Exception:
System.TypeLoadException: A type load exception has occurred.
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationSettings.GetConfig (System.String sectionName) [0x00000] in <filename unknown>:0 
  at System.Diagnostics.DiagnosticsConfiguration.get_Settings () [0x00000] in <filename unknown>:0 
  at System.Diagnostics.TraceImpl.InitOnce () [0x00000] in <filename unknown>:0 
  at System.Diagnostics.TraceImpl.get_Listeners () [0x00000] in <filename unknown>:0 
  at System.Diagnostics.Trace.get_Listeners () [0x00000] in <filename unknown>:0 
  at HelloWorld.Main (System.String[] args) [0x00000] in <filename unknown>:0



I am not familiar enough with C#/.NET to know what this means, but it may be necessary for some config files to be made available, or the environment needs to be configured properly and embedded mono by default (or by default in NaCl) doesn't have this.

 


Google does not return anything relevant on this message... Any ideas?

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to native-client-di...@googlegroups.com.
To post to this group, send email to native-cli...@googlegroups.com.
Visit this group at http://groups.google.com/group/native-client-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages