[Mono-dev] NullReferenceException when trying to use socket with embedded mono2

Mrak konstantink at epsystems.lt
Wed Oct 8 03:09:03 EDT 2008


Hello,

I'm using mono in embedded mode, and currently trying to upgrade runtime to
version 2.0. However have a strange problem. When trying to use TCP sockets
i'm getting the following exception:

System.Configuration.ConfigurationErrorsException: Error Initializing the
configuration system. ---> System.NullReferenceException: Object reference
not set to an instance of an object
  at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal
(ConfigurationUserLevel userLevel, System.Reflection.Assembly
calling_assembly, System.String exePath) [0x00000] 
  at System.Configuration.ClientConfigurationSystem.get_Configuration ()
[0x00000] 
  --- End of inner exception stack trace ---
  at System.Configuration.ClientConfigurationSystem.get_Configuration ()
[0x00000] 
  at
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection
(System.String configKey) [0x00000] 
  at System.Configuration.ConfigurationManager.GetSection (System.String
sectionName) [0x00000] 
  at System.Net.Sockets.Socket.CheckProtocolSupport () [0x00000] 
  at System.Net.Sockets.Socket..cctor () [0x00000] 

I've explored some source code and figured out that in this code
(ConfigurationManager.cs starting from line 96):

				if (exePath == null || exePath.Length == 0) {
					if (!systemWebInUse && calling_assembly != null)
					        exePath = calling_assembly.Location;
					else
						exePath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
					map.ExeConfigFilename = exePath.EndsWith (".config") ? exePath :
exePath + ".config";

Both calling_assembly and
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile are null so
exePath.EndsWith(".config") fails with NullReferenceException

I've checked, in embedded mode Assembly.GetEntryAssembly() returns null, so
naturally calling_assembly here is null.

Is it a bug or "feature" and how can I overcome it?

Thank you very much in advance,

-- 
Konstantin Koryashev
-- 
View this message in context: http://www.nabble.com/NullReferenceException-when-trying-to-use-socket-with-embedded-mono2-tp19873451p19873451.html
Sent from the Mono - Dev mailing list archive at Nabble.com.



More information about the Mono-devel-list mailing list