[Mono-dev] HttpRuntime.Cache crashing HttpListener in console application
MemphisWeb
memphisweb at gmail.com
Wed Apr 1 23:41:06 EDT 2009
Done! Bug #491343
Gonzalo Paniagua Javier-5 wrote:
>
> Do you mind entering this information in https://bugzilla.novell.com ?
> Under "Mono::class libraries" - Sys.Web.
>
> Thanks!
>
> -Gonzalo
>
> On Wed, 2009-04-01 at 09:46 -0700, MemphisWeb wrote:
>> If I Cache data using System.Web.Caching in a console application I get
>> an
>> exception if I ltry to start a HttpListener object. It seems that
>> somewhere
>> in System.Net it is looking for Cache Settings in a web.config.
>>
>> This is a bug because the behavior does not exist in the .net runtime.
>>
>> Is there a workaround?
>>
>> ############################
>>
>> using System;
>> using System.Web;
>> using System.Web.Caching;
>> using System.Net;
>>
>> namespace TestWeb
>> {
>> class MainClass
>> {
>> public static void Main(string[] args)
>> {
>> /* Uncomment to section to produce error
>> *
>> Cache cache = HttpRuntime.Cache;
>> cache["hello"] = "world";
>> Console.WriteLine("Hello World!");
>>
>> Cache cacheClone = HttpRuntime.Cache;
>> string s = cacheClone["hello"] as String;
>> Console.Write(s);
>> */
>>
>> System.Net.HttpListener listener = new System.Net.HttpListener();
>> listener.Prefixes.Add("http://192.168.1.101:8081/");
>> listener.Start();
>>
>> Console.WriteLine(listener.IsListening);
>> }
>> }
>> }
>>
>> Hello World!
>> world
>> Unhandled Exception: System.TypeInitializationException: An exception was
>> thrown by the type initializer for System.Net.Sockets.Socket --->
>> System.NullReferenceException: Object reference not set to an instance of
>> an
>> object
>> at System.Web.Configuration.WebConfigurationManager.GetSectionCacheKey
>> (System.String sectionName, System.String path) [0x00000] in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs:487
>> at System.Web.Configuration.WebConfigurationManager.GetSection
>> (System.String sectionName, System.String path) [0x00000] in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs:313
>> at System.Web.Configuration.WebConfigurationManager.GetSection
>> (System.String sectionName) [0x00000] in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs:308
>> at
>> System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection
>> (System.String configKey) [0x00000] in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System.Web/System.Web/UplevelHelper.cs:1
>> at System.Configuration.ConfigurationManager.GetSection (System.String
>> sectionName) [0x00000] in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:162
>> at System.Net.Sockets.Socket.CheckProtocolSupport () [0x0003c] in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System/System.Net.Sockets/Socket.cs:1342
>> at System.Net.Sockets.Socket..cctor () [0x0000c] in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System/System.Net.Sockets/Socket.cs:601
>> --- End of inner exception stack trace ---
>> at System.Net.EndPointListener..ctor (System.Net.IPAddress addr, Int32
>> port, Boolean secure) [0x00028] in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System/System.Net/EndPointListener.cs:58
>> at System.Net.EndPointManager.GetEPListener (System.Net.IPAddress addr,
>> Int32 port, System.Net.HttpListener listener, Boolean secure) [0x00064]
>> in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System/System.Net/EndPointManager.cs:96
>> at System.Net.EndPointManager.AddPrefixInternal (System.String p,
>> System.Net.HttpListener listener) [0x00050] in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System/System.Net/EndPointManager.cs:78
>> at System.Net.EndPointManager.AddListener (System.Net.HttpListener
>> listener) [0x0002a] in
>> /usr/src/packages/BUILD/mono-2.4/mcs/class/System/System.Net/EndPointManager.cs:49
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
--
View this message in context: http://www.nabble.com/HttpRuntime.Cache-crashing-HttpListener-in-console-application-tp22830802p22840284.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
More information about the Mono-devel-list
mailing list