WebException was unhandled (Start Composite) without network

Topics: General
Apr 27, 2011 at 8:48 AM

Hi

Last weekend played around with C1 on a holiday without network and...

  Errors if network is absent. Opening C1 Console through: http://localhost:3984/Composite/default.aspx + Start Composite

	Website_v2.1\Composite\controls\ScriptLoaderControl.ascx.cs
	line=192 
	line_content: System.Threading.Tasks.Task task = System.Threading.Tasks.Task.Factory.StartNew(() => loaded = System.Xml.Linq.XDocument.Load(uri));

	Exception:

	System.Net.WebException was unhandled by user code
	  Message=The remote name could not be resolved: 'c1console.composite.net'
	  Source=System
	  StackTrace:
		   at System.Net.HttpWebRequest.GetResponse()
		   at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
		   at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
		   at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
		   at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
		   at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext)
		   at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings)
		   at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
		   at System.Xml.Linq.XDocument.Load(String uri)
		   at ScriptLoaderControl.<>c__DisplayClass1.<_HasServerToServerConnection>b__0() in d:\SRC\HolisticWare\HolisticWare_Web_CMS_C1\Website_v2.1\Composite\controls\ScriptLoaderControl.ascx.cs:line 192
		   at System.Threading.Tasks.Task`1.InvokeFuture(Object futureAsObj)
		   at System.Threading.Tasks.Task.InnerInvoke()
		   at System.Threading.Tasks.Task.Execute()
	  InnerException: 


	private bool _HasServerToServerConnection()
	{
		bool result = false;
		try
		{
			string uri = ConfigurationManager.AppSettings["Composite.StartPage.Url"];

			XDocument loaded = null;
		
			// Exception occurs in line below!!
			System.Threading.Tasks.Task task = System.Threading.Tasks.Task.Factory.StartNew(() => loaded = System.Xml.Linq.XDocument.Load(uri));

			task.Wait(2500);
			if (task.IsCompleted)
			{
				XElement titleElement = loaded.Descendants(Composite.Core.Xml.Namespaces.Xhtml + "title").FirstOrDefault();
				result = (titleElement != null && titleElement.Value == "Start");
			}
		}
		catch (Exception) { }
		return result;
	}

Regards 
mel
Coordinator
Apr 27, 2011 at 11:09 AM

Will be fixed soon. For now, you can edit

\Composite\controls\ScriptLoaderControl.ascx.cs

remove _HasServerToServerConnection() method, and add the following code instead:

 

 

    private static bool _HasServerToServerConnection()
    {
        bool result = false;
        try
        {
            string uri = ConfigurationManager.AppSettings["Composite.StartPage.Url"];

            XDocument loaded = null;
            System.Threading.Tasks.Task task = System.Threading.Tasks.Task.Factory.StartNew(() => loaded = TryLoad(uri));

            task.Wait(2500);
            if (task.IsCompleted && loaded != null)
            {
                XElement titleElement = loaded.Descendants(Composite.Core.Xml.Namespaces.Xhtml + "title").FirstOrDefault();
                result = (titleElement != null && titleElement.Value == "Start");
            }
        }
        catch (Exception) { }
        return result;
    }

    [System.Diagnostics.DebuggerStepThrough]
    private static XDocument TryLoad(string uri)
    {
        try
        {
            return XDocument.Load(uri);
        }
        catch
        {
            /* silent */
            return null;
        }
    }

 

 

The [DebuggerStepThrough] attribute should prevent Visual Studio from breaking execution on exception

Apr 29, 2011 at 12:19 PM

Hi

I stepped through debugger w/o problems. But wanted to inform You about this issue.

did small workaround with another catch and everything was fine. Currently cannot help You a lot, but at least this way.

 

regards

mel

Coordinator
Apr 29, 2011 at 1:50 PM

@moljac I really didn't consider the single step debugging scenario - sorry for closing down your bug reports so hard :) We look into if adding [DebuggerStepThrough] make good sense in the places you report - please don't stop spamming us ;-)