Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

Insights reports crashes of Mono since update to the newest version

$
0
0

I'm having a weird problem since I updated to the latest version of Xamarin. My App is behaving normally but in Xamarin Insights I get reports of a crash.

I'm getting a System.ObjectDisposedException at Mono.Net.Security.MobileAuthenticatedStream.

The complete stack trace that Insights shows me is only 3 lines long, which is not very helpful. And although Insights reports a crash, the app itself is not crashing at all.

I searched the internet and StackOverflow but I didn't find a solution so far. Maybe anyone in here has experienced some similar issues or knows how to fix this.

Im currently using:

Visual Studio for Mac: 7.3 (build 797)

Mono: 5.4.1.7

Xamarin.iOS : 11.4.0.214

The link below stack trace is all i get from Xamarin Insights.

System.ObjectDisposedExceptionCannot access a disposed object. Object name: 'MobileAuthenticatedStream'.

null

System.ObjectDisposedExceptionCannot access a disposed object. Object name: 'MobileAuthenticatedStream'.
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Mono.Net.Security.MobileAuthenticatedStream.d__58.MoveNext()


Use azure on an existing application

$
0
0

Hello everyone,
Is it possible to use some azure service like Notification Hub without having a database on azure or azure mobile application ?
I would like our own current servers to send a notification (with Azure) after an adding an element to our database for example.
Thank you

ListView desperately needs a SelectedItemBackgroundColor property

$
0
0

It's a very basic thing, nobody wants an ugly grey (or blue) bar to appear as the background when you select an item in a ListView. It looks terrible from a UI point of view. Everybody has been implementing their own workarounds for this (custom renderers etc) but it is getting out of hand.

The ViewCellRenderer custom renderer approach works fine with a ListView with the default caching strategy ListViewCachingStrategy.RetainElement but it does NOT work if you set it to ListViewCachingStrategy.RecycleElement or ListViewCachingStrategy.RecycleElementAndDataTemplate .

If you need a different caching strategy you have to go one step further and create a custom ListViewRenderer and then assign your own UITableViewDelegate based delegate, and from there you need to override the WillDisplay method in order to eventually be able to set the selected item's background color to something that matches your app's color scheme. And after all this you'll find there are problems with the fact that you're replacing the "default delegate". (note: conversely and ironically this ListViewRenderer approach seems to work ok with a ListView that has a non-default caching strategy set but it does NOT work with the default caching strategy - in the latter case it doesn't pick up the ItemSelected event anymore). The problem with overwriting the default delegate is described here: https://forums.xamarin.com/discussion/42863/setting-delegate-of-control-in-custom-renderer-results-in-lost-functionality

The problem and various workarounds that people have been trying is summarised here (but still there are some problems as mentioned in paragraph above):

In short this is madness that each developer must go through all this pain for such a simple thing.

To solve all this a simple SelectedItemBackgroundColor property should be added to the ListView class. It won't be difficult to add the required code (just some code in the custom renderers will do the trick). Then we won't have to worry about all these custom renders or about how to handle the overwritten default delegate.

Xamarin.iOS 11.4.0 does not support a deployment target of 11.2 for iOS (the maximum is 11.1)

$
0
0

Since the last iOS and Visual Studio Mac update, I'm getting the following error when trying to build:

Error Xamarin.iOS 11.4.0 does not support a deployment target of 11.2 for iOS (the maximum is 11.1). Please select an older deployment target in your project's Info.plist or upgrade to a newer version of Xamarin.iOS.

My iPhone and iPhone simulators are all on 11.2, and the only SDK version available in Visual Studio is 11.2 as well.

Any suggestions?

Certified Xamarin Developer - Hire me!

$
0
0

I am Xamarin Developer with 5+ Years of experience,Curretly performing Team Lead role and looking for job change overseas. Below are few briefs about me.

Technical skills : 
   Mobile app development using cross platform technologies  
1) Xamarin Forms 
2) Xamarin iOS
3) Xamarin Android 
4) Azure
5) SQLite
6) C#.NET
With additional skillset for automation testing tools.
1) Xamarin UITest
2) Cucumber 
3) Calabash
4) Gherkin
5) Specflow
Ability to work techno functional.
Kindly acknowledge my profile and let me know about the opportunities for same.

