CarouselView Xamarin Plugin not working - xaml

I am getting the following error:
Error CS0234: The type or namespace name 'CarouselView' does not exist
in the namespace 'Xamarin.Forms' (are you missing an assembly reference?)
(CS0234) (your project)
Using this on the XAML
xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
Name of the package is: CarouselView.FormsPlugin.
Update......
xaml

As per the project documentation on GitHub, there are several steps you need to do to enable the plugin:
Install the package via NuGet
Initialize the plugin
On Universal Windows Platform include with Xamarin.Forms initialization:
List<Assembly> assembliesToInclude = new List<Assembly>();
assembliesToInclude.Add(typeof(CarouselViewRenderer).GetTypeInfo().Assembly);
Xamarin.Forms.Forms.Init(e, assembliesToInclude);
On iOS and Android right after Xamarin.Forms initialization:
Xamarin.Forms.Init();
CarouselViewRenderer.Init();
Use in XAML
For XAML usage, you need to include a different namespace (CarouselView.FormsPlugin.Abstractions) than you noted in the question:
xmlns:controls="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
And now use as:
<controls:CarouselViewControl ...>

Related

How can I get ApplicationPartAttribute within .net5 class library?

The task is not practical, it's just learning experiment.
I have .net5 app (which essentially is asp .net core app) which references onto neighboring project "WebControllers" which contains only Controller class.
WebControllers is .net5 class library into which I added reference to Microsoft.AspNetCore.Mvc.Core package. This package allows to create of working Controller object which is discovered by asp .net core infrastructure and which properly handles http requests.
Now I want inside my WebController objec create variable of ApplicationPartAttribute type. I tried doing this like that:
var aaa = new Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartAttribute("asd");
But Visual studio says to me that it don't know ApplicationPartAttribute class and it doesn't offer to use some namespace or add some package.
Let's go to the MSDN. MSDN about this type for .NET5 says:
Namespace: Microsoft.AspNetCore.Mvc.ApplicationParts
Assembly: Microsoft.AspNetCore.Mvc.Core.dll
Package: Microsoft.AspNetCore.App.Ref v5.0.0
Okay, let's try to install this package. Next errors are occured:
NU1213 The package Microsoft.AspNetCore.App.Ref 5.0.0 has a package
type DotnetPlatform that is incompatible with this project.
Package 'Microsoft.AspNetCore.App.Ref 5.0.0' has a package type
'DotnetPlatform' that is not supported by project 'WebControllers'
Why these errors are occured is unclear to me because both projects are .net5 projects and Microsoft.AspNetCore.App.Ref v5.0.0 is designed for .NET 5.
The question is: how can I use ApplicationPartAttribute in .net5 class library?
Add this code in your xxx.csproj file
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
</ItemGroup>

Adding a custom font in Xamarin

According to this post: https://devblogs.microsoft.com/xamarin/embedded-fonts-xamarin-forms/
The new way to add a custom font is to add the font as an embeddedResource and then add this line in App.xaml.ca:
[assembly: ExportFont("DSEG7ModernRegular.ttf")]
But I get this error:
Error CS0246 The type or namespace name 'ExportFontAttribute' could not be found (are you missing a using directive or an assembly reference?)
My project references:
Xamarin.Essentials (1.3.1)
Xamarin.Forms (4.4.0.991265) - 4.5
NetStandard.Library (2.0.3)
ExportFontAttribute is in the Xamarin.Forms namespace, so be sure you have
using Xamarin.Forms;

Is EmbeddedFileProvider or ManifestEmbeddedFileProvider available in ASP.NET Core 2.1?

I have seen references in documentation ( https://learn.microsoft.com/en-us/aspnet/core/fundamentals/file-providers?view=aspnetcore-2.1 ) to EmbeddedFileProvider and ManifestEmbeddedFileProvider as a way of accessing embedded resource files in my assembly via the IFileProvider interface, but when I try to use either of them I get "Error CS0246 The type or namespace name 'ManifestEmbeddedFileProvider' could not be found (are you missing a using directive or an assembly reference?)" and the only options in VS alt+enter menu are to generate the class.
I have already specified using Microsoft.Extensions.FileProviders; and PhysicalFileProvider is certainly available, but not the embedded ones.
If they are supposed to be usable in 2.1 how do I make them available to my project?
You need the following NuGet package: Microsoft.Extensions.FileProviders.Embedded.

Xamarin namespace issues in XAML files when changing startup project in VS

I have issues with Xamarin in Visual studio 2017 15.8.0 Preview 4 (And all previous builds)
I have a Xamarin forms project with a Android Project and a UWP project, if I change the startup project to UWP and try to compile I get this error
Error Failed to resolve assembly: 'FoosballXamarin.Android,
Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' FoosballXamarin.UWP ...\Views\LoginPage.xaml
And the XAML itself will give me errors on these lines
xmlns:viewModels="clr-namespace:FoosballXamarin.ViewModels;assembly=FoosballXamarin.Android"
xmlns:helpers="clr-namespace:FoosballXamarin.Helpers;assembly=FoosballXamarin.Android"
And want me to change them to
xmlns:viewModels="clr-namespace:FoosballXamarin.ViewModels;assembly=FoosballXamarin.UWP"
xmlns:helpers="clr-namespace:FoosballXamarin.Helpers;assembly=FoosballXamarin.UWP"
Is there a way to write it differently so I dont get this error every time?
Based on the errors you're seeing, I'm going to guess you have this configured as a shared project (not PCL/.netstandard). If that's the case, simplify the lines in the XAML file to:
xmlns:viewModels="clr-namespace:FoosballXamarin.ViewModels"
xmlns:helpers="clr-namespace:FoosballXamarin.Helpers"
In other words, just remove the assembly= part. If you don't specify the assembly on the xmlns line, it will assume the namespace is the same assembly as the XAML file. So you only need to include it if it's in a different assembly.
Since shared projects include the XAML file in multiple assemblies (one per platform), you pretty much have to omit the assembly= on the xmlns declaration for namespaces/types in the same assembly.

System.Web.Http.Description is missing from Add Reference List

I am getting an error:
Error 1 The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?) c:\users\klippiat\documents\visual studio 2010\Projects\TfsPortal\TfsPortal\Models\ApiModel.cs 5 23 TfsPortal
I would normally Add Reference and select the missing reference. But System.Web.Http.Description is missing from the list. I have sorted the list by name to make sure that I should be able to see it. I can see System.Web.Http.Data and .Common etc. but not the .Description one.
What am I doing wrong?
Visual Studio 2012 SPA Template /Help/index.cshtml file was throwing your error.
#using System.Web.Http
#using System.Web.Http.Description <=== CS0234: The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)
Solution: Set "Copy Local : True" in properties for References\System.Web.Http
You aren't doing anything wrong. There is just some configuration problem that prevents Visual Studio from adding the reference to the list of assemblies for the compiler to check.
Types in the System.Web.Http.Description are found in the System.Web.Http.dll assembly, which is found in a Nuget package folder.
You can type Uninstall-Package Microsoft.AspNet.WebApi in the NuGet Package Console and then type Install-Package Microsoft.AspNet.WebApi to re-install it at which point, the reference will be fixed.
I un-installed MVC4 and reinstalled from a fresh download. I had to create a NEW project again and the Description namespace appeared.
The strange thing is if I open the old project the Description namespace is still missing when I try to add a using...
I was also facing the same issue when while creating a SPA solution by using MVC-4 framework.
I resolved this by setting the Copy Local : True in properties for the reference System.Web.Http.
I had the same problem. I was opening the project as a website instead of project/solution. So, after opening the solution it solved my problem.