.NET Components for Mobility

BadRequest VS2003 C#

Last post 02-13-2007 9:13 PM by PeterFoot. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-13-2007 6:31 AM

    • zope83
    • Not Ranked
    • Joined on 02-12-2007
    • Posts 0

    BadRequest VS2003 C#

    Hello

     I have searched through forum threads and cannot find information why I get a bad request when I use the sample code submitted with in the hand download.

     I have version 1.6 of In the hand.

    When I run the sample: ObjectPushApplication it works to send files to a bluetooth device but with the same code I get this bad request. I don't understand why at all. The dialog box to choose device works and I get the device address. The sample code is written in VS2005 but I also have an application, by Glarks, written in VisualBasic, VS2003 and it works.

    Here is the code I have:

    using System;

    using System.Drawing;

    using System.Collections;

    using System.Windows.Forms;

    using System.Data;

    using System.Net;

    using System.Net.Sockets;

    using System.IO;

    using InTheHand.Net;

    using InTheHand.Net.Sockets;

    using InTheHand.Net.Bluetooth;

    using InTheHand.Net.Forms;

     

    namespace Svep.QualiTracer.TestController.Plugin

    {

    /// <summary>

    /// Discover and connects to another bluetooth device

    /// Sends a file to the device

    /// </summary>

    ///

    public class Bluetooth

    {

    private BluetoothClient bc;

    public Bluetooth()

    {

    try

    {

    bc = new BluetoothClient();

    }

    catch

    {

    l4n.log.Error("Couldnt load BT-client");

    }

    BluetoothRadio br = BluetoothRadio.PrimaryRadio;

    if(br!=null)

    {

    br.Mode = RadioMode.Discoverable;

    }

    else

    {

    l4n.log.Error("Your device uses an unsupported Bluetooth software stack");

    }

    sendFile();

    }

    public void sendFile()

    {

    l4n.log.Info("sendFile 1");

     

    // use the new select bluetooth device dialog

    SelectBluetoothDeviceDialog sbdd = new SelectBluetoothDeviceDialog();

    sbdd.ShowAuthenticated = true;

    sbdd.ShowRemembered = true;

    sbdd.ShowUnknown = true;

    if(sbdd.ShowDialog()==DialogResult.OK)

    {

    Cursor.Current = Cursors.WaitCursor;

    System.Uri uri = new Uri("obex://" + sbdd.SelectedDevice.DeviceAddress.ToString() + "/" + "test.txt");

    //System.Uri uri = new Uri("obex://" + sbdd.SelectedDevice.DeviceAddress.ToString() + "/" + System.IO.Path.GetFileName(ofdFileToBeam.FileName));

    ObexWebRequest request = new ObexWebRequest(uri);

    //request.ReadFile(ofdFileToBeam.FileName);

    request.ReadFile("c:\\test.txt");

     

    ObexWebResponse response = (ObexWebResponse)request.GetResponse();

     

    l4n.log.Error(response.StatusCode.ToString());

    response.Close();

    Cursor.Current = Cursors.Default;

    }

    }

    }

     

    }

    Filed under:
  • 02-13-2007 9:13 PM In reply to

    Re: BadRequest VS2003 C#

    BadRequest is often caused by an incorrect address used, or the remote device doesn't expose the specific service you are connected to e.g. ObexPush

    Peter

    Peter Foot
    Microsoft Device Application Development MVP
    www.peterfoot.net | www.inthehand.com
Page 1 of 1 (2 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.