I am reachable on below 
Ph. No. ‪+1(925) 263-6909
Email : anuj@inwizards.com

Interested please fill form. - https://goo.gl/jsMCt4

Importing NSPerformService

$
0
0

I've tried to import NSPerformService and got this so far:
[System.Runtime.InteropServices.DllImport("System/Library/Frameworks/AppKit.framework/Versions/C/AppKit")]<br /> static extern bool NSPerformService(string item, NSPasteboard pboard);

Unfortunately, when I call it I get System.Runtime.InteropServices.MarshalDirectiveException:

Type AppKit.NSPasteboard which is passed to unmanaged code must have a StructLayout attribute.

I realize that it is something about marshaling, so that probably NSPasteboard should be sent like IntPtr or something else, but I have no idea on how to do that (this thread contains the solution when this happens on the return value, but it can't be applied when the problem is in the argument: https://forums.xamarin.com/discussion/57248/type-foundation-nsdictionary-which-is-passed-to-unmanaged-code-must-have-a-structlayout-attribute).

I guess the answer would help to other people that might have similar problem in the future as there aren't too many threads regarding this and definitely not about this specific issue.

AppSettings Reader for Xamarin and Xamarin.Forms

$
0
0

Reading app.config files in a Xamarin.Forms Xaml project

While each mobile platforms do offer their own settings management api, there are no built in ways to read settings from a good old .net style app.config xml file; This is due to a bunch of good reasons reasons, notably the .net framework configuration management api being on the heavyweight side, and each platform having their own file system api.

So we built a simple PCLAppConfig library nicely nuget packaged for your immediate consumption.

This library makes use of the lovely PCLStorage library

This example assumes you are developing a Xamarin.Forms Xaml project, where you would need to access settings from your shared viewmodel.

FOR FILESYSTEM APP.CONFIG

Initialize ConfigurationManager.AppSettings on each of your platform project, just after the ‘Xamarin.Forms.Forms.Init’ statement, as per below:
iOS (AppDelegate.cs)

Xamarin.Forms.Forms.Init();
ConfigurationManager.Initialise(PCLAppConfig.FileSystemStream.PortableStream.Current);
LoadApplication(new App());

Android (MainActivity.cs)

Xamarin.Forms.Forms.Init(this, bundle);
ConfigurationManager.Initialise(PCLAppConfig.FileSystemStream.PortableStream.Current);
LoadApplication(new App());

UWP / Windows 8.1 / WP 8.1 (App.xaml.cs)

Xamarin.Forms.Forms.Init(e);
ConfigurationManager.Initialise(PCLAppConfig.FileSystemStream.PortableStream.Current);
LoadApplication(new App());

Add an app.config file to your shared PCL project, and add your appSettings entries, as you would do with any app.config file

<configuration>
  <appSettings>
    <add key="config.text" value="hello from app.settings!" />
  </appSettings>
</configuration>

Add this PCL app.config file as a linked file on all your platform projects. For android, make sure to set the build action to ‘AndroidAsset’, for UWP set the build action to ‘Content’
Access your setting:

ConfigurationManager.AppSettings["config.text"];

FOR EMBEDDED APP.CONFIG

Initialize ConfigurationManager.AppSettings on your pcl project like below:

Assembly assembly = typeof(App).GetTypeInfo().Assembly;
ConfigurationManager.AppSettings = new ConfigurationManager(assembly.GetManifestResourceStream("DemoApp.App.config")).GetAppSettings;

Add an app.config on your shared pcl project and ensure that Build Action:EmbeddedResource, and add your appSettings entries, as you would do with any app.config
The source code and demo app are available in github

Master-Detail Hamburger iOS vs. Android

$
0
0

I have built a Master/Detail page with a menu. It works beautifully in Android, giving me an animated hamburger. But in iOS the hamburger becomes the word menu and only appears on one screen. Have you run into this? Is this a known and/or fixable problem?

I have followed the approach shown here.

Thanks


DependencyService ist't work (SQLite, PCL)

$
0
0

Hello. I try to use SQLite. I try to do https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/databases/ for that.
But I get error for iOS:

The type or namespace name 'IFileHelper' could not be found (are you missing a using directive or an assembly reference?)

and Android:
The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
at System.IO.PathHelper.GetFullPathName()
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at Xamarin.Android.Tools.Files.ExtractAll(ZipArchive zip, String destination, Action2 progressCallback, Func2 modifyCallback, Func2 deleteCallback, Boolean forceUpdate) at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection1 resolvedResourceDirectories, ICollection1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

What could be the problem?

Error inflating class android.support.design.widget.TabLayout on Jelly Bean and KitKat

$
0
0

I have the following TabLayout in my activity which works fine on Nougat, Marshmallow, and Lollipop, but throws an exception on Jelly Bean and KitKat. Any ideas? This has become beyond frustrating.

<android.support.design.widget.TabLayout p1:minWidth="25px" p1:minHeight="25px" p1:layout_width="match_parent" p1:layout_height="wrap_content" p1:id="@+id/notificationTypes" p1:theme="@style/Theme.AppCompat.Light" />

Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.design.widget.TabLayout ---> Java.Lang.Reflect.InvocationTargetException: Exception of type 'Java.Lang.Reflect.InvocationTargetException' was thrown. ---> Java.Lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.

SQLiteNetExtensions

$
0
0

update the SQLiteNetExtensions to version 2.0.0 and I get this error "return connection.GetAllWithChildren (). ToList ();"
does not recognize me the connection.GetAllWithChildren help please

Querying for two text elements in one container

$
0
0

I am writing tests for an online booking system. Timeslots for the system can be Available, Request, or Unavailable. What I want my test to do is tap the first "Available" timeslot and to return the time as a string, for assertion later on, then select that timeslot and continue. Is there anyway to do this? Currently, I cannot establish a relationship between the 'container', the availability text, and the timslot label text.
As you can see, if a timeslot is unavailable, then there's no text displayed for availability.
When running the repl tree command on this page, I am displayed the following ((for the first two timeslots in the screenshot above) says I've not been around long enough to post pics/links):

   [LabelRenderer] label: "TimeSlotLabelId_Container"
                            [FormsTextView] id: "NoResourceEntry-606",  label: "TimeSlotLabelId",  text: "09:00"
                        [Platform_DefaultRenderer > Platform_DefaultRenderer]
                          [LabelRenderer] label: "TimeSlotLabelId_Container"
                            [FormsTextView] id: "NoResourceEntry-608",  label: "TimeSlotLabelId",  text: "09:30"
                          [LabelRenderer]
                            [FormsTextView] id: "NoResourceEntry-609" text: "Available"
``> > > ``

If I query the "TimeSlotLabelId_Container", then there's nothing that seems to links the times to the availability:

[0] {
        Id => null,
        Description => "md5b60ffeb829f638581ab2bb9b1a7f4f3f.LabelRenderer{14f1b71 V.E...... ........ 0,0-120,65}",
        Rect => {
            Width => 120,
            Height => 65,
            X => 40,
            Y => 842,
            CenterX => 100,
            CenterY => 874
        },
        Label => "TimeSlotLabelId_Container",
        Text => null,
        Class => "md5b60ffeb829f638581ab2bb9b1a7f4f3f.LabelRenderer",
        Enabled => true

Xamarin.Forms 2.5.0

Maps Ios position difference

$
0
0

Hi all,

I have follow this link
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/map/customized-pin/

But i have a problem on Ios on function "GetCustomPin" :

PinMotoAlarm GetCustomPin(IMKAnnotation annotation)
        {
            var nativelement = (CustomMap)this.Element;
            var position = new Position(annotation.Coordinate.Latitude, annotation.Coordinate.Longitude);
            foreach (var pin in nativelement.CustomPins)
            {
                if (pin.Position == position)
                {
                    return pin;
                }
            }
            return null;
        }

Position of annotation is never equal with my custon pin. It's normal ?

Thanks in advance for help.

Save user input to file not working correctly on iOS

$
0
0

Hello, I am trying to save user selections from different pickers to a text file so that I can retrieve them later.
However, only the last thing that a user has selected seems to be saved to the file.

First, I save the user selected row from the Brand picker as below:

public override void Selected(UIPickerView pickerView, nint row, nint component)
        {
            brandLabel.Text = $"Gekozen apparaat: {brands[pickerView.SelectedRowInComponent(0)]}";
            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filename = Path.Combine(documents, "Write.txt");
            File.WriteAllText(filename, brands[pickerView.SelectedRowInComponent(0)]);
        }

Secondly, I save the user selected row from the Device picker as below:

public override void Selected(UIPickerView pickerView, nint row, nint component)
{
        deviceLabel.Text = $"Gekozen apparaat: {devices[pickerView.SelectedRowInComponent(0)]}";
        var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        var filename = Path.Combine(documents, "Write.txt");
        File.WriteAllText(filename, devices[pickerView.SelectedRowInComponent(0)]);
    }

I write both of these selections to "Write.txt".
Then, I want to show the content of "Write.txt" as below into the console:

    var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filename = Path.Combine(documents, "Write.txt");
            var text = File.ReadAllText(filename);

        Console.WriteLine(text);

But it only shows 1 of the 2 things from only 1 on of the pickers (the second picker).

What am I doing wrong? Any help is much appreciated!


NamedSize.Large is too small?

$
0
0

I find NamedSize enum results are too small in xamarin forms. at least for label, i can say that. I think that based on device, it changes. When I test on an emulator with 1200x720, I am not sure about DPI information but i represents Samsung Galaxy Nexus. NamedSize.Large returns 22 only. this is such a small number for meaning of Large. when you say Large, you expect to cover half of the screen at least :) What is the purpose of NamedSize.
I think that otherway around the same goes way too large on UWP mobile applications. It is impossible to control on UWP what it is returned and expected.

NuGets not installing error

$
0
0

If I make a new project as a PCL and try to install certain NuGet packages (for example I'm trying CSVHelper and Xam.iTextSharpLGPL) I'll get the error message:

Could not install package 'CsvHelper 6.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

The package, however, will successfully install. But in the iOS project only.

If I make a new project as shared code, they will successfully install. I've tried changing the PCL profile to target fewer options but still have the same problems. I don't want to have to migrate my whole project to .NET standard at this point in time.

Visual Studio 2017 v15.4.5, Xamarin 4.7.10.38

Fresh New Project Error in Compilation after last update of VS 15.5.0 and XF

$
0
0

I just created a new project and tapped to run but i'm getting a lot of errors like that:

Here are my Nuget manager page:

In Updates Tab I only have Xamarin.Android things that NEVER EVER I was able to update.

Configurations Choosed when created the Project:

Even in Shared Project I get these errors and more.

That's It. Anyone can help me with that? Please don't tell me to reinstall Visual Studio, my internet sucks and it takes one day or maybe more....

Visual Studio 2017: This propertyis not valid when the SDK is not installed.

$
0
0

Suddently im getting this message everywhere on visual studio.
I cant even close it (File/Exit), I cant access to any options menu
What is this? i think at some point my pc has shutdown when a Visual studio update was installing
I have try to repair Visual Studio but i still getting this error.
Should i try to update the sdk manually? where i can find the sdk installation path?

How do I change target devices in Xamarin Forms?

$
0
0

I'm using Visual Studio for Mac with Xamarin Forms. My app is currently targeting iPad, but there I would like to target ONLY iPhone devices, no iPad. However, I can't seem to find where to change the target devices.

Viewing all 204402 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>