Chinaunix首页 | 论坛 | 博客
  • 博客访问: 42580
  • 博文数量: 17
  • 博客积分: 330
  • 博客等级: 一等列兵
  • 技术积分: 135
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-23 16:12
文章分类

全部博文(17)

文章存档

2011年(17)

我的朋友

分类: 嵌入式

2011-09-16 09:25:10

不好意思,又要来请教大家问题, 我现在在帮公司做的,是一个barcode的软件,用途是机器扫描barcode之

后,可以透过soap传到网路上,soap的连接已经可以了,不过因为考虑到机器不是一直都会有网路,所以扫了

之后,按下一个button,他就回上传到网路上,如果没有网路的话,我想说先存到local的数据库,以下是那个按

钮的程式码

private void button1_Click(object sender, EventArgs e)
        {
            label2.Text = null;

            //Get the hostmachine name

            string hostName = Dns.GetHostName();

            label2.Text += string.Format("HostName:{0}\r\n", hostName);

            //Get machine information
            IPHostEntry hostEntry = Dns.GetHostEntry(hostName);

            //List the IP address
            foreach (IPAddress ip in hostEntry.AddressList)
            {
                label2.Text += string.Format("IP:{0}\r\n", ip);
            }         
            //know the IP is working or not
            try
            {
                if (hostEntry.AddressList[0].ToString() == "127.0.0.1")
                {
                    MessageBox.Show("No Internet, Save Local DataBase");
                    barCodeTextBox.Text = textBox1.Text;
                    ordersBindingSource.EndEdit();
                    ordersDataGrid.Update();
            //这段是如果没网路的话会执行的
                }
                else
                {

                    
                    EchoService.EchoServer test = new   BarCode07032.EchoService.EchoServer();
                    String text = textBox1.Text;
                    test.Echo(ref text);
                    MessageBox.Show(text);
//这段是有网路之后会执行的
                }

            }
            catch (WebException Exc)
            {            
                MessageBox.Show(Exc.Message);
            }
            catch (InvalidOperationException Exc2)
            {
                MessageBox.Show(Exc2.Message);
            }
    }


用电脑的emulator跑可以过,但是一放到机器上,当没有网路的时候,程式就会当掉讯息是

"Client found response content type of ''text/html", but expected 'text/xml'

at  System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName,Object[] parameters, WebClientAsyncResult asyncResult)

at

BarCode07032.EchoService.EchoServer.Echo(String&value)

at

BarCod..........(后面很长)



























































vs调试时候如何附加进程到device.exe?列表里面没有这个进程,但实际上手机里是有的。























用ShellExecuteEx执行iexplore.exe时出错
















更多windows phone开发资料,请访问
阅读(405) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~