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

Programmatically determine memory used by app?

$
0
0

To help monitor/track down memory leaks, we need to know what memory our app is consuming.

This is for a Xamarin.Forms app; currently we're only running on Android, but will be on iOS in the future.

I know we can get the OS memory used on the device, in the Droid project, by using code like below:

public static MemoryInfo GetMemoryInfo()
{
        MemoryInfo retVal = new MemoryInfo();
        retVal.MaxMemory = Java.Lang.Runtime.GetRuntime().MaxMemory();
        retVal.FreeMemory = Java.Lang.Runtime.GetRuntime().FreeMemory();
        retVal.TotalMemory = Java.Lang.Runtime.GetRuntime().TotalMemory();

        return retVal;
}

Is there any mechanism for getting a figure for the memory being consumed in the Mono runtime?


Cannot run iOS simulator for iOS 11.1

$
0
0

Since a few weeks now I haven't been able to deploy and execute apps on iPhone simulator running on iOS 11.1. The problem seems related to XCode or, possibly, MacOS because I get the same error when I try deploy from XCode (using Swift). This is the error message I get:

Unable to lookup service com.apple.CoreSimulator.host_support: 0x3

I have tried running on iOS 10.0 and also 11.1 on iPhone 6 and that works fine. But iPhone 8 or 7 on 11.1 yields this error.
Can someone help me decrypt the error message (Google came up empty).

CarouselPage binding

$
0
0

I haven't used the CarouselPage before and I cannot get the binding for the children pages to work. I have something like this:

`    <?xml version="1.0" encoding="utf-8" ?>
<CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:JaaTyrePal;assembly=JaaTyrePal"
             xmlns:iconize="clr-namespace:FormsPlugin.Iconize;assembly=FormsPlugin.Iconize"
             x:Class="JaaTyrePal.HomePage"
             NavigationPage.HasNavigationBar="false">
    <ContentPage x:Name="Page1" BackgroundColor="Black"  >
        <Label Grid.Row="0" Grid.Column="1" Text="{Binding Temp}" Style="{StaticResource GaugeLabel}"/>

    </ContentPage>
    <ContentPage x:Name="Page2" BackgroundColor="Black" Title="Right Tyres">
         <Label Grid.Row="0" Grid.Column="1" Text="{Binding TempB}" Style="{StaticResource GaugeLabel}"/>
    </ContentPage>
</CarouselPage>`

And my simple ViewModel:
`

            public HomePageModel(MasterParameterContainer masterContainer)
            {
                Temp = 2.3;
            }

            double _temp;
            double Temp
            {
                get
                {
                    return _temp;
                }
                set
                {
                    _temp = value;
                    RaisePropertyChanged();
                }

`

I cant get the binding to work for ContentPages, I even tried the following in the code behind:

`protected override void OnBindingContextChanged()
        {
            Page1.BindingContext = BindingContext;
            Page2.BindingContext = BindingContext;
            base.OnBindingContextChanged();
        }`

What am I doing wrong here?

iOS XAML previewer not working with VS Mac 7.3 (build 979)

$
0
0

Since I upgraded, two days ago, to the latest version of Visual Studio for Mac the XAML previewer no longer renders for iOS (Android still works), This is the stack trace it renders instead:

