Hi,
1. I have a WCF service, deployed as part of an asp.net mvc3 application.
[ServiceContract]
public interface ILoadService
{
[OperationContract]
string SayHello(string yourName);
}
public class LoadService : ILoadService
{
public string SayHello(string yourName)
{
return "Server Said: Hello " + yourName;
}
}
2. Im using code sharing techniques for Mono For Android, and hence my project setup for android app is as below
a. SharedLibrary : Which adds a Service Reference to the online WCF, and uses it to make calls through a proxy generated through SvcUtil.exe (automatically generated proxy). A file named abc.cs makes the WCF calls
using SharedLibrary.LoadServiceReference;
using System;
using System.Runtime.Serialization;
public class LoadServiceLibrary
{
public string SayHello(string yourName)
{
using (LoadServiceClient client = new LoadServiceClient())
{
var result = client.SayHello(yourName);
return result;
}
}
}
b. SharedLibrary.MonoAndroid : An Android service library that adds abc.cs from SharedLibary "as a link" so that we resolve .net dll issues where SharedLibrary is a common library and SharedLibrary.MonoAndroid uses MonoForAndroid profile.
example: same file above --> as a link
c. I have a project, say AndroidApp, that first adds the SharedLibrary.MonoAndroid as an Existing Project to the solution, adds a reference to the added project. Now the idea is to use Native UI for Android (In future, iOS WP7).
Example Android App:
using SharedLibrary.MonoAndroid;
[Activity(Label = "Second Page")]
public class SecondActivity : Activity
{
private ProgressDialog progressDialog;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.ServerResponse);
progressDialog = new ProgressDialog(this) { Indeterminate = true };
progressDialog.SetTitle("Getting Hello Signal");
progressDialog.SetMessage("Please wait...");
progressDialog.Show();
ThreadPool.QueueUserWorkItem(item => GetResponse());
}
private void GetResponse()
{
string serverResponse;
using (LoadService client = new LoadService())
{
serverResponse = client.SayHello("My Name");
if (serverResponse != null)
{
RunOnUiThread(() =>
{
progressDialog.Hide();
FindViewById<TextView>(Resource.Id.Response).Text = serverResponse;
});
}
}
}
Now the problem is... When i add abc.cs as Link to the SharedLibrary.MonoAndroid, the using statement contained in abc.cs (using MyWcfService) in the original project SharedLibrary does not resolve. If i add a new Web Reference, to SharedLibrary.MonoAndroid just to reslove the issue, the whole code sharing breaks down, where in in the future, i might have to add local Reference to SharedLib.iOS, sharedLib.Wp7..
Can anyone suggest a work around for this? because i don't want to break the chain of shared code, which is possible through the original shared library.
Any help is greatly appreciated. Thanks.