This is a migrated thread and some comments may be shown as answers.

Q2 2010, The remote server returned an error: NotFound

1 Answer 102 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pullan
Top achievements
Rank 1
Pullan asked on 13 Aug 2010, 10:13 AM
I created a solution and tried to build a program from zero according to Silverlight SalesDashboard Demo. I used OpenAccess to generate Domain Model. Database northwind comes from the Demo.
I noticed the employee class in Employees.generated.cs includes the below two fields:

 

private IList<Employee> employees1 = new List<Employee>();

        [Collection(InverseProperty = "ReportsTo")]
        [Storage("employees1")]
        public virtual IList<Employee> Employees1
        {
            get
            {
                return this.employees1;
            }
        }

        private IList<Order> orders = new List<Order>();

        [Collection(InverseProperty = "Employee")]
        [Storage("orders")]
        public virtual IList<Order> Orders
        {
            get
            {
                return this.orders;
            }
        }

 Then I wrote WCF service according to demo and added it into Shell project as service reference. When testing functions such as GetRepresentatives, I would get error "The remote server returned an error: NotFound" at

System.Collections.ObjectModel.ObservableCollection<Telerik.SalesDashboard.Shell.
SalesDashboardServiceReference.Employee
_result = 
((System.Collections.ObjectModel.ObservableCollection<Telerik.SalesDashboard.Shell.
SalesDashboardServiceReference.Employee
>)(base.EndInvoke("GetRepresentatives", 
_args, result))); <BR>

Seems the type Employee cannot be recognized. I tried many ways, finally, I removed the above two fields. The error disappeared. But I don't know why.

1 Answer, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 18 Aug 2010, 05:24 PM
Hello Pullan,

The troubles you are experiencing are due to WCF serialization issues. Using the persistent classes to travel with service method invocations is not recommended in general. The persistent objects are tightly related to the context (scope) that manages them and this context cannot be serialized and sent through the service. The list collections (the many side of a one-to-many relationship) that you have deleted to make your service work define circular referencing – the Employee persistent class has many Orders and an Order has an Employee reference. The recommended approach when implementing custom WCF services  is to use specially designed objects which repeat the definition of the persistent classes and which are capable to be serialized. In order to link the persistent classes with the serializable ones you can use the assembler pattern. The following Northwind WCF N-tier Demo is developed with best practices in WCF handling. It may seem a bit complicated but spending time to understand it is worth the effort.  The application is not Silverlgiht-based but it revolves around the WCF issues you are facing.

If you need simpler scenarios where WCF services are not in the limelight you can benefit from following the Quickstart examples:

Silverlight 4 – Using WCF RIA Services

Silverlight 4 – Using WCF Data Services

Do not hesitate to contact us if you need further assistance.


Regards,
Petko_I
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Pullan
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Share this question
or