Silverlight / WPF - Unable to build wcf application

Asked By veerendra potru on 19-Nov-09 02:39 AM

Hi, i am new to silverlight.

Basically, i would like to save employee details to the server through WCF Service.

Here are the brief steps about my application :

1. I have a Silverlight Application Project 'MySilverlightApp' which is having a Employee Class and it implements INotifyPropertyChanged interface.So, i prepared Employee object with Name,Id and Address for sending it to the WCF service.

2. I have another WCF Application Project with 'EmployeeService' service. Here i have referenced to 'MySilverlightApp' application for getting 'Employee' object. So that i will receive 'Employee' object from silverlight application for saving the record to the database.

3. I have added the webservice reference in my silverlight project.

But when i build the project, i am getting an error as follows :

Error 1 The type 'System.ComponentModel.INotifyPropertyChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. D:\SilverlightApplication\WcfService\IService1.cs 15 16 WcfService.

I think this problem might be with the INotifyPropertyChanged Interface which is implemented by my 'Employee' class. I cant move my Employee class to the WCF Service project, because my current project having all class files in the silverlight application.

Please help me to solve my problem.Any solution will be appreciated.

Thanks and Regards,


You can move the Employee class in a separate project - Michael Detras replied to veerendra potru on 19-Nov-09 02:57 AM

Most of the data transfer classes I've seen are either defined on the server-side assemblies or an assembly shared by the client and the server. You can go for the latter.

Reply - veerendra potru replied to Michael Detras on 19-Nov-09 05:26 AM

Thanks Michael for quick reply.

But most of my class files are defined in the silverlight application and i couldn't move them to the WCF service application or some other Is there any other way to access the silverlight classes?



If I understand you correctly... - Michael Detras replied to veerendra potru on 19-Nov-09 05:46 AM

I believe you can move all of your data transfer classes into another project. Create a project of type Class Library and put all of your classes there. Then on your Silverlight project, add a reference to the new project. Do the same for your WCF Service project. Also, in the WCF Service project, remove the reference to the Silverlight project. Please let me know if this answers your question.
Re - veerendra potru replied to Michael Detras on 19-Nov-09 06:10 AM

Thanks Michael.

I tried your solution, but i am unable to add reference to'Class Library' from my silverlight application as i am getting the following error :

'You cant add reference to classlibrary.dll as it was not built against silverlight rutime. silverlight projects will only works with silverlight assemblies.'

I dont think that we can add reference to normal class library from silverlight applications.



Sorry about that - Michael Detras replied to veerendra potru on 19-Nov-09 06:16 AM
I thought Silverlight applications are same with WPF. I'll check for a solution.
Please check this. - Michael Detras replied to veerendra potru on 19-Nov-09 06:49 AM

You can check the answer in that forum. It says that the data contracts should be defined in your server-side assemblies. When you add a service reference to your Silverlight project, xml schema and the exchange contract will be generated. You can use the generated classes instead.

Reply - veerendra potru replied to Michael Detras on 19-Nov-09 08:03 AM

Thanks Michael for your quick replay.

Anyway, i will try your link.