c# - Cannot connect to a local network server in Visual Studio Xamarin Android -


i'm using xamarin in visual studio community ; i'm trying connect remote database without success.

tried wcf, rest, httprequest - none can connect remote server/service. in "new console application", however, works fine. made "new android project", cannot connect service/server, either.

the following code works in console application cannot connect in xamarin mono (visual studio):

httpwebrequest request = httpwebrequest.create(string.format(@"http://192.168.16.100/restservice/restserviceimpl.svc/json/12")); request.contenttype = "application/json"; request.method = "get";  using (httpwebresponse response = request.getresponse() httpwebresponse) {     if (response.statuscode != httpstatuscode.ok)     {         console.out.writeline("error fetching data. server returned status code: {0}", response.statuscode);     }      using (streamreader reader = new streamreader(response.getresponsestream()))     {         var content = reader.readtoend();         if (string.isnullorwhitespace(content))         {             console.out.writeline("response contained empty body...");         }         else         {             console.out.writeline("response body: \r\n {0}", content);         }     } } console.readline(); 

have tried windows communication foundation (wcf)?

for me works great selfhosted wcf service. (make sure run selfhoster admin, otherwise fail)

you need download: slsvcutil create app client , include in xamarin project.


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -