How to get the same UUID in my app after project upgrade from c++/cx to c#?

KGabesz 1 Reputation point
2023-10-10T12:29:55.0433333+00:00

I am developing an UWP app for years. It is a C++/CX UWP app, and working well.

Now I decided to upgrade my VS to version VS2022, and upgrade my app as well. So I made a new C# UWP project, with the same name, and I would like to make the new version of my app in this new project and environment.

It looked like it works, I was able to associate my new project with the earlier version in the Store, everything looked like it will work, but there is one issue what I can not solve.

In my C++/CX app I used this code:

EasClientDeviceInformation^ deviceInformation;
_UUID = deviceInformation->Id.ToString();  

Then my app sent this _UUID to the server, this is the unique ID of the installed application instance.

Now in my new C# project I use the same:

EasClientDeviceInformation deviceInformation = new EasClientDeviceInformation();
_UUID = deviceInformation.Id.ToString();

But this _UUID is different. If I update the app, the UUID returned in this way is unfortunately different from the previous one. This is a security problem for me, my server won't let this new instance to login, because the UUID is different than the earlier. I tried to find the solution in everywhere, but I don't know how to step over. The documentation says:

The Id property represents the DeviceId using the GUID truncated from the first 16 bytes of the SHA256 hash of the MachineID, User SID, and Package Family Name where the MachineID uses the SID of the local users group.

In my case the MachineID, User, Package Family Name are the same, but the Id what I receive is different.

Please help me, this situation makes it impossible to rewrite my program despite all my efforts.

Developer technologies | Universal Windows Platform (UWP)
Developer technologies | C++
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-10-11T03:35:42.9533333+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I made a simple test here. I created a C# sample and a C++/CX sample. Both of them are associated with the same app in the Store. Actually, both of the UWP apps gives me the same ID value when calling EasClientDeviceInformation Object. But you might need to modify the value a little bit because the format is different.

    From the C++/CX sample, the string I got is {b3cf16ff-147d-df55-602f-e7e9973fc99c}.

    User's image

    From the C# sample, the string I got is b3cf16ff-147d-df55-602f-e7e9973fc99c.

    User's image

    The ID string from the C# sample lack "{" and "}" compared to the ID string from the C++/CX sample.

    I think this should be the reason for your behavior. Please take a look at the values you've got and check it.

    So, the solution is that you just need to add "{" and "}" in the beginning and the end of the string you get from the C# code.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.