我使用的Web引用作为代理,我用它来从sql中获取数据并将数据写入sql。当我在调试模式下使用它时,它没有任何问题,但是在发布时,只要我实例化一个对象,就会抛出一个异常,说明"对象引用没有设置为对象的实例"。
我应该指出,相同的代码在vs 2015中运行良好,但自从我升级到vs 2017后,就出现了这个错误。 我还应该提一下:
A:I don't use a valid ssl certificate for my web service
B:I tried URL Behavior of web service in both static and dynamic.
C:I tried HttpClient Implementation as 'Managed (HttpClientHandler)' and 'Android ClientHandler'
D:I tried SSL/TLS implementation as 'Managed TLS 1.1' and 'Native TLS 1.2+'
E:I tried with and without ServicePointManager for bypass security warnings.
try
{
WebReference.Register wr = new WebReference.Register(); // in release this line throws an exception
Toast.MakeText(this, "we reached here", ToastLength.Long).Show(); // in release we never reach to here , but it's fine in debug mode
}
catch (Exception ex)
{
Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
}
答案 0 :(得分:0)
以防万一其他人遇到同样的问题。
经过一整天,我的头靠在墙上,拉出我的头发,结果是“使用LLVM优化编译器”选项导致问题。禁用此选项解决了我的问题。