.NET Components for Mobility

NotImplemented Exception on Discovery?

Last post 06-18-2009 8:57 AM by alanjmcf. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 06-15-2009 7:45 AM

    NotImplemented Exception on Discovery?

    Hello,

    In my software based on the InTheHand.net library, I have the following subroutine to do discovery.  Note that myBlueTooth is an object of type BlueToothClient, instantiated at the class level.  This subroutine is called in a thread each time I want to discover devices.

    The code works fine - for 8 or 10 or even 18 hours, but eventually the system hangs (not every system, only some, and for some reason it is more likely to occur on systems with Portuguese Windows XP).  I was finally able to discover that the problem is in the line of code where I call DiscoverDevices, and the NotImplemented exception is thrown.

    Dim foundDevs() As BluetoothDeviceInfo = myBlueTooth.DiscoverDevices(NumToDiscover, False, True, True)

    So...Is this a bug in the DiscoverDevices function?  Or is it something in my code?  Has anyone had a similar problem?

    Thanks.

     

    <code> 

    Private Sub tDoDiscovery()DeviceList = New ArrayList

    NumToDiscover = SaveNumToDiscover

    Dim amDone As Boolean = False

    If Not HaveBluetoothDevice Then

    RaiseEvent DiscoveryComplete()

    Exit Sub

    End If

    DeviceList.Clear()

    Debug.Print("About to DiscoverDevices")

    Dim foundDevs() As BluetoothDeviceInfo = myBlueTooth.DiscoverDevices(NumToDiscover, False, True, True)

    For Each foundDev As BluetoothDeviceInfo In foundDevs

    foundDev.Refresh()

    DeviceList.Add(foundDev)

    Next

    RaiseEvent DiscoveryComplete()

    Debug.Print("BTManager: end of tDoDiscovery")

    End Sub

    </code>

    Here is the exception information:

    A first chance exception of type 'System.NotImplementedException' occurred in System.dll
    System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical">
    <TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier>
    <Description>Unhandled exception</Description><AppDomain>Bluetooth Marketing 2Call.vshost.exe</AppDomain>
    <Exception><ExceptionType>System.NotImplementedException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
    <Message>This method is not implemented by this class.</Message>
    <StackTrace>   at System.Net.EndPoint.Create(SocketAddress socketAddress)
       at InTheHand.Net.BluetoothEndPoint.Create(SocketAddress socketAddress)
       at InTheHand.Net.Sockets.BluetoothClient.DiscoverDevices(Int32 maxDevices, Boolean authenticated, Boolean remembered, Boolean unknown)
       at BlueGarra.BlueTooth.tDoDiscovery() in C:\Documents and Settings\Amir Bavar\My Documents\BlueGarra\BlueGarra\BlueTooth.vb:line 354
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>System.NotImplementedException: This method is not implemented by this class.
       at System.Net.EndPoint.Create(SocketAddress socketAddress)
       at InTheHand.Net.BluetoothEndPoint.Create(SocketAddress socketAddress)
       at InTheHand.Net.Sockets.BluetoothClient.DiscoverDevices(Int32 maxDevices, Boolean authenticated, Boolean remembered, Boolean unknown)
       at BlueGarra.BlueTooth.tDoDiscovery() in C:\Documents and Settings\Amir Bavar\My Documents\BlueGarra\BlueGarra\BlueTooth.vb:line 354
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord>

  • 06-15-2009 12:09 PM In reply to

    Re: NotImplemented Exception on Discovery?

    That's an interesting one!  What happens it that we get a sockaddr_bt out of the native discovery procedure, and call BluetoothEndPoint.Create to convert it to a BluetoothEndPoint.  But the value doesn't look valid so we ask the base class (EndPoint) to convert it.  It doesn't know how, so the NotImplementedException is shown.

    So ultimately the results being returned by the native discovery process look to be wrong, at least the value containing the address type is wrong it should be 32.  So something wrong in the winsock stack or something on your machine, or...?  Is there anything else special about the environment?  Is it WCF or something?  You are the first person to report this BTW.

    If you debug the code it'll be interesting to see what array we get out.  If you download the sources from CodePlex (http://32feet.codeplex.com/SourceControl/ListDownloadableCommits.aspx) you can build the library yourself.  Then you can debug to see what happens, but also you could change the code to skip the bad values for instance.  But I'd like to see that the values look like to see if this could be a general problem.

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
  • 06-16-2009 6:58 AM In reply to

    Re: NotImplemented Exception on Discovery?

    Anything special about the environment?  Our customers are running in to this problem on all types of PCs, nothing special, Windows XP Pro SP2 and SP3, English and Portuguese languages (not sure if it happens under Vista...)  The one common factor is that the software has to be running in an environment where there are a lot of Bluetooth devices being discovered, such as in a shopping mall, and it usually takes hours before the problem happens.  We can't reproduce the bug in the lab, we only managed to get the exception message when we installed Visual Studio on a laptop and left the software running under the debugger at a store in the mall.

    For now I've added exception handling to my discovery procedure, which will close the BluetoothClient, pause, then recreate it, and return.  This should at least prevent the software from locking up.

    I will download the source and see what I can do about debugging it.

    Thanks for the help.

  • 06-18-2009 8:57 AM In reply to

    Re: NotImplemented Exception on Discovery?

    Maybe add the following lines into [Socket]BluetoothClient.DiscoverDevices, adding the 'debug' lines into the existing code.  Then we could see what sort of data Winsock is returning.

       byte[ debug = new byte[sockaddrlen]; //debug
       for(int sockbyte = 0; sockbyte < sockaddrlen; sockbyte++)
       {
          btsa[sockbyte] =
    Marshal.ReadByte(sockaddrptr, sockbyte);
          debug[sockbyte] = btsa[sockbyte];
    //debug
       }
       Debug.WriteLine("sockaddr: " + BitConverter.ToString(debug), "DiscoverDevices"); //debug

    .

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
Page 1 of 1 (4 items)
Copyright © 2001-2010 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.