locked
Can you have multiable package manifest in a solution.

    Question

  • Hello

    I'm trying to add a c# window runtime component to an existing javascript solution.  The new project will access a bluetooth device.  I know I need to add bluetooth capability to the package manifest which I did in the original javascript project.  But the service provider is still getting a null.  Do I need a separate package manifest for each project in a solution?

    Thanks 

    Friday, February 07, 2014 4:53 PM

Answers

  • The first call needs to be on the UI thread to bring up the permissions dialog. Are you seeing that?

    Your JavaScript call should be on the UI thread unless you're doing something specifically to avoid it. The documentation I linked explains several techniques for getting back onto the UI thread from your runtime component in case it's off.

    If you make your call directly from a button click you know for sure you're on the UI thread.

    --Rob

    • Marked as answer by dontcallmejeff Wednesday, February 19, 2014 4:34 PM
    Tuesday, February 18, 2014 7:23 PM
    Owner

All replies

  • Hello

    I'm going to ask my question in a different way.  I have a javascript project that is running great.  I want to add bluetooth access so I've added another project to the solution that is a C# window runtime component that is being called from javascript.  My call from rfcommDeviceService.FromIdAsync is all ways returning a null.  I know this most often happens when the bluetooth capabilities are not added to the manifest.  I've added it to the manifest in the javascript project which is the app store project.  Do I also need to add to the window runtime component project?  Is there other reason for getting a null every time?

    Thanks for any help.

    John

    Friday, February 07, 2014 9:54 PM
  • Hi not-Jeff,

    You'll need one manifest for the appx package. The manifest controls the permissions and capabilities of the entire app package (in the scenario you describe that's the JavaScript app), not for individual components.

    To narrow down the problem can you successfully call the service provider from JavaScript? When calling from your component do you see the initial consent dialog? Are you calling FromIdAsync from the UI thread at least once?

    --Rob


    Friday, February 07, 2014 10:15 PM
    Owner
  • Rob

    Thanks for the reply.  I'm trying to avoid doing the bluetooth communications in the main javascript app.  So I haven't tried adding the calls there, I guess that the next thing to try.  Are there any good examples of opening a bluetooth serial port in javascript?  I don't beleive I've called the FromIdAsync UI thread since I'm doing all this in my window runtime component.  Would the UI thread be part of the main app store app.  Is there a way to call something on the UI thread in the window runtime component?

    John

    Friday, February 07, 2014 10:26 PM
  • Rob

    I'm going to try call from Javascript today.  But are you indicating that I can't do it the way I planned.  That I can't have all the bluetooth code in a window run time component and out side the main application which is an html javascript application.

    John

    Monday, February 10, 2014 4:17 PM
  • Hi John,

    You should be able to do this from a WRC. I suggested checking the calls from JavaScript as a diagnostic step. When something complicated isn't working a good first step is to remove some of the complication and make sure the base works. Once that's confirmed then you can re-complicate things knowing you're on a sound foundation.

    The UI thread is not directly dependant on the package it is called from: runtime components can use the UI thread or other threads. See Raising Events in Windows Runtime Components for some suggestions around this area. While your case isn't raising an event, the initial call to FromIdAsync will have the same restrictions since it needs the UI thread to show the consent UI.

    --Rob

    Monday, February 10, 2014 4:51 PM
    Owner
  • Hello

    I wrote a small app in C# and it can to my printer.  But I'm still getting a null for RfcommDeviceService in the WRC that is part of my JavaScript project.  I'm pretty sure the problem is that the manifest information in the main app for defining the serial port isn't being used in my WRC.  I would like to try doing the bluetooth serial ports calls in my JavaScript.  If you could point me to a JavaScript sample that does bluetooth serial port calls, that would be a big help.

    John

    Tuesday, February 11, 2014 9:29 PM
  • I searched the sample gallery for rfcomm and found the Bluetooth Rfcomm Chat sample. That will demonstrate the JavaScript side.
    Wednesday, February 12, 2014 6:19 AM
    Owner
  • Hello

    Thanks for the response.  Been using this example, but really need a serial port example.  Ideally it would be nice if I could figure out why my c# WRC can't talk to my bluetooth device.  But my small c# program can.  I think it's a problem with the manifest or not running on the UI thread.

    John

    Wednesday, February 12, 2014 4:19 PM
  • I'm not aware of any samples, but you can perform your own search.

    You should be able to confirm in the debugger the thread your initial call runs on.

    You can also confirm your manifest in a C# app rather than a JS app or your WRC. Once you have it working there then move up to the component.

    --Rob

    Wednesday, February 12, 2014 8:31 PM
    Owner
  • Rob

    Again thanks for the reply.  I have it working in the small C# app I wrote.  Not sure about the thread, I'll check that.  I see the <m2:DeviceCapablity Name = "bluetooth.rfcomm"> in the appxManifest.xml that is built as part of the build of the JavaScript app.  But my rfcommservice is always null.  I'll do more searching for examples.  do you think it could be a thread issue.  Will the WRC run on a different thread then the JavaScript app?

    John

    Wednesday, February 12, 2014 11:28 PM
  • Hello

    I'm pretty sure my rfcommdeviceservice isn't running on the UI thread and that is my problem.  I'm going through all the thread discussion but haven't found an answer to my problem.  How do I run this from my WRC on the UI thread.

    John

    Thursday, February 13, 2014 4:22 PM
  • See Raising Events in Windows Runtime Components for some suggestions around thread handling and a few different ways to get onto the main app's UI thread. While your case isn't raising an event, the initial call to FromIdAsync will have the same restrictions since it needs the UI thread to show the consent UI.

    --Rob

    Thursday, February 13, 2014 8:37 PM
    Owner
  • Hello

    I have an html JavaScript app that has been ported over.  It doesn't have a WinJS name space.  I'm trying to connect to a bluetooth device but I keep get null.  I think there is a problem with the UI thread.  How do I access the thread?

    Thanks

    John

    Tuesday, February 18, 2014 1:34 AM
  • Hi John,

    Did you look at the documentation I linked on threading? If you're having trouble following it please let us know exactly what you tried and in what way it isn't working for you.

    --Rob

    Tuesday, February 18, 2014 2:26 AM
    Owner
  • Rob

    Thanks for your continued help.  Feel I've been bouncing around my real issue but feel I'm getting closer.  I think my issue has to do with the UI thread.  I have a JavaScript app running under VS 2013.  I'm trying to connect to a devices bluetooth serial port.  As suggested I've moved the calls to bluetooth to run in the JavaScript.  So now the calls are in the app not in the WRC.  The findAsyncid get a null every time.  I'm pretty sure that because it's not running on the UI thread and because of this not passing the security it needs.  So the questions are these, do I need to access winjs to have an UI thread that findasync can talk to.  Or am i out of my mind and the UI thread is there on a straight JavaScript app.  I have all this working in a small C# app I wrote so I know I can talk to the device.  Sorry about be long winded, very fustrated at this point.

    John

    Tuesday, February 18, 2014 3:03 PM
  • Hello

    Getting no such service known.  The service cannot be found in specific name space.  I'm getting this when I call RfcommDeviceService.fromIdAsync.  Any idea?

    Thanks

    John

    Tuesday, February 18, 2014 6:37 PM
  • The first call needs to be on the UI thread to bring up the permissions dialog. Are you seeing that?

    Your JavaScript call should be on the UI thread unless you're doing something specifically to avoid it. The documentation I linked explains several techniques for getting back onto the UI thread from your runtime component in case it's off.

    If you make your call directly from a button click you know for sure you're on the UI thread.

    --Rob

    • Marked as answer by dontcallmejeff Wednesday, February 19, 2014 4:34 PM
    Tuesday, February 18, 2014 7:23 PM
    Owner
  • Rob

    Thanks for the response.  I come back hat in hand because it was a something I've been battling for a week and it was stupid mistake.  In my defense I've been doing .net development for many years, but with Windows 8 there seems to be a lot of moving parts.  I was getting null when I called RfcommDeviceService.fromIdAsync.  Different threads here made me believe I had a manifest problem or a thread problem.  Since my app was a ported over JavaScript, HTML5 and not a WinJs app I thought that might have been the problem.  I wrote a small C# program that had no problem talking to the Bluetooth device.  Rob is correct that I got the permission dialog with the C# program but never realized that I didn't get with the JavaScript app.  I did finally figure this out on my own, but will mark it answered.  Even through I had paired the Bluetooth device to the laptop, the JavaScript app was marked no on permission and the C# app was marked yes.  I don't think I ever got the permission dialog on the JavaScript app  Once changed my C# WRC could talk fine with the Bluetooth printer, no thread issues, no manifest issues.  Live and learn.

    John

    • Marked as answer by dontcallmejeff Wednesday, February 19, 2014 4:34 PM
    • Unmarked as answer by dontcallmejeff Wednesday, February 19, 2014 4:34 PM
    Wednesday, February 19, 2014 4:34 PM