HttpWebRequest的粉碎应用调试发布配置 [英] HttpWebRequest crush application Debug Release configuration

查看:207
本文介绍了HttpWebRequest的粉碎应用调试发布配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写的HTTP请求中检索使用安全的API Web服务器的信息(JSON)。
应用程序工作正常,当我调试它的AVD或设备,但是当我发布的应用程序,并尝试运行已安装的apk它粉碎。
我设置了Internet权限。

非常感谢您的任何意见。
这里是我的code:

  System.Net.ServicePointManager.ServerCertificateValidationCallback =
新System.Net.Security.RemoteCertificateValidationCallback(委托{返回true;});
字符串的用户名=******;
字符串密码=******;
字符串的URL =的String.Format(https://开头......);VAR REQ =(HttpWebRequest的)WebRequest.Create(URL);
req.Credentials =新的NetworkCredential(用户名,密码);
变种响应= req.GetResponse();使用(StreamReader的读者=新的StreamReader(response.GetResponseStream()))
    {
    VAR内容= reader.ReadToEnd();
    MYLIST = JsonConvert.DeserializeObject<名单,LT;比较>>(内容);
    }


解决方案

每当我看到调试之间不同的行为,并释放我的code的构建我我怀疑是连接问题。

试着改变你的链接选项:项目选项> Android组建> Linker选项卡。更改发布配置匹配到匹配的调试配置(我猜测它不链接)。你并不想真正释放这种方式 - 这仅仅是解决该问题。然后生成并运行在释放模式的应用程序。如果现在的工作,这个问题被链接相关。

相反,您可以更改调试配置以匹配发布配置是(可能只链接SDK组件),卸载应用程序,做一个干净的构建,然后构建并运行调试版本,以查看是否发生在那里的问题。如果现在失败了,问题是相关的链接。

对于链接帮助,请参阅:请参阅: HTTP://developer.xamarin。 COM /引导/安卓/ advanced_topics /连接/

I'm writing http request to retrieve information(json) from the web server using secured API. Application is working fine when I'm debugging it on AVD or device, however when I released the app and tried to run an installed .apk it crush. I set the Internet permission.

Thank you very much for any advice. Here is my code:

System.Net.ServicePointManager.ServerCertificateValidationCallback =
new System.Net.Security.RemoteCertificateValidationCallback(delegate { return true; });
string username = "******";
string password = "******";
string url = String.Format("https://......");

var req = (HttpWebRequest)WebRequest.Create(url);
req.Credentials = new NetworkCredential(username, password);
var response = req.GetResponse();

using (StreamReader reader = new StreamReader(response.GetResponseStream()))
    {
    var content = reader.ReadToEnd();
    MyList = JsonConvert.DeserializeObject<List<Comp>>(content);
    }

解决方案

Whenever I see different behavior between the debug and release build of my code my I suspect a linking issue.

Try changing your linking options: Project Options>Android Build>Linker Tab. Change the Release configuration match to match the Debug configuration (I am guessing that it is Don't Link). You don't want to really release this way -- this is just to troubleshoot the issue. Then build and run the app in release mode. If it now works, the issue was linking related.

Conversely, you can change the Debug configuration to match what the Release configuration was (probably Link SDK assemblies only) uninstall the app, do a clean build and then build and run the Debug version to see if the issue occurs there. If it now fails, the issue was linking related.

For help with Linking, see: See: http://developer.xamarin.com/guides/android/advanced_topics/linking/

这篇关于HttpWebRequest的粉碎应用调试发布配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