Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
I'm trying to develop a bluetooth application in Windows Phone 7. I found WP7 doesn't provide bluetooth SDK. So I thought to implement the required functionality in C# assembly and import it in phone application.
But WP7 even doesn't allow this importing as well. So thought of to develop a COM dll in C++ and to import it in WP7 application. For POC, I developed a COM dll, and imported it in WP7 application using ComBridge object from Microsoft.Phone.InteropServices. The dll is getting loaded/registered. But when I instantiate the required coclass from the dll, it throws COMException saying 'The request is not supported.' Can somebody point out what else I could be missing?

Following is the code snippet I wrote in WP7 application.

C#
internal static class BluetoothExports
{
    private static ICOMBluetoothServer m_iBluetoothServer;

    static BluetoothExports()
    {
        //This works fine.
        ComBridge.RegisterComDll("COMBluetooth.dll", new Guid("3A3C0E65-4ECD-4f8a-A0CC-9509C287375E"));

        //This is the point where I get exception.
        m_iBluetoothServer = new CProxyBluetoothClass() as ICOMBluetoothServer;
    }

    public static int GetDeviceName(string strDeviceName)
    {
        int retValue = 0;

        retValue = m_iBluetoothServer.GetDeviceName(strDeviceName);

        return retValue;
    }
}

public abstract class Bluetooth : IDisposable
{
    public void TestBluetooth()
    {
        string str = "";
        BluetoothExports.GetDeviceName(str);
    }

    public void Dispose()
    {
    }
}

public class CBluetooth : Bluetooth
{
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900