I need to use Windows.Storage.Streams and Windows.Devices.Enumeration in my Winforms application on Windows 7 to access and manipulate Barcode reader, but unable to find it to Add Reference. Not sure if can download it somewhere. I was able to find and download Microsoft.PointOfService and added reference to my project, but not the first two libraries.
Please advise.
The Windows.Storage.Streams and Windows.Devices.Enumeration namespaces are part of the Windows Runtime. To use them you need to target Windows 8 or above. They aren't available when targeting Windows 7.
How to access the Windows 10 APIs from WPF
You can access the Windows 10 APIs from a pre-existing WPF project. To do so, go to your Solution Explorer window and …
Right click on References.
Select “Add Reference…” from the context menu.
On the left of the Reference Manager, choose Browse and find the following file: C:/Program Files (x86)/Windows Kits/10/UnionMetadata/Windows.winmd.
Add it to your project as a reference. Note: You will need to change the filter to “All Files”.
Right click on References. Select “Add Reference…” from the context menu. On the left of the Reference Manager, go to Browse and find the directory “C:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/.NETCore/v4.5”. Add System.Runtime.WindowsRuntime.dll to your project.
Learn More Calling Windows 10 APIs From a Desktop Application
Just to be helpful to others that arrive here through Google, Microsoft has some NuGet packages to access Windows-specific APIs like that without the need to import or reference Windows libs manually. More info can be seen on their documentation here.
For those trying to use it from Windows 8/8.1, add a reference (like Sajeeb's answer) to the files at 32-bit C:\Windows\System32\WinMetadata or 64-bit C:\Windows\System32\WinMetadata respectively.
I believe those namespaces are not part of Windows Apps libraries. I don't think a WinForm project is able to use them. Personally, I don't have newer versions of VS, so I am not sure of that. But there is supposed to be a new project type in VS2015 onwards.
Related
I'm working on a windows Phone OLD application. I'm getting this issue related to SQL3.dll. in visual 2015.
Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
What I've tried, Done Cleaning all project, added sqlite.dll in Bin/debug folder, but I could not overcome this issue.
here is a screenshot.
I've tried adding a dll as reference (sqlite-winrt-3220000.vsix) but this is not compatible.
Any help would be appreciated.
Add the dll as a reference:
Right-click in "References" in the project you want to use it in and select "Add reference".
Select the option "Browse" and use the browse button to select the dll you want to include.
Add a using statement to the class.
After this you can use the dll in the project.
I've tried adding a dll as reference (sqlite-winrt-3220000.vsix) but this is not compatible.
SQlite is distributed as a VS extension. To add reference to your project, right click on References, “Add References”, “Windows Phone 8”, “Extensions”, check “SQLite for Windows Phone”, press OK.
No other steps are required, you don’t need other references and you don’t need to specify or deploy DLLs manually.
Also sqlite has different extension for WP8.1, you should probably install another one, sqlite-wp81-winrt-3220000.vsix.
Update: I think you’re trying to build for a platform that’s unsupported by SQLite library. SQlite for windows phone only supports 2 platforms, intel 32 bit (for emulators) and ARM (for devices and for the marketplace). It does not support AMD64, and it does not support “Any CPU”. You’re probably trying to build “Any CPU”, it’s usually the default platform for .NET.
Another possible reason is wrong project type. Your project has to be windows phone 8.1 app, not universal, i.e. the project name in the solution explorer panel must end with ”(Windows Phone 8.1)”
Update 2: I’ve compiled a simple app that uses sqlite, run it in emulator and it worked flawlessly on my PC. Ensure your references look like this:
If you have the same, make sure you have VS 2015 Update 3 installed. If you already have it, repairing your visual studio installation might help.
As the title says, what is the preferred way to add the Mobile Broadband API to my C# WPF application?
Steps that worked for me. The file you're looking for is mbnapi.tlb which for me (I'm on Windows 8) is located here:
C:\Program Files (x86)\Windows Kits\8.0\Lib\Win8\um\x64\mbnapi.tlb
There are a few different folders where you could find this file to work with OS versions (8.0, 8.1, ...) and processor architectures (x86, x64, ...).
Once you have located that file use the normal procedure to reference it in Visual Studio:
Click the Project item in the toolbar, and then click Add Reference from the drop-down menu.
From the Add Reference page, click the Browse tab.
Browse to the Mbnapi.tlb file and select it. Then, click OK.
Reference: http://download.microsoft.com/download/7/E/7/7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2/MB_ManagedCode.docx
Is there a way for me to reference to a class library project, which is in the same solution as my windows form application ?
There are 5 windows form applications in my solution with one class library. Is it possible for me to reference to the class library without building it separately and copying the DLL each time.
Screen shots are for VS 2013
The steps to follow work for pretty much all versions
Right click the References section in the solution explorer of the project you want to add the dll to
Select Add references, select "Solution" on the left hand side
You should see your project, check it to add a reference that will always be the latest compiled version of that project.
See MSDN for more on the Add References dialog
I'm using VS 2012 and I need to write code that uses the classes in the Windows.Devices.Gelocation namespace. I downloaded the sample program but it won't load in VS2012 as it requires VS 2013. And the documentation for the class does not indicate which DLL that namespace is in.
Can someone tell me which DLL contains that namespace? Is it available in .NET 4 or do I have to use .NET 4.5?
Edit
My project is a console application which runs in the background as a Windows service. The searching I've done indicates that I have to target Windows 8 by using the Reference Manager's Windows Tab. But there is no Windows tab in the Reference Manager in my project because it's not a Windows Store application. Is there a way to use this API from a desktop application???
I've found how to reference the assembly I need.
On this page, under the section Windows Tab, in the Core Subgroup subsection, the third paragraph gives instructions on how to reference the needed windows assemblies from desktop applications. To summarize it:
Unload the project to which the reference will be added.
Edit the .csproj file for the project.
Add the following snippet anywhere in the .csproj file:
<PropertyGroup>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
</PropertyGroup>
Save the edited .csproj file.
Reload the project.
At this point, when you open the Reference Manager dialog, you'll see a Windows tab on the left. Click that, and you'll see the Core subgroup. To the right, it'll say "Targeting Window 8.0" and under that "Windows version 255.255.255.255" will be unchecked. Check it off then click OK & you're done.
I'm trying to follow this tutorial about WP7 development: http://mobile.tutsplus.com/tutorials/windows/introduction-to-windows-mobile-7-development/
It's talking about using XElements, which require the System.Xml.Linq library, but I can't find a way to add it to the project references. When I go to add reference, the .NET list is empty, and it's saying it's filtered to Windows Phone 7.
The tutorial might be out of date. Is the library even available for WP7? Is there a different way to read XML on the platform?
How can I get it working?
EDIT:
The same problem is described here:
http://forums.netduino.com/index.php?/topic/1127-add-reference-net-tab-empty/
The suggested fix doesn't work for me.
EDIT:
Apparently this is a bug in the Silverlight 4 Tools:
https://connect.microsoft.com/VisualStudio/feedback/details/529718/empty-net-tab-when-adding-a-reference
That is the correct Assembly you need to work with XML in Windows Phone 7. Not sure why it does not show up in your Add Reference dialog.
It should be like following:
What version of WP7 developer tools are you using?
The assembly list should not be empty when adding a reference from the .NET tab even for a Windows Phone 7 project, so it sounds like you might have an issue with Visual Studio.
However, you could try using the Browse tab instead. On my system (64-bit), the assembly is in the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone folder.
Yes, LINQ to XML is definitely available for Windows Phone 7. If you aren't seeing any available references to add, that sounds like your development environment is a little bit messed up...