我们在WM 6.5上运行的解决方案连接到我们的服务器,但我们的客户之一经常出现问题,我们的软件失去了gprs连接,并且在手机重新启动之前无法获得新的连接。
我们知道手机位于gprs区域,因为我们可以将桌面远程连接到手机并使用Internet Explorer浏览。我们的日志显示虽然我们指定了2分钟超时,但ConnMgrEstablishConnectionSync返回waitForConnection状态。有没有人有什么想法会出错?例如某些第三方软件是否有可能窃取我们的连接?
非常感谢。
private void Connect()
{
if (_connectionHandle != IntPtr.Zero)
{
EventLog.AddLogEntry(LogSeverity.Trace, "connmgr - current handle was:" + _connectionHandle);
CloseConnection();
}
const int connectionTimeout = 120000;
const int CONNMGR_PARAM_GUIDDESTNET = 1;
const int CONNMGR_PRIORITY_USERINTERACTIVE = 0x8000;
const int CONNMGR_FLAG_SUSPEND_AWARE = 0x10; // suspended connections supported
const int CONNMGR_FLAG_NO_ERROR_MSGS = 0x40; // don't show any error messages for failed connections
const int CONNMGR_proxies = 0x3;
const string testUrl = "http://www.bbc.co.uk";
ConnectionInfo info = new ConnectionInfo();
info.cbSize = (uint)Marshal.SizeOf(info);
info.bExclusive = 0;
info.dwFlags = CONNMGR_proxies | CONNMGR_FLAG_NO_ERROR_MSGS | CONNMGR_FLAG_SUSPEND_AWARE;
info.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
Guid networkGuid = Guid.Empty;
int hResult = MobileNativeMethods.ConnMgrMapURL(testUrl, ref networkGuid, IntPtr.Zero);
if (hResult != 0)
{
EventLog.AddLogEntry(LogSeverity.Trace, "<<Dllimport - ConnMgrMapURL (error) " + hResult.ToString());
throw new ConnectionUnavailableException("Unable to open connection");
}
info.guidDestNet = networkGuid;
info.dwParams = CONNMGR_PARAM_GUIDDESTNET;
uint status = 0;
hResult = MobileNativeMethods.ConnMgrEstablishConnectionSync(ref info, out _connectionHandle, (uint)connectionTimeout, out status);
if (hResult != 0)
{
EventLog.AddLogEntry(LogSeverity.Trace, "<<Dllimport - ConnMgrEstablishConnectionSync (error) " + networkGuid.ToString());
throw new ConnectionUnavailableException("Unable to open connection: " + (ConnectionStatus) status);
}
EventLog.AddLogEntry(LogSeverity.Trace, "<<Dllimport - ConnMgrMapURL Connection OK");
}
答案 0 :(得分:1)
最后我发现将注册表中的AlwaysOn设置设置为false可以解决问题。我怀疑霍尼韦尔设备存在更深层次的问题,因为摩托罗拉设备似乎无论其价值如何都能正常运行。