I started receiving this error after I added some code to my App.xaml.cs file.
After some searching I found some outdated info. Basically this is a timing issue. I inserted this code in my App.xaml.cs file:
1: SFA.SLApplication.Proxies.DataServiceClient dataSvc = new SFA.SLApplication.Proxies.DataServiceClient();
2:
3: public App()
4: {
5: this.Startup += this.Application_Startup;
6: this.Exit += this.Application_Exit;
7: this.UnhandledException += this.Application_UnhandledException;
8:
9: InitializeComponent();
10: }
11:
12: private void Application_Startup(object sender, StartupEventArgs e)
13: {
14: this.RootVisual = new MainPage();
15:
16: dataSvc.GetUsersAllCompleted += new EventHandler<SFA.SLApplication.Proxies.GetUsersAllCompletedEventArgs>(dataSvc_GetUsersAllCompleted);
17: dataSvc.GetUsersAllAsync();
18: }
So the problem is with line #1. This line is trying to read from the ServiceReferences.config file that can not be read at that point in the Silverlight application’s lifecycle. Changing the code like this works:
1: SFA.SLApplication.Proxies.DataServiceClient dataSvc = null;
2:
3: public App()
4: {
5: this.Startup += this.Application_Startup;
6: this.Exit += this.Application_Exit;
7: this.UnhandledException += this.Application_UnhandledException;
8:
9: InitializeComponent();
10: }
11:
12: private void Application_Startup(object sender, StartupEventArgs e)
13: {
14: this.RootVisual = new MainPage();
15:
16: dataSvc = new SFA.SLApplication.Proxies.DataServiceClient();
17:
18: dataSvc.GetUsersAllCompleted += new EventHandler<SFA.SLApplication.Proxies.GetUsersAllCompletedEventArgs>(dataSvc_GetUsersAllCompleted);
19: dataSvc.GetUsersAllAsync();
20: }
Hope this helps someone ;)
Full error below:
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E; InfoPath.3)
Timestamp: Tue, 8 Dec 2009 18:19:34 UTC
Message: Unhandled Error in Silverlight 3 Application
Code: 4004
Category: ManagedRuntimeError
Message: System.InvalidOperationException: Cannot find 'ServiceReferences.ClientConfig' in the .xap application package. This file is used to configure client proxies for web services, and allows the application to locate the services it needs. Either include this file in the application package, or modify your code to use a client proxy constructor that specifies the service address and binding explicitly. Please see inner exception for details. ---> System.Xml.XmlException: Cannot open 'ServiceReferences.ClientConfig'. The Uri parameter must be a relative path pointing to content inside the Silverlight application's XAP package. If you need to load content from an arbitrary Uri, please see the documentation on Loading XML content using WebClient/HttpWebRequest. ---> System.ArgumentException: Application object is not initialized.
at System.Windows.Application.GetResourceStream(Uri uriResource)
at MS.Internal.JoltHelper.ApplicationResourceStreamResolver.GetApplicationResourceStream(Uri relativeUri)
at System.Xml.XmlXapResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
--- End of inner exception stack trace ---
at System.Xml.XmlXapResolver.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.ServiceModel.Configuration.ServiceModelSectionGroup.GetSectionGroup()
--- End of inner exception stack trace ---
at System.ServiceModel.Configuration.ServiceModelSectionGroup.GetSectionGroup()
at System.ServiceModel.Configuration.ServiceModelSectionGroup.get_Current()
at System.ServiceModel.Description.ConfigLoader.LookupChannel(String configurationName, String contractName, Boolean wildcard)
at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName)
at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
at System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase`1..ctor()
at SFA.SLApplication.Proxies.DataServiceClient..ctor()
at SFA_SLApplication.App..ctor()
Line: 56
Char: 13
Code: 0
URI: http://localhost:26140/SFA.SLApplicationSite/
d85b3dc0-e78c-4e27-9cb5-ceb3f833323c|2|5.0