views:

15

answers:

1

I am trying to call a service from a silverlight application, but I am getting the following error.

Uncaught Error: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details.

This works fine locally. I don't know if it make any sense, but locally if I add the url of the webservice on a browser, I am getting the details page of the service. In the other hand, on production server, it prompts me to download it.

Does anyone know something about this?

Thanks

 public MainPage() {
        InitializeComponent();
        Loaded += new System.Windows.RoutedEventHandler(MainPage_Loaded);
    }

    private void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e) {
        var newsFeedWcfClient = new NewsFeedWCFClient();
        newsFeedWcfClient.GetNewsFeedItemsCompleted += newsFeedWcfClient_GetNewsFeedItemsCompleted;
        newsFeedWcfClient.GetNewsFeedItemsAsync();
    }

    void newsFeedWcfClient_GetNewsFeedItemsCompleted(object sender, GetNewsFeedItemsCompletedEventArgs e) {
        var source = (IList<NewsFeed>)e.Result;
        IList<CustomNewsFeed> customNewsFeeds = new List<CustomNewsFeed>();
        foreach (var item in source) {
            customNewsFeeds.Add(new CustomNewsFeed() {
                ProductID = item.Products.ProductID,
                ProductTitle = item.Products.Title,
                Status = item.Text,
                Thumb = string.Format("{0}/{1}", item.Products.Product_Photos.Select(pp => pp.PhotoPath).FirstOrDefault(), item.Products.Product_Photos.Select(pp => pp.PhotoName).FirstOrDefault()),
                UserID = item.User.Id,
                UserName = item.User.Username
            });
        }
        NewsFeedLB.ItemsSource = customNewsFeeds;
    }
A: 

The fact that on the production server it "prompts you to download" would suggest that the production web server doesn't know what to do with your .svc or .asmx file. It is treating it like a normal file (.txt, .pdf etc).

Have you got all of the required items installed in production. For instance, you need the correct .NET runtime to be installed. Also, ASP.NET needs to be installed and then enabled.

To determine exactly what is happening I would recommend installing Fiddler and using it to trace what is happening when the Silverlight app calls the server. I have found this approach to be invaluable when troubleshooting Silverlight to Web Service communication problems.

James