locked
Binding silverlight controls to a WCF data service RRS feed

  • Question

  • Hi,

    Beginning on Silverlight here. I am struggling with the example "Binding silverlight controls to a WCF data service" at http://msdn.microsoft.com/en-us/library/ee621313.aspx . It just never shows the customer data in my firefox 10. Setting breakpoints at the loaded method does not work either. How can i discover security problems?

    Hope someone will help me out?

    Here is my code

    http://www.sendspace.com/file/b3ni9n

    • Moved by Sheldon _Xiao Tuesday, March 20, 2012 8:58 AM (From:Windows Presentation Foundation (WPF))
    Sunday, March 4, 2012 6:17 PM

All replies

  • On 3/4/2012 1:17 PM, CsharpCoder2012 wrote:
    > Hi,
    >
    > Beginning on Silverlight here. I am struggling with the example "Binding
    > silverlight controls to a WCF data service" at
    > shows the customer data in my firefox 10. Setting breakpoints at the
    > loaded method does not work either. How can i discover security problems?
    >
    > Hope someone will help me out?
    >
    > Here is my code
    >
    >
     
    I suggest that you set a breakpoint in the WCF Web service code and
    start single stepping through the code.
     
    You set a breakpoint and hit F5 on in the VS IDE on the client-side
    before you call the service, and you "Attach" to the ASP.NET Worker
    Process. The ASP.NET Worker Process hosts all ASP.NET processes.
     
    The worker process may be call w3wp.exe it depends and can be different
    that what's being shown in the link.
     
     
    The hit f5 to continue until you hit the breakpoint in the WCF Web
    Service. You have about 60 seconds in the WCF service in break mode
    before it times-out, kicks you out, and you have to start over again.
     
    I suspect the WCF service is blowing-up, you don't know it (no
    try/catches) and it's not returning anything.
     
     
    Sunday, March 4, 2012 6:52 PM
  • I had some more luck with debugging with IE and i get a nullreference at these commands

    customersViewSource.Source = advWorksService.Customer.EndExecute(result)) . What should i look for because a nullreference does not tell what is wrong?

    The data can be queried from the sql server from VS with the local windows logged in account..

    Should it be possible to get customer data as xml if browsing to localhost:8942/AdventureWorksDataService.svc/Customer ? If so, it does not shown any data....


    Sunday, March 4, 2012 8:58 PM
  • On 3/4/2012 3:58 PM, CsharpCoder2012 wrote:
    > I had some more luck with debugging with IE and i get a nullreference at
    > these commands
    >
    > customersViewSource.Source =
    > advWorksService.Customer.EndExecute(result)) . What should i look for
    > because a nullreference does not tell what is wrong?
    >
    > The data can be queried from the sql server from VS with the local
    > windows logged in account..
    >
    > Should it be possible to get customer data as xml if browsing to
    > localhost:8942/AdventureWorksDataService.svc/Customer ? If so, it does
    > not shown any data....
    >
    >
     
    I don't know man. I took that project, followed the instructions, put
    the project together and it worked like a champ. I forgot the port
    number the Data Server was listening on. So I did a Edit/Find
    Replace/Find in all Files and searched for "LocalHost"  and found the
    line that had the port number for the Development server and changed the
    line for Localhost in the below code to that port number.
     
    The link you posted and at the bottom of the link starts showing things
    you must check if the application doesn't work out the gate. If you have
    followed the instructions to the letter, then the project should work
    for you.
     using System;
    using System.Windows;
    using System.Windows.Controls;
    using AdventureWorksSilverlightApp.AdventureWorksService;
     namespace AdventureWorksSilverlightApp
    {
        public partial class MainPage : UserControl
         {
            private AdventureWorksLTEntities advWorksService;
            private System.Windows.Data.CollectionViewSource
    customersViewSource;
             public MainPage()
            {
                InitializeComponent();
            }
             private void UserControl_Loaded(object sender, RoutedEventArgs e)
            {
                 // Do not load your data at design time.
                // if
    (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
                // {
                //     //Load your data here and assign the result to the
    CollectionViewSource.
                //     System.Windows.Data.CollectionViewSource
    myCollectionViewSource =
    (System.Windows.Data.CollectionViewSource)this.Resources["Resource Key
    for CollectionViewSource"];
                //     myCollectionViewSource.Source = your data
                // }
            }
             private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
            {
                advWorksService = new AdventureWorksLTEntities(new
                 customersViewSource = this.Resources["customersViewSource"]
                as System.Windows.Data.CollectionViewSource;
                advWorksService.Customers.BeginExecute(result =>
    Dispatcher.BeginInvoke(() => customersViewSource.Source =
    advWorksService.Customers.EndExecute(result)), null);
             }
        }
    }
     
    Monday, March 5, 2012 1:15 AM
  • customersViewSource is null when i run this line

    customersViewSource = this.Resources["customersViewSource"] as System.Windows.Data.CollectionViewSource;

    which must give the trouble at the next line as i wrote earlier..

    I am not sure i understand exactly this.Resources["customersViewSource"] which gets "customersViewSource" but where is this instantiated. I havent done it and the example does not either...

    Monday, March 5, 2012 1:46 PM
  • On 3/5/2012 8:46 AM, CsharpCoder2012 wrote:
    > customersViewSource is null when i run this line
    >
    > customersViewSource = this.Resources["customersViewSource"] as
    > System.Windows.Data.CollectionViewSource;
    >
    > which must give the trouble at the next line as i wrote earlier..
    >
    > I am not sure i understand exactly this.Resources["customersViewSource"]
    > which gets "customersViewSource" but where is this instantiated. I
    > havent done it and the example does not either...
    >
     
    I suggest that you do the project over from scratch and use the VS
    Development server as instructed in the instructions to build and set
    the solution up to run. It must be something you have missed or have not
    done correctly in following those instructions.
     
    Like I said, I followed those instructions to the letter and made sure
    the solution was setup and built correctly. I got confused at the WCF
    service and Silverlight setup instructions, but I stopped, looked and
    verified that things were correct in the set-up of the projects etc, etc.
     
    The project/solution ran  and worked the first time right out the gate
    for me with no issues.
     
    All I can say is that you have missed something, or you have not done
    something correctly based on the given instructions on how to setup the
    project and run it.
     
    Monday, March 5, 2012 3:48 PM
  • Hi CsharpCoder2012,

    This is WPF forum, as for Silverlight relative issue, you could post it on Silverlight forum to get better answer, the link is:

    http://forums.silverlight.net/

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 6, 2012 3:55 AM