Bug 12669 - The 'ExeConfigFilename' argument cannot be null
Summary: The 'ExeConfigFilename' argument cannot be null
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Configuration ()
Version: unspecified
Hardware: All Other
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks: 51261
  Show dependency tree
 
Reported: 2013-06-13 05:18 UTC by Tim Matthews
Modified: 2017-01-06 08:42 UTC (History)
3 users (show)

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


Attachments
New function to set base dir and config file (592 bytes, patch)
2013-06-29 07:39 UTC, Tim Matthews
Details
New function to set base dir and config file (526 bytes, patch)
2013-06-29 07:40 UTC, Tim Matthews
Details


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:
Status:
RESOLVED FIXED

Description Tim Matthews 2013-06-13 05:18:11 UTC
I noticed a bug that was introduced in Mono 3 for embedding mono:

#include <glib.h>
#include <mono/jit/jit.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/object.h>

#include <stdio.h>

int
main (int argc, char* argv[]) {
    MonoDomain *domain;
    MonoImage *image;
  MonoAssemblyName *assemName;
  MonoAssembly *assem;
  MonoMethodDesc* desc;
  MonoMethod* method;
   
  mono_config_parse(NULL);
    domain = mono_jit_init (argv [0]);

  assemName = mono_assembly_name_new("System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089");
  assem = mono_assembly_load(assemName, NULL, NULL);
  image = mono_assembly_get_image(assem);
  desc = mono_method_desc_new("System.Windows.Forms.Application:EnableVisualStyles()", 1);
  method = mono_method_desc_search_in_image(desc, image);

  printf("About to crash\n");

  mono_runtime_invoke(method, NULL, NULL, NULL);  //crash

    mono_jit_cleanup (domain);
    return 0;
}




Produces the following output:

% ./a.out  
About to crash

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Net.Sockets.Socket ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.ArgumentException: The 'ExeConfigFilename' argument cannot be null.
  at System.Configuration.ExeConfigurationHost.CheckFileMap (ConfigurationUserLevel level, System.Configuration.ExeConfigurationFileMap map) [0x00000] in <filename unknown>:0
  at System.Configuration.ExeConfigurationHost.InitForConfiguration (System.String& locationSubPath, System.String& configPath, System.String& locationConfigPath, IInternalConfigRoot root, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
  at System.Configuration.InternalConfigurationSystem.InitForConfiguration (System.String& locationConfigPath, System.String& parentConfigPath, System.String& parentLocationConfigPath) [0x00000] in <filename unknown>:0
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
  at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
  at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00000] in <filename unknown>:0
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <filename unknown>:0
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0
  at System.Net.Sockets.Socket.CheckProtocolSupport () [0x00000] in <filename unknown>:0
  at System.Net.Sockets.Socket..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) [0x00000] in <filename unknown>:0
  at System.Windows.Forms.XplatUIX11..ctor () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.XplatUIX11.GetInstance () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.XplatUI..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Application.EnableVisualStyles () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Net.Sockets.Socket ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.ArgumentException: The 'ExeConfigFilename' argument cannot be null.
  at System.Configuration.ExeConfigurationHost.CheckFileMap (ConfigurationUserLevel level, System.Configuration.ExeConfigurationFileMap map) [0x00000] in <filename unknown>:0
  at System.Configuration.ExeConfigurationHost.InitForConfiguration (System.String& locationSubPath, System.String& configPath, System.String& locationConfigPath, IInternalConfigRoot root, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
  at System.Configuration.InternalConfigurationSystem.InitForConfiguration (System.String& locationConfigPath, System.String& parentConfigPath, System.String& parentLocationConfigPath) [0x00000] in <filename unknown>:0
  at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
  at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
  at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00000] in <filename unknown>:0
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <filename unknown>:0
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0
  at System.Net.Sockets.Socket.CheckProtocolSupport () [0x00000] in <filename unknown>:0
  at System.Net.Sockets.Socket..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) [0x00000] in <filename unknown>:0
  at System.Windows.Forms.XplatUIX11..ctor () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.XplatUIX11.GetInstance () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.XplatUI..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Application.EnableVisualStyles () [0x00000] in <filename unknown>:0
Comment 1 Tim Matthews 2013-06-29 07:39:07 UTC
Created attachment 4233 [details]
New function to set base dir and config file

Proposed new function to set base directory and config file name
Comment 2 Tim Matthews 2013-06-29 07:40:59 UTC
Created attachment 4234 [details]
New function to set base dir and config file

Proposed new function to set base directory and config file name
Comment 3 Tim Matthews 2015-01-15 05:02:46 UTC
This appears to have been fixed in https://github.com/mono/mono/commit/57f5187ad29a7913f083a659ea77d90eb8bad4d4. That references bug https://bugzilla.xamarin.com/show_bug.cgi?id=10468