https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=505636

I am developing a silverlight application that is using a WCF service in my local solution. When I right click on the service reference in the SL application and choose update or if I click configure a duplicate Endpoint and Bindings for the service in my ServiceReferences.ClientConfig file:
     <endpoint address="http://localhost:15153/AdminService.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IAdminService" contract="Proxy.AdminService.IAdminService"
        name="BasicHttpBinding_IAdminService" />
     <endpoint address="http://localhost:15153/AdminService.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IAdminService1" contract="Proxy.AdminService.IAdminService"
        name="BasicHttpBinding_IAdminService1" />

Posted by Microsoft on 11/16/2009 at 2:52 PM

Dear Customer,
Thanks for reporting the issue.
This issue has been resolved in the latest version of Visual Studio 2010.
Thanks!

Warning    7    Custom tool warning: No endpoints compatible with Silverlight 3 were found. The generated client class will not be usable unless endpoint information is provided via the constructor.    D:\Projects\VMR\AzureVMR\VMRSilverlight\Service References\Proxy.DataService\Reference.svcmap    1    1    VMRSilverlight

Visual Studio 2010 Beta 2 has been giving me some funky errors lately.  The errors occur out of the blue.  Updating the service references work find for a few days and then seemingly at random I start to get the error above.

I found a solution that has been working for me.

Reconfigure the service reference:

image

Check the box “Reuse types in referenced assemblies” and choose “Reuse types in specified referenced assemblies”  Choose only the Model assemblies that you share between the Silverlight App and your WCF Service.  Hit OK and you should be good to go!

I started receiving this error after I added some code to my App.xaml.cs file.

image

 

After some searching I found some outdated info.  Basically this is a timing issue.  I inserted this code in my App.xaml.cs file:


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:


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.ChannelFactory1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)

   at System.ServiceModel.ChannelFactory1..ctor(String endpointConfigurationName)

   at System.ServiceModel.EndpointTrait1.CreateSimplexFactory()

   at System.ServiceModel.EndpointTrait1.CreateChannelFactory()

   at System.ServiceModel.ClientBase1.CreateChannelFactoryRef(EndpointTrait1 endpointTrait)

   at System.ServiceModel.ClientBase1.InitializeChannelFactoryRef()

   at System.ServiceModel.ClientBase1..ctor()

   at SFA.SLApplication.Proxies.DataServiceClient..ctor()

   at SFA_SLApplication.App..ctor()    

Line: 56

Char: 13

Code: 0

URI: http://localhost:26140/SFA.SLApplicationSite/

Loading data into your Silverlight Line of Business application can take a second or two.  Sometimes it is necessary to pacify the user with a ‘Waiting’ or ‘Loading’ screen reminiscent of the AJAX Loading panels from days past in ASP.NET.

I Googled for some solutions and found some really bad code and over engineered solutions.  I like simplicity so here it is in a nutshell:

  1. Add a child window to your project.
  2. Remove the ‘Chrome’ from the child window template so there is no ‘Titlebar’ on the child window.
  3. Add a Textblock and a ProgressBar Control to the child window (resize the window also, 180 x 80 is what I use).
  4. Set the ProgressBar Control’s IsIndeterminate property to True.

That is basically your ‘Waiting window’.  The ProgressBar self animates so you don’t need to deal with that.  You can go so far as to add a property to the code behind that will allow you to set the loading message dynamically.

Open the child window when you want to display the message and close it when you are done.  I have an event that fires in my ViewModel class that tells me when my data is loaded.  So before I have the View ask for the data from the ViewModel I show the waiting window.  Then the ViewModel fires a ‘DataLoaded’ event which the View subscribes to.  The View then closes the waiting window.  *NOTE* XAML Binding purists will hate this.  So if you are one go ahead and create some data bindings in your View’s XAML and accomplish the Open and Close of the waiting window on your own.

image

My code behind becomes this:


There is ZERO code in the Waiting Child Window.

Line 3 creates an instance of my ViewModel.  That class is responsible for retrieving the data for the form and setting the data properties on itself with the data it retrieves.  After it retrieves the data it fires an event called QuoteLoaded.

Line 4 creates an instance of the Waiting child window.

Line 8 sets my message above the progressbar control.

Line 9 shows the waiting window.

Line 20 closes the waiting window when the data is all loaded.

Easy-peasy!

In Visual Studio 2010 B2 this is really easy.

Simply right click on your Website project root and choose Property Pages.

image

Click the Silverlight Applications option.  Here you can select the Silverlight Application project from the drop down and specify the destination folder for the .XAP file once it is built.

The “Microsoft.WebApplication.Build.Tasks.GetSilverlightItemsFromProperty” task could not be loaded from the assembly … Microsoft.WebApplication.Build.Tasks.dll. … The assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.  Confirm that the <UsingTaskk> declaration is correct, and that the assembly and all its dependencies are available.

So I am sure there is a way to tweak / edit the solution files and .csproj files to fix this.  I had not gotten into much coding with the Silverlight side of this solution.  I had been working on the Model and WCF stuff (targeting .NET 4.0) so I encountered this when I started on some ViewModel code. 

Clearly this is because the WebApplication project created for the Silverlight 3 application is trying to build with the .NET 4.0 version of the MSBuild environment and Blend 3 wants the 3.5/2.0 version.

The simplest way to fix this is to create the Silverlight + Website project from Blend 3.  Then Add the projects to your VS 2010 B2 solution.  Then everything works.

image

 

image