

You must add a reference to assembly ‘System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.” But when you go to the Add Reference dialog, you won’t see it! It’s telling me to add a reference to an assembly that doesn’t exist!
#Microsoft Surface Serial Number Lookup windows#
If you use a Windows Runtime class that projects as an IDictionary or some other fancy type, then you will get the error message “The type ‘IDictionary`2’ is defined in an assembly that is not referenced. The last bit is another obscure piece of information on MSDN: Adding a reference to System.Runtime. Repeat for each contract your program requires. That documentation also says that the SmbiosInformation class was introduced in v1, so the minimum version I need is 1.0.0.0. I got this information from the documentation for the SmbiosInformation class: Look under API contract. Blah namespaces under Core, go to the Browse option and browse to C:\ Program Files (x86)\ Windows Kits\ 10\ References\ CONTRACT\ VERSION\ CONTRACT.winmd. If you are doing cross-targeting, then instead of referencing the Windows. In general, check each second-level namespace your program uses.Īdding a reference from Core will access the information from your development machine, so it assumes that your development machine is running the same or greater version of Windows than your target. Expand it, click on Core, and then check Windows. The magic XML you added to the *.csproj enables a new node in the dialog box called Windows. Reopen the project, right click the References node and select Add Reference. This requirement is obscurely documented on MSDN. ($"Serial number = ") īefore building, you’ll have to prepare the project, and the preparation is particularly ugly.Ĭlose the solution in Visual Studio and open the *.csproj file in a text editor.
#Microsoft Surface Serial Number Lookup series#
Continuing our series on getting the computer’s serial number in desktop apps in various languages, we look at C#.įrom Visual Studio, create a new C# Console Application that goes like this:
