Quantcast

Consuming WCF 4.0 Service

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Consuming WCF 4.0 Service

robroysd
Hi,

I have a WCF service, embedded in an asp.net MVC3 app. I want to consume this service thorugh my android app (mono for android).

When i reference the service (through a shared library) i get the following error: Error 1 The type 'System.Runtime.Serialization.IExtensibleDataObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

I realize that the .net Profile for mono for android is different than .net 4.0, but for the above situation, is there a work around?

Any help is appreciated. Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Consuming WCF 4.0 Service

Jonathan Pryor-2
On Oct 24, 2012, at 10:32 AM, robroysd <[hidden email]> wrote:
> I have a WCF service, embedded in an asp.net MVC3 app. I want to consume this service thorugh my android app (mono for android).
>
> When i reference the service (through a shared library) i get the following error: Error 1 The type 'System.Runtime.Serialization.IExtensibleDataObject'
> is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

You need to do two things:

1. Add an assembly reference to System.Runtime.Serialization.dll. (The Mono for Android profile includes a System.Runtime.Serialization.dll.)
2. Your shared library needs to be rebuilt to use the Mono for Android profile assemblies. You can do this by creating a new project and using file linking:

        http://docs.xamarin.com/ios/Guides/Application_Fundamentals/Building_Cross_Platform_Applications/Part_3_-_Setting_Up_A_Xamarin_Cross_Platform_Solution#File-linking_into_each_App_Project

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Consuming WCF 4.0 Service

robroysd
Hi Jon,

I fixed the issue of missing dll's ect.

For code sharing however.. facing issues.

To simply the scenario, here's the deal:
Project A is a normal .NET class library.
  This project contains a WCF Reference, to make common calls through file somefile.cs which uses WCF.

Project B is an Android Class Library (mono for android profile)
  This project adds "as a link" somefile.cs from project A

There is no way no matter what  i tried, that the "as a link" file added in project B, resolves the wcf reference. Adding as a link, just does not work in this case when WCF reference is involved.
Project B want's its own WCF reference. Couldn't get around this.

So i've done the following:
New Project A (previously project B) now has WCF reference, uses it and makes calls
New Project B (Android App) references Project A, and uses the calls.

With this approach, i guess if i build iOS, WP7 apps, i'd have to add WCF references to those projects, and use it.

what im thinking is, Since all code only uses WCF, i only have to maintain a consistent server side WCF.
Client projects (Android,iOS,WP7) can add new functionality as WCF references, and use it.

I realize that you answered my question, and thanks for that. But in the above case, i tried things but didnt work.

If you have any suggestions, let me know. Thank you.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Consuming WCF 4.0 Service

Jonathan Pryor-2
On Oct 26, 2012, at 2:58 PM, robroysd <[hidden email]> wrote:
> For code sharing however.. facing issues.
>
> To simply the scenario, here's the deal:
> Project A is a normal .NET class library.
>  This project contains a WCF Reference, to make common calls through file
> somefile.cs which uses WCF.
>
> Project B is an Android Class Library (mono for android profile)
>  This project adds "as a link" somefile.cs from project A

Project B _also_ needs to contain WCF assembly references, otherwise it won't compile. For example, you'll need to add System.Runtime.Serialization.dll and System.ServiceModel.dll assembly references to Project B so that somefile.cs can use WCF types.

> There is no way no matter what  i tried, that the "as a link" file added in project B, resolves the wcf reference.

Nor would I expect it to. Source files cannot specify assembly references; projects specify assembly references.

> Project B want's its own WCF reference. Couldn't get around this.

Right. I'm trying to figure out why you'd want to "get around this." Go with it, and add the appropriate assembly references. Does this not work for some reason?

> So i've done the following:
> New Project A (previously project B) now has WCF reference, uses it and
> makes calls
> New Project B (Android App) references Project A, and uses the calls.

That structure sounds like a Bad Idea. It might work, as long as our desktop WCF and Mono for Android WCF APIs match, but that's not necessarily true; Mono for Android's WCF is based upon the Silverlight WCF API, not the desktop WCF API, and these are not entirely compatible with each other.

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Consuming WCF 4.0 Service

Samus Arin
In reply to this post by robroysd
If you have the option, and get an opportunity, I'd highly reccomend porting your asp.net
webservice from WCF to WebApi 4.  

WebApi 4's asp.net mvc webservices are no long WCF based, and implements REST
lightweight, like it should be (there is nothing lightweight about WCF, hence the departure
from it).

I believe WCF is primarily intended for Enterprise Web Apps running on corporate intranets.

On Wed, Oct 24, 2012 at 10:32 AM, robroysd <[hidden email]> wrote:
Hi,

I have a WCF service, embedded in an asp.net MVC3 app. I want to consume
this service thorugh my android app (mono for android).

When i reference the service (through a shared library) i get the following
error: Error 1 The type 'System.Runtime.Serialization.IExtensibleDataObject'
is defined in an assembly that is not referenced. You must add a reference
to assembly 'System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'.

I realize that the .net Profile for mono for android is different than .net
4.0, but for the above situation, is there a work around?

Any help is appreciated. Thanks.



--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Consuming-WCF-4-0-Service-tp5712234.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
mk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Consuming WCF 4.0 Service

mk
This post has NOT been accepted by the mailing list yet.
In reply to this post by Jonathan Pryor-2
hi
i ran into same problem using mono 4.0.5
when i tried to using System.Runtime.Serialization.dll;
 Error CS0234: The type or namespace name `dll' does not exist in the namespace `System.Runtime.Serialization'. Are you missing an assembly reference? (CS0234) (infra)
Loading...