Missing System.Media.Capture.Frames namespace - c#

I'm trying to develop a barcode reader app for the Microsoft HoloLens (using this tutorial) but I'm encountering a problem. In the code of this tutorial, there's being referenced to the System.Media.Capture.Frames namespace and it seems like I'm missing this namespace. Looking at the Windows universal samples from Microsoft, there's also being referenced to this namespace. However, I cannot import this namespace.
I'm running on Windows 10 Version 1607 Build 14393.693
I have .NET Framework 4.6.2
My Windows is fully up-to-date
Does anyone have any idea how I can get access to this namespace?

Two likely problems:
You need Windows.Media.Capture.Frames not System.Media.Capture.Frames
Windows.Media.Capture.Frames is new for build 14393 so you'll need to make sure your app targets at least that high:
Go to your app's project properties and make sure your target version is set to Build 14393 on the Application tab. Alternatively open the csproj in a text or XML editor and set the TargetPlatformVersion there:
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
If your minimum version is less than 14393 then make sure you do feature detection with the ApiInformation class before calling the Frames functions to make sure they exist.

Related

How to reference .Net 6.0 project from WinUI 3 project?

I have a .NET 6.0 C# class library project that contains platform-independent code (let's call this BusinessLogic). In my same solution, I would like to create a project for a WinUI 3 app that references this class library (let's call this WindowsApp). I would also like to create a class library specific to the Windows platform (so I can access the Windows.Storage namespace from within that class library, for example... let's call this WindowsOS).
I get an error when attempting to set this up. I have tried two techniques:
First technique
Create a .NET 6.0 C# class library WindowsOS.
In WindowsOS project, add reference to BusinessLogic. No problem.
In WindowsOS project, install NuGet packages Microsoft.Windows.SDK.BuildTools and Microsoft.WindowsAppSDK. This gives me an error about numeric comparisons on the target platform, similar to the one described in this GitHub issue. Afterwards, the project becomes unloadable in Visual Studio.
Second technique
Create a Class Library (Universal Windows) project WindowsOS.
In WindowsOS project, add reference to BusinessLogic. This gives me an error immediately, simply refusing to allow the reference to be added.
I suspect there appears to be some compatibility issue going on. I reviewed the Microsoft docs on .NET Standard versions, as well as this helpful StackOverflow question about .NET Core vs .NET Standard class libraries, and from what I can tell UWP may not be capable of referencing .NET class libraries.
My end goal is to create a WinUI 3 desktop app that references these cross-platform class libraries. My common code is contained in these libraries, and I may make an Android app or other platform app in a separate project that also references these same cross-platform class libraries. How do I do this?
EDIT: Here is a screenshot of the error from technique #1:
I figured out the answer. In the Visual Studio project properties (screenshot below), there is a Target OS property. That property defaults to (None).
Given the names of the projects in the question, set the property accordingly:
Set the property value to Windows in the WindowsOS project. This will give access to Windows-platform specific namespaces (such as Windows.Storage). WindowsOS can still have a project reference to BusinessLogic (and any .NET 6.0 C# library) as before.
No change necessary to the BusinessLogic project properties.
The WindowsApp (WinUI 3) project also requires no changes, and can reference BOTH the WindowsOS project (which now has a Target OS of Windows) AND the BusinessLogic project (which still has a Target OS property of (None).
Something to keep in mind: the WindowsApp project and the WindowsOS project will now both have Target OS version and Supported OS version properties. If you set these to different values in each project, you will get compiler warnings about a potential conflict (a user could install the app with a lower version of Windows, but that app then references the library which may require a higher version of Windows than the user has, for example). This does not matter if you are only using APIs supported in BOTH versions of Windows, but to be safe make sure these are consistent between your projects.

Why is Desktop bridge creating a .msixupload bundle when it used to create a .appxupload?

I am using VS2017 15.9.6 with an XAF Winforms application and Desktop Bridge.
At one point I was able to create a .appxupload package to upload to the store however now I can only create a .msixupload bundle
The docs dont seem to explain the difference.
I am using Create App Packages, by right clicking the Packages project.
I don't think I changed anything in the manifest.
I tried Release (Any CPU) and Release (x64)
The solution is Framework 4.7.2 I also tried 4.5.1
This MCP Mag article explains that
MSIX is Microsoft's planned replacement for the MSI and AppX formats.
However this does not help me understand why one of my projects has flipped to using it when other projects have not.
Looks like it has to do with the minimum version of Universal Windows.
I had changed the target min version from Creators update 15063 to Windows 10 version 1809 Build 17763
VS2017 15.9 added support for MSIX when targeting Windows SDK 1809 (17763) as described in the release notes
You should not worry about .appxupload vs. .msixupload, since the store accept both and clients running 1809 won't see any difference between one or the other.

Can I reference a .NetStandard library from my Windows 10 UWP app?

There are TONS of posts, blogs, articles, etc... explaining all of this confusing stuff with regard to .Net/.NetCore/.NetStandard and I have read many of them.
Here is the issue, I have a Windows 10 UWP app and I need to reference a library that I created. I first created the library as a NetCore library but I could not reference that from my UWP app (which is confusing because UWP uses .Net Core but the .Net Core library I created assumed this was for ASP.NET?).
So, then I tried to create the library as a PCL library and targeted ONLY Windows 10 UWP (which it then forces you to Windows 8.1 because they are the same). With this type of library I am confident I would be able to reference it from my UWP app but it caused me to lose too many .Net namespaces that I could not get the library to build.
Finally, I then selected the link, in the project properties, to target the .Net Standard instead. I selected .Net Standard 1.4 and suddenly, I had all the namespaces I needed available to me and I was able to build my library. I am also able to successfully add it as a reference to my UWP app.
However, I am getting the following 6 exceptions and they don't tell me too much about the root cause so I can fix it.
So, my main question is, can you reference a .Net Standard 1.4 library in your UWP app? Second, any ideas what these exceptions mean?
Thanks!
EDIT - I have uploaded both csproj files here:csproj files
Okay, I found that answer but it was based mainly on this answer which I did not see before posting my question due to search terms (I have literally spent over a day searching and trying to find an answer).
Answer that helped:
Here is a summary:
.NetStandard 1.4 is supported by UWP.
By default, VS 2015 Update 3 template for a UWP project imports Microsoft.NetCore.UniversalWindowsPlatform version 5.1.0. I am sure the VS 2017 template will start off with a newer version, 5.1.0 is fairly old. So, based on the answer linked above, I updated (using NuGet) to the newest version allowed by VS 2015 Update 3 which at the time of this answer, is version 5.2.3. There is a 5.3.x version but it requires VS 2017.
Finally, I modified the project.json in my UWP project to import the netstandard1.4 framework. It looks like this:
"frameworks": {
"uap10.0": {
"imports": "netstandard1.4"
}
And, with those simple steps, I can get the UWP project to build and those 6 errors above go away.
Hope this helps!

LiveSDK 5.6.3 not working in UWP store app

I have a universal windows store app targeting Windows 10. In a previous version of the app targeting Windows 8.1 I used the LiveSDK (the 5.6 version here) to access data from the user's MS Live account using the LiveAuthClient. In the new version of the app, I figured I'd use the most recent version of the LiveSDK (5.6.3 available as a nuget package here) but when I install the nuget package, I am unable to to access the Microsoft.Live namespace.
For example, the following statement:
using Microsoft.Live;
Produces the error "The type or namespace 'Live' does not exist in the namespace 'Microsoft'"
Is this package broken or am I missing something obvious here? I would have expected this to work just like it did with the 5.6 version of the LiveSDK. It also seems like the documentation for the LiveSDK is all pointing to info about the OneDrive api now so it makes me wonder if the purpose of the sdk has changed. I'm confused... What's the most recent version of the LiveSDK (the one that has the LiveAuthClient) and where can I find it?
I'm not sure why Nuget Manager doesn't add a reference automatically, but it seems to work once you add a reference manually from directory:
C:\Users\USER\.nuget\packages\LiveSDK\5.6.3\WindowsXAML\MicrosoftLive.dll.

Prexisiting dlls (.NET 4 framework) issue with mono for android

I am creating a fresh Mono for android application using http://xamarin.com/monoforandroid
I selected Mono for Android Application using Visual C# option.
My Android target version is :
I went to references of the project and tried adding my pre existing dlls (made in .NET 4 Framework)
and I got this error:
The strange stuff is there is no option to change the .NET Framework from project properties. Can you tell me what I am missing?
The problem here is that you're trying to reference a .NET 4 DLL from a project that isn't .NET 4. Mono for Android uses its own profile for .NET, which is very similar to that of Silverlight (but not exactly the same). While it's possible that adding a DLL compiled for a different profile will work, it's very risky as you will probably run into problems at runtime where your app will crash, due to something being missing from the Mono for Android profile.
The best answer right now is to create a Mono for Android class library, link in the appropriate files from the library you want to use, and reference that. This will give you compile-time checking that you're not using anything unsupported by the Mono for Android profile, and help keep you more sane in the long run. I have an old blog post up here that talks about how to link files across projects.
That said, in this case you're in luck because someone else has already done that last part for you! Check out this fork of Json.NET which provides versions for MonoTouch and Mono for Android.
The strange stuff is there is no option to change the .NET Framework from project properties. Can you tell me what I am missing?
It's not particularly strange - that dialog box was written by Microsoft, with its own project types in mind. It sounds like Mono for Android doesn't have the same options available.
I strongly suspect you'll just have to use a version of JSON.NET targeting .NET 3.5.
(Having said that, Mono for Android claims to support "dynamic language features" which sounds like it should be targeting .NET 4. Odd. I suspect the fix is the same though.)

Categories

Resources