System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> MonoTouch.Design.Client.InvalidSessionException: Exception of type 'MonoTouch.Design.Client.InvalidSessionException' was thrown. ---> Foundation.NSErrorException: Exception of type 'Foundation.NSErrorException' was thrown.
at MonoTouch.Hosting.SlimSession.LaunchApplicationImpl (System.String bundleId, System.String[] arguments) [0x001a9] in <8a34bfb579844fbaa8516068fec2ce02>:0
at MonoTouch.Hosting.Session.LaunchApplication (System.String bundleId, System.String[] arguments) [0x00006] in <8a34bfb579844fbaa8516068fec2ce02>:0
at MonoTouch.Design.Client.Mac.MacServerProcessConnection.EnsureServerRunning (System.Boolean throwIfNotRunning) [0x0017d] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client.Mac/MacServerProcessConnection.cs:313
--- End of inner exception stack trace ---
at MonoTouch.Design.Client.Mac.MacServerProcessConnection.EnsureServerRunning (System.Boolean throwIfNotRunning) [0x001d0] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client.Mac/MacServerProcessConnection.cs:323
at MonoTouch.Design.Client.ServerProcessConnection.SendRequestCore (MonoTouch.Design.CommandRequest request, System.Boolean throwIfNotRunning) [0x00056] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:271
at MonoTouch.Design.Client.ServerProcessConnection.SendRequest (MonoTouch.Design.CommandRequest req, System.Boolean throwIfNotRunning) [0x00001] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:219
at MonoTouch.Design.Client.ServerProcessConnection.SendRequest[TResponse] (MonoTouch.Design.CommandRequest req, System.Boolean throwIfNotRunning) [0x00001] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:241
at MonoTouch.Design.Client.ServerProcessConnection.CreateSession () [0x00001] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:109
at MonoTouch.Design.Client.ServerProcessConnection.b__24_0 () [0x00000] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:114
at System.Threading.Tasks.Task1[TResult].InnerInvoke () [0x0000f] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:680 at System.Threading.Tasks.Task.Execute () [0x00010] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00013] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2159 at System.Threading.Tasks.Task1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:562
at System.Threading.Tasks.Task1[TResult].get_Result () [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:532 at MonoTouch.Design.Client.IPhoneDesignerSession+<>c__DisplayClass265_11[TResult].b__1 (System.Threading.Tasks.Task1[TResult] t) [0x00012] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/IPhoneDesignerSession.cs:1858 at System.Threading.Tasks.ContinuationResultTaskFromResultTask2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskContinuation.cs:207
at System.Threading.Tasks.Task.Execute () [0x00010] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00013] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2159
at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:3189
at System.Threading.Tasks.Task.Wait () [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:3054
at MonoTouch.Design.Client.IPhoneDesignerSession+<>c__DisplayClass265_01[TResult].<EnsureSession>b__0 () [0x002bb] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/IPhoneDesignerSession.cs:1919 at System.Threading.Tasks.Task1[TResult].InnerInvoke () [0x0000f] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:680
at System.Threading.Tasks.Task.Execute () [0x00010] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 at Xamarin.Designer.Forms.Preview.iOSXamlRenderer+<RenderXamls>d__2.MoveNext () [0x001ed] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.Forms/Xamarin.Designer.Forms.Preview/iOS/iOSXamlRenderer.cs:56 ---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> MonoTouch.Design.Client.InvalidSessionException: Exception of type 'MonoTouch.Design.Client.InvalidSessionException' was thrown. ---> Foundation.NSErrorException: Exception of type 'Foundation.NSErrorException' was thrown. at MonoTouch.Hosting.SlimSession.LaunchApplicationImpl (System.String bundleId, System.String[] arguments) [0x001a9] in <8a34bfb579844fbaa8516068fec2ce02>:0 at MonoTouch.Hosting.Session.LaunchApplication (System.String bundleId, System.String[] arguments) [0x00006] in <8a34bfb579844fbaa8516068fec2ce02>:0 at MonoTouch.Design.Client.Mac.MacServerProcessConnection.EnsureServerRunning (System.Boolean throwIfNotRunning) [0x0017d] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client.Mac/MacServerProcessConnection.cs:313 --- End of inner exception stack trace --- at MonoTouch.Design.Client.Mac.MacServerProcessConnection.EnsureServerRunning (System.Boolean throwIfNotRunning) [0x001d0] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client.Mac/MacServerProcessConnection.cs:323 at MonoTouch.Design.Client.ServerProcessConnection.SendRequestCore (MonoTouch.Design.CommandRequest request, System.Boolean throwIfNotRunning) [0x00056] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:271 at MonoTouch.Design.Client.ServerProcessConnection.SendRequest (MonoTouch.Design.CommandRequest req, System.Boolean throwIfNotRunning) [0x00001] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:219 at MonoTouch.Design.Client.ServerProcessConnection.SendRequest[TResponse] (MonoTouch.Design.CommandRequest req, System.Boolean throwIfNotRunning) [0x00001] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:241 at MonoTouch.Design.Client.ServerProcessConnection.CreateSession () [0x00001] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:109 at MonoTouch.Design.Client.ServerProcessConnection.<CreateSessionAsync>b__24_0 () [0x00000] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:114 at System.Threading.Tasks.Task1[TResult].InnerInvoke () [0x0000f] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:680
at System.Threading.Tasks.Task.Execute () [0x00010] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00013] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2159
at System.Threading.Tasks.Task1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:562 at System.Threading.Tasks.Task1[TResult].get_Result () [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:532
at MonoTouch.Design.Client.IPhoneDesignerSession+<>c__DisplayClass265_11[TResult].<EnsureSession>b__1 (System.Threading.Tasks.Task1[TResult] t) [0x00012] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/IPhoneDesignerSession.cs:1858
at System.Threading.Tasks.ContinuationResultTaskFromResultTask2[TAntecedentResult,TResult].InnerInvoke () [0x00024] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskContinuation.cs:207 at System.Threading.Tasks.Task.Execute () [0x00010] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 ---> (Inner Exception #0) MonoTouch.Design.Client.InvalidSessionException: Exception of type 'MonoTouch.Design.Client.InvalidSessionException' was thrown. ---> Foundation.NSErrorException: Exception of type 'Foundation.NSErrorException' was thrown. at MonoTouch.Hosting.SlimSession.LaunchApplicationImpl (System.String bundleId, System.String[] arguments) [0x001a9] in <8a34bfb579844fbaa8516068fec2ce02>:0 at MonoTouch.Hosting.Session.LaunchApplication (System.String bundleId, System.String[] arguments) [0x00006] in <8a34bfb579844fbaa8516068fec2ce02>:0 at MonoTouch.Design.Client.Mac.MacServerProcessConnection.EnsureServerRunning (System.Boolean throwIfNotRunning) [0x0017d] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client.Mac/MacServerProcessConnection.cs:313 --- End of inner exception stack trace --- at MonoTouch.Design.Client.Mac.MacServerProcessConnection.EnsureServerRunning (System.Boolean throwIfNotRunning) [0x001d0] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client.Mac/MacServerProcessConnection.cs:323 at MonoTouch.Design.Client.ServerProcessConnection.SendRequestCore (MonoTouch.Design.CommandRequest request, System.Boolean throwIfNotRunning) [0x00056] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:271 at MonoTouch.Design.Client.ServerProcessConnection.SendRequest (MonoTouch.Design.CommandRequest req, System.Boolean throwIfNotRunning) [0x00001] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:219 at MonoTouch.Design.Client.ServerProcessConnection.SendRequest[TResponse] (MonoTouch.Design.CommandRequest req, System.Boolean throwIfNotRunning) [0x00001] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:241 at MonoTouch.Design.Client.ServerProcessConnection.CreateSession () [0x00001] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:109 at MonoTouch.Design.Client.ServerProcessConnection.<CreateSessionAsync>b__24_0 () [0x00000] in /Users/vsts/agent/2.124.0/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:114 at System.Threading.Tasks.Task1[TResult].InnerInvoke () [0x0000f] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:680
at System.Threading.Tasks.Task.Execute () [0x00010] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 <---
<---

Xamarin Forms Bluetooth

$
0
0

Hi,
I am trying to create a Portable Class library Xamarin Form project in which I need to use Bluetooth of the device to communicate with HC-05 Bluetooth module using serial communication. I want the code to be cross-platform. Can anybody please guide me step by step how can I do a single coding for both Android and iOS platform in Xamarin Forms. I don't want to opt for platform-specific coding. Thanks in advance

Android Instant Apps

$
0
0

Is Android Instant Apps supported in Xamarin.Android ? and if not is there any plans for supporting it in the future

How to handle OutOfMemory Exception in xamarin.android

$
0
0

Hey
I am new to Android

I am resizing a Bitmap, for this when I create a blank Bitmap with a high resolution, it throws OutOfMemory Exception. How to deal with this.

public Bitmap getResizedBitmap(Bitmap originalBitmap, int maxWidth, int maxHeight)
{
Bitmap res = Bitmap.CreateBitmap(4000, 4000, Bitmap.Config.Argb8888);
Canvas can = new Canvas(res);
Paint paint = new Paint();
paint.FilterBitmap = false;
can.DrawBitmap(originalBitmap, new Matrix(), paint);

    return res;
}

When I choose for low resolution Bitmap then it works fine and the issue is with the high resolution images.

I also noticed that when I give different resolution in compared to originalBitmap then the output of the res is cropped, and not resized.

Any help would be appreciated.

Inspector thinks AVD is a physical device and will not load

$
0
0

I'm using the Android SDK emulator with a x86 system image and VS 2017. When I try to use the latest version of the Inspector I get an error launching it; "Inspector is not supported on physical Android devices".

I'm debugging the app fine with the emulator.


Access a viewmodel method from a custom viewcell

$
0
0

Hi Guys i'm trying to implement and learn MVVM the best I can,

I'm tripping over on how to do this,

I have a listview which is bound to a List contained in my pages view model of the type:

public class DeliverySet : List<Box>
{
    public string OrderID { get; set; }
    public Address address { get; set; }
}

The grouping header template is bound to a custom viewcell which displays the OrderID and has a button for Deletion.

The pages view model contains a method for deleting an item from the list, database and a web service, how can I somehow execute this method from the view cell as the binding context is the DeliverySet type and I have no access to the parent pages view model?

Thanks!
Dave

Arrrrghh another update problem

$
0
0

I installed the latest update, now I get the error XamarinShellPackage did not install correctly and my project will no longer load (says it is incompatible). This is with VS2015 Pro also updated to the latest. Any ideas? I tried downgrading to Cycle 8 again and now it won't compile I just get a appt.exe exited with code 1

Run double async tasks at the same time

$
0
0

I have one Async Task that execute in ContentPage A, and another Async Task that execute in ContentPage B. Both of the content pages I gathered them in TabbedPage.

How to execute both the Async Tasks in both content pages when I open the TabbedPage? Because currently, the Async Task in A is executed completely but the Async Task in B seems like executed half way. The result in B does not return to the callback class.

Is this the correct way to completely execute double async tasks at the same time? Are there any other better ways of doing this? Can suggest me suitable links for understand asynchronous tasks?

listview item selected disable

$
0
0

I have a custom cell in my listview. Each cell has a bunch of buttons and images which have tap events. Sometimes when I click outside of image or button in cell, the row gets highlighted. Is it possible to let users click images and buttons but still disable row highlighting?

Thanks

How to use webservice async?

$
0
0

I 'm developing a program using webservice. Data is given asynchronously. (refer TodoASMX )
Program sources are shown below.
how to use task and await?

Webservice
[WebMethod]
public userInfo WS_PDA010E01_R1(string strID, string strPWD)
{
DataTable dt = new DataTable();
userInfo uInfo = new userInfo();
try
{
uInfo = todoService.CMWS_WS_PDA010E01_R1(strID, strPWD);
return uInfo;
}
catch (Exception ex )
{
throw new SoapException("Error", SoapException.ServerFaultCode, ex);
}
}

**Forms **
1. public interface ISoapService
- Task WS_PDA010E01_R1(string strID, string strPWD);
2. public class DataManager
- public Task WS_PDA010E01_R1(string strID, string strPWD)
{
return soapService.WS_PDA010E01_R1(strID, strPWD);
}

3. XAML
async void OnLoginButtonClicked(object sender, EventArgs e)
{
try
{
var items = await App.dtManager.WS_PDA010E01_R1(usernameEntry.Text, passwordEntry.Text);
if (string.IsNullOrEmpty(items.MEMBERNAME) == false)
{
App.IsUserLoggedIn = true;
await Navigation.PopModalAsync(true);
}
else
{
App.IsUserLoggedIn = false;
messageLabel.Text = "Login failed";
passwordEntry.Text = string.Empty;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}

Andoid
public async Task WS_PDA010E01_R1(string strID, string strPWD)
{
var varUser = new userInfo();
try
{
//Error-generation part
var items = await Task.Factory.FromAsync(begin., commonWS.WS_PDA010E01_R1, null, TaskCreationOptions.None);

            varUser.MEMBERID = items.MEMBERID;
            varUser.MEMBERNAME = items.MEMBERNAME;
            return varUser;
        }
        catch (Exception ex)
        {
            throw new Exception(ex);
        }
    }

Forms Custom Renderer in Android Bottom Half Clipped

$
0
0

I am trying to write a custom renderer in a Forms project for an Entry which features text above the entry.

But my custom entry cuts off the bottom section of the entry. The border actually draws correctly, along with the text, however the bottom portion of the view is cut off. I tested this without the text and the drawable was drawn as expected. I'm sure this has something to do with the bounds, clipBounds or the size of the canvas but I can't for the life of me figure it out -- if anyone can it would be must appreciated!

My way to get this up and running was to use a drawable for the border around the entry with some additional code in the DrawChild method to try and create the text.

Here in OnElementChanged I set the drawable for my Entry along with some other values.

    protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
    {
                base.OnElementChanged(e);

    if (Control != null)
    {
        //Initialise textview to get textsize
        tv = new Android.Widget.TextView(Context);
        //Set values for our paint used for our label text
        paint.TextSize = tv.TextSize;

        //Set fields
        entry = (CustomEntry)Element;
        label = entry.EntryLabel;

        //Set typical values
            Control.SetHintTextColor(Xamarin.Forms.Color.FromHex("#B8B8B8").ToAndroid());
        backgroundDrawable = Context.GetDrawable(Resource.Drawable.entry_background);

        //Set as our current background with left and right padding
        Control.Background = backgroundDrawable;
        Control.SetPadding(Control.PaddingLeft + 10, Control.PaddingTop, Control.PaddingRight +10, Control.PaddingBottom);
    }
            }

Then in my DrawChild method I aim to draw the text at (0, paint.TextSize) as the docs states that the y axis in .DrawText() is the baseline of the text. Then I draw the actual entry underneath this baseline by 4 pixels.

    protected override bool DrawChild(Canvas canvas, Android.Views.View child, long drawingTime)
    {
        try
        {
            //Handle our label drawing
            DrawLabel(canvas);
            //Set the child element's Y position to be lower than the label and draw it.
            child.SetY(paint.TextSize + 4);

            return base.DrawChild(canvas, child, drawingTime);
        }
        catch (Exception e)
        {
            System.Diagnostics.Debug.WriteLine("Exception in CustomEntry: " + e.Message);
        }
        return base.DrawChild(canvas, child, drawingTime);
    }

    /// <summary>
    /// Draw our label in either the focused or unfocused colours.
    /// </summary>
    /// <param name="canvas">Canvas</param>
    protected void DrawLabel(Canvas canvas)
    {
        if (HasFocus)
            canvas.DrawText(label, 0, label.Length, 0, paint.TextSize, focusPaint);
        else
            canvas.DrawText(label, 0, label.Length, 0, paint.TextSize, paint);
    }

Help with Components folder

$
0
0

Hello. I have a problem. After reinstalling Visual Studio 2017, the Components folder does not display in the Solution Explorer. Is it possible to manually enable the Components folder?

Im start blank Android c# projekt.


Xamarin.iOS Build for Devices is taking too long

$
0
0

Hi fellows,
I'm having several issues with build time for iOS devices (not for the simulator). A build is taking about 5 minutes or more!

I'm using the latest version of Xamarin Studio (6.1.3 Build 19) and the latest version of the Apple SDK's. This is happening on a MBPr 15' i7 16 GB 512 SSD, so It's definitely not an hardware issue (specially because I've never had that kind of issue before on the same machine).

Does anyone facing the same kind of issue?
Regards.

"No Updates Found" error when attempting to install Visual Studio Updater 1.7

$
0
0

Hi, just as the title, I'm getting an error of 'Error - No updates found' when attempting to install Visual Studio Updater 1.7.
The error occurs when clicking 'Restart and Install Update.

Other updates have installed without issue, and I'm using the stable update channel.

Any advice?
Thanks.

How trigger the DateSelected event of DatePicker only if the user tap on "Done" on iOS?

$
0
0

Hello,

How trigger the DateSelected event of DatePicker only if the user tap on "Done" on iOS?

Currently the event is triggered if you change the year, month or date

Best regards.

Open start form and close all other Forms

$
0
0

At the start of my project I open a Dashboard form, each time I am calling other forms with the Navigation.PushAsync. But when the User logs out I want to close all forms and stacks and open my Dashboard again without going back option. How do i do this?

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

Viewing all 204402 articles
Browse latest View live


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