ASStream extension method not found - windows

I am trying to write a metro style application to read data from a TCP stream. I am using Visual C++.
The problem is that the ASStream extension method cannot be found.
I have the following directives:
#using <System.Runtime.InteropServices.WindowsRuntime.dll>
using namespace System::IO;
using namespace System::Runtime::InteropServices::WindowsRuntime;
ASStream is supposed to be part of WindowsRuntimeBuffer class in the System.Runtime.InteropServices.WindowsRuntime namespace. But object browser clearly does not show that class in the System.Runtime.InteropServices.WindowsRuntime namespace.

Only native C++ is supported for Metro style applications. C++/CLI is not supported and the .NET Framework is not directly supported from a native C++ component.

Related

error CS0234: The type or namespace name 'Persistence' does not exist in the namespace 'UnityEngine.XR.WSA' (are you missing an assembly reference?)

I'm currently developing an app for android. In my code, I use the namespace UnityEngine.XR.WSA.Persistence. When I'm launching the app on the editor, i have no errors, but when I try to build this to send it to my phone, I get the following one :
The type or namespace name "Persistence" does not exist in the
namespace "UnityEngine.XR.WSA". Are you missing an assembly
reference?"
Isn't it strange since it's working on the editor? How do i fix it?
WSA stands for Windows Store Apps. This is only available when building apps for Universal Windows Platform. Especially UnityEngine.XR.WSA.Persistence afaik is or at least was previously developed by Microsoft and is even only used in particular for the HoloLens.
It throws no exceptions in the Editor but afaik some #if preprocessors make sure that it also does nothing there.
It is not available when building an App for Android platforms.
To remove the error in your script you can use #if preprocessors and Platform dependent compilation like
#if UNITY_WSA
// anything using the UnityEngine.XR.WSA namespace
#else
// alternative implementation for different platform
#endif
however, the functionality ofcourse will not be available on Android so if you need something similar you have to use another library or come up with one ;)

How do your write Xamarin platform specific code in a .net standard library?

How do your write Xamarin platform specific code in a .net standard library?
I want to use namespaces like Xamarin.Forms.Platform.iOS in a .Net Standard Library..
Use case: I want to develop a .net library for my apps which includes a video player for the various platforms. This video player also has to interact with other code in the .net library.
Or is the answer I need to use a shared project or portable library?
You should not include platform specific code or use namespaces like the one you mentioned in your .NET Standard Library, the reason is that .NET is just a runtime environment.
It’s not the the main runtime environment that you would use on iOS or Android. These platforms use Mono - not .NET. Check this or this to see more details for how its structured.
If you need to execute something from your .NET Standard project which is related to platform-specific behavior, use Dependency Injection or Custom Renderers.

Xamarin Shared Library and PCL

What is the exact difference between xamarin shared project and portable class library?
When to use shared library and when to use portable class library?
Is this possible to write native functionality in shared projects like showing alert,accessing camera and use it for both android and iOS?
Can anyone please explain me.
In shared projects each code file will be compiled for each destination (Android, iOS, Windows Phone etc). You are able to include platform specific code by using #if compiler directives.
When you want to access the camera you need to write the access code inside an #if block for all destinated platforms. This can mess up your code but it can be easier to find the different implementations.
Learn more: http://developer.xamarin.com/guides/cross-platform/application_fundamentals/shared_projects/
Protable Class Libraries (PCL) are compiled against a general .NET subset which is compatible to all platforms you want. So you can access System.Net.Http but you cannot access any platform specific code. If you want to access the camera inside the PCL code then you need to access it by a generalized interface via dependency injection. There are some pretty good frameworks helping you to archieve this goal. One of the most famous is MVVMCross (https://github.com/MvvmCross/MvvmCross/wiki). Learn more about PCL: http://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options/#Portable_Class_Libraries
I personally perefer PCLs because the code is much easier to read without any compiler directives. Using MVVMCross you are able to use plenty of plugins via NuGet. So you don't need to write your own classes for camera access, showing alerts etc.

Cannot resolve System.Linq namespace

Working in a standard visual studio 2013 web app, I realized that it seems not possible to resolve the System.Linq namespace, e.g. on
mylist.Sum(...)
in a class when using System.Linq is missing in the code. You have to add
using System.Linq
manually, which is possible (references are added to project). What is the reason for this?
All the LINQ methods are extension methods. The compiler only knows which extension methods you're interested based on which using directives are present in your code, e.g.
// Imports extension methods from all static classes in the
// System.Linq namespace
using System.Linq;
// C# 6 only: imports extension methods from System.Linq.Enumerable only
using static System.Linq.Enumerable;
That's just how extension methods work... it's not LINQ-specific.

how do you execute silverlight class library?

When execute the silverlight class library,debugging(F5) is disable.how do I test whether my class library is right?Silverlight class library is only reusable class and components from other project?
how can share the code between the different class libraries by linking source code files between them in silverlight application??
you need to write a demo or test project to exercise the code in your library. typically, from within the project you want to use your library in, you add a reference to the assembly that contains the classes that you want to use. now, for silverlight, you are only allowed to use libraries/assemblies that are silverlight libraries--you are not allowed to use the "normal" windows class libraries.

Resources