locked
Device meta data in Windows 8.1

    Question

  • I have created device meta data for printer in Windows 8.1 using Metadata authoring wizard and I am trying to associate this with a Windows Store device app written in Visual Studio 2013 Preview. This sample device app  is the one downloaded from Windows 8.1 samples collection at http://code.msdn.microsoft.com/windowsapps/Print-job-management-and-8245e020. But I am not able to associate meta data with the app though meta data creation is success. When I get the package family name of the connected usb printer in code , it is null so it does not match with the package family name of the app. I tried a number of times but the issue persists. This problem was not there in Windows 8 and there I was able to associate device. It is also seen that the meta data created is getting associated with ndevice app thereby matching with the package family name of that app. So association with my app fails. Has anyone come across such issue in 8.1? Any work arounds?

    Monday, July 22, 2013 5:28 PM

Answers

All replies

  • its_me_here,

    Do you get any error codes?

    Best Regards - Eric


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, August 1, 2013 3:49 AM
    Moderator
  • Thanks Eric for replying. No, I am not getting any error codes. The things is the device is associating with another app and not with my app(HP Printer Control app ). The device should associate with my app. But instead it is assonating with HP Printer Control whose meta data is automatically downloaded when the printer is connected. It worked correctly on Windows 8.

    Please find the relevant code in the sample:

    async Task<bool> IsDeviceContainerAssociatedWithAppAsync(string deviceContainerId)
            {
                // CreateFromIdAsync needs braces on the containerId string.
                string formattedContainerId = "{" + deviceContainerId + "}";
    
                // Retrieve the 'package family name' property from the device container which tells
                string packageFamilyNamePropertyName = "System.Devices.AppPackageFamilyName";
                string[] propertiesToRetrieve = new string[] { packageFamilyNamePropertyName };
    
                // Asynchoronously retrieve the device container information.
                PnpObject deviceContainer =
                    await PnpObject.CreateFromIdAsync(PnpObjectType.DeviceContainer, formattedContainerId, propertiesToRetrieve);
    
                // If the packageFamilyName of the printer container matches the one for this app, the printer is associated with this app.
                string[] packageFamilyNameList = (string[])deviceContainer.Properties[packageFamilyNamePropertyName];
    
                if (packageFamilyNameList != null)
                {
                    foreach (string packageFamilyName in packageFamilyNameList)
                    {
                        if (packageFamilyName.CompareTo(this.packageFamilyNameToMatch) == 0)
                        {
                            return true;
                        }
                    }
                }
    
                return false;
            }
        }

    Below is the relevant line:

    // If the packageFamilyName of the printer container matches the one for this app, the printer is associated with this app.
    string[] packageFamilyNameList = (string[])deviceContainer.Properties[packageFamilyNamePropertyName];
    The packageFamilyNameList[] array is filled with the package family name of HP Printer Control instead of the package famliy name of my app which I had provided during meta data creation.


    Friday, August 2, 2013 3:42 AM
  • its_me_here,

    You will likely need to do this on a system that is not connected to the internet to prevent the metadata download from the store.

    Best Regards - Eric


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, August 2, 2013 8:21 PM
    Moderator
  • Thanks Eric for your reply. But how can I make the device meta data associate with my app? It should be possible , right?  We cannot expect the machine to be always disconnected from internet.

    Monday, August 5, 2013 4:18 AM
  • its me here,

    Only one Device Meta Data can be associated with a specific printer in the general sense.  Are you writing the app for a printer manufacturer?  It might be possible to have a separate app per OEM if you could co-ordinate with the printer manufacturer and OEM.  What is the desired goal?

    Best Regards - Eric


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, August 5, 2013 6:59 PM
    Moderator
  • Thank Eric. Yes, I understand that there will be one app per printer. But I am talking about a test scenario( working with that sample app I mentioned ) . Has there been any change in meta data and association concepts recently? Now is it not possible to associate a device with my own app on Win 8.1? Or is it that the moment I connect a device , device meta data will be downloaded , if found, thereby preventing app association with my own app?

    Tuesday, August 6, 2013 4:00 AM
  • Yes,  Once you connect the device the device meta data will be downloaded preventing app association with your own app. 

    Best Regards - Eric


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 6, 2013 5:51 AM
    Moderator
  • it is me here,

    You may find this document helpful:  http://msdn.microsoft.com/en-us/library/windows/hardware/hh833785.aspx

    It explains how and when to update the driver, app and Metadata.

    Best Regards -Eric.


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 6, 2013 5:34 PM
    Moderator
  •       

    it is me here,

    Let me know if you have any follow up questions.

    Best Regards -Eric.


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 6, 2013 5:35 PM
    Moderator