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

The type initializer for 'SQLite.SQLiteConnection' threw an exception in Uwp

$
0
0

public SQLiteConnection GetConnection()
{
var sqliteFilename = "Member.sqlite";
string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename);
var conn = new SQLite.SQLiteConnection(path,true);
return conn;
}

above is my Code in UWP
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'SQLite.SQLiteConnection' threw an exception.
Source=SQLite-net
StackTrace:
at SQLite.SQLiteConnection..ctor(String databasePath, Boolean storeDateTimeAsTicks)
at EReader.UWP.FileHelperImplementation.FileHelperImplementation.GetConnection() in E:\VinodkumarP\EReader\trunk\src\source\mobile\EReader\EReader.UWP\FileHelperImplementation\FileHelperImplementation.cs:line 63
at EReader.Domain.DbRepository.DbBaseRepository`1..ctor() in E:\VinodkumarP\EReader\trunk\src\source\mobile\EReader\Domain\DbRepository\DbBaseRepository.cs:line 20
at EReader.Domain.DbRepository.DbUserRepository..ctor() in E:\VinodkumarP\EReader\trunk\src\source\mobile\EReader\Domain\DbRepository\DbUserRepository.cs:line 6
at EReader.ViewModel.LoginViewModel..ctor()
at EReader.LoginPage..ctor()
at EReader.App..ctor()
at EReader.UWP.MainPage..ctor() in E:\VinodkumarP\EReader\trunk\src\source\mobile\EReader\EReader.UWP\MainPage.xaml.cs:line 24
at EReader.UWP.EReader_UWP_XamlTypeInfo.XamlTypeInfoProvider.Activate_4_MainPage() in E:\VinodkumarP\EReader\trunk\src\source\mobile\EReader\EReader.UWP\obj\x86\Debug\XamlTypeInfo.g.cs:line 255
at EReader.UWP.EReader_UWP_XamlTypeInfo.XamlUserType.ActivateInstance() in E:\VinodkumarP\EReader\trunk\src\source\mobile\EReader\EReader.UWP\obj\x86\Debug\XamlTypeInfo.g.cs:line 480

Inner Exception 1:
TypeLoadException: Method 'sqlite3_blob_open' in type 'SQLitePCL.SQLite3Provider_e_sqlite3' from assembly 'SQLitePCLRaw.provider.e_sqlite3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9c301db686d0bd12' does not have an implementation.


App runs in debug mode, crashes in release mode

$
0
0

Hi!

When running my xamarin forms app on android in debug mode, all works fine.
But when running it in release mode the app crashes after showing the splash screen. (I have deleted the debug version from phone before installing the release version).
Below you can see the application output.
If i delete "Mono Android-23 Support" and "Mono shared Runtime" and reinstall the release version my app does NOT crash in release mode.
So far okay - but will it work later when somebody installs my app from Play store?

What are your experiences with debug and release mode?

Thanks a lot and have a nice day!
Andreas

Application Output: [AndroidRuntime] Shutting down VM [AndroidRuntime] FATAL EXCEPTION: main [AndroidRuntime] Process: Alarm.Droid, PID: 8858 [AndroidRuntime] java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811) [AndroidRuntime] Caused by: java.lang.reflect.InvocationTargetException [AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method) [AndroidRuntime] at java.lang.reflect.Method.invoke(Method.java:372) [AndroidRuntime] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016) [AndroidRuntime] ... 1 more [AndroidRuntime] Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.IO.FileNotFoundException: Could not load file or assembly 'alarm' or one of its dependencies. The system cannot find the file specified. [AndroidRuntime] File name: 'alarm' [AndroidRuntime] at System.AppDomain.Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence) <0x003d4> [AndroidRuntime] at System.AppDomain.Load (System.Reflection.AssemblyName) <0x0001f> [AndroidRuntime] at (wrapper remoting-invoke-with-check) System.AppDomain.Load (System.Reflection.AssemblyName) <0x0007b> [AndroidRuntime] at System.Reflection.Assembly.Load (System.Reflection.AssemblyName) <0x0001f> .....

Why Location Permission is not when when distributing the app?

$
0
0

Hi,

In my .NET Standard app, I have set the location permission as you can see in the attached image but when distributing the android app on Google Play it doesn't set the permission so user needs to go manually and enable it.

Where is the issue here please?

Thanks,
Jassim

The name 'InitializeComponent' does not exist in the current context

$
0
0

I Created a brand new Xamarin.forms project with Visual studio 2017, when i try to compile after creating the project, i'm getting the below error, I didn't change single line of code.

"Error CS0103 The name 'InitializeComponent' does not exist in the current context App2.iOS D:\App2\App2\App2\App.xaml.cs 14 Active"

other info : It is successfully connected to a Mac machine

Login Page in Xamarin Forms

$
0
0

Hi guys,

I am really new to Xamarin so help is much appreciated :)

Here are my questions:

  1. I am wondering since i read the other thread about creating a login module which it says "push the login page modal on the navigation stack and pop it when you logged in" ? Is that how we create login in Xamarin?

  2. So what's the difference between Question 1 Vs Creating a new login activity in the PCL and make that activity first to run on App.Xaml.cs , and after the login is successfull, we direct them to our Main Page (In my case i use MasterDetailPage Forms for the main page) ?

  3. How to store login state, so when users did login once, they do not need to enter login credentials everytime they open the app until they clear the cache in options?

Kind Regards,
Kevin

Xamarin for Point of Sale app

$
0
0

Hi,

Can I use Xamarin for Point of Sale app?

If yes then how can I print for example to the Epson thermal printer to print the customer receipt?

Thanks,
Jassim

Android Activity tag android:name MD5 changed in Manifest file without changing any code

$
0
0

I have created an android build in 10 March 2018(#1234) then created the same version build in 15 May 2018(#1245). In both the builds i there is an issue of changing the class name in android manifest file. I don't know what xamarin changed its build process so i am getting the different class name.

I am showing you the exact scenario:

  • In #1234 i am getting the string of activity with name like below

    <activity android:icon="@drawable/icon" android:label="@string/app_name" android:name="md5601603957bd95d32f86ccea34c18d6a7.SplashActivity" android:noHistory="true" android:screenOrientation="portrait" android:theme="@style/SplashTheme">

  • In #1245 i am getting the string of activity with name like below
    <activity android:icon="@drawable/icon" android:label="@string/app_name" android:name="md5b3a0d56d6e26694c48a179fb000dfbaa.SplashActivity" android:noHistory="true" android:screenOrientation="portrait" android:theme="@style/SplashTheme">

So the difference is in the android:name tag of activity. Why it is coming?

One more strange thing happens. I though i could have changed some code may be i have changed the namespace because the class name computed by using MD5SUM of fully qualified name of a class. So i took update of old code (10 March 2018) and build that version. I am surprised to see the out put that this build also having the changed class name (md5b3a0d56d6e26694c48a179fb000dfbaa.SplashActivity).

On more thing here, I have extracted the apk using apktool and see the different in both the resources. If i go abc.apk->smali i can see all the MD5SUM class generated folder then i searched for splash activity one and see the following difference:

  • In #1234:
    .line 15
    const-string v0, "PackageName.Android.SplashActivity, PackageName.Android, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
    const-class v1, Lmd5601603957bd95d32f86ccea34c18d6a7/SplashActivity;

  • In #1245
    .line 15
    const-string v0, "PackageName.Android.SplashActivity, PackageName.Android"

    const-class v1, Lmd5b3a0d56d6e26694c48a179fb000dfbaa/SplashActivity;

This difference i can see in both the files. May be Xamarin made some release which changes my class name with in my given period of time.

Please help me out for this.

HttpClient has very large response time on Xamarin Android

$
0
0

I have followed the article https://docs.microsoft.com/en-gb/xamarin/android/app-fundamentals/http-stack?tabs=macos to make Xamarin Android application support TLS 1.2

When I call rest service, It takes 10+ seconds from Xamarin Android while 2 seconds from Xamarin IOS project.

Both project uses same PLC HttpClient code to call same service.

Code:

HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, restQuery);
response = await client.SendAsync(request);
string result = await response.Content.ReadAsStringAsync();

Raising this issue as it has considerable difference between IOS & Android environment in Xamarin.


Border Radius and Border on Entry

$
0
0

Is there a way to set a border radius or border color/width on an Entry?

Or does that have to be done using custom renderers, and if so, does anyone have an example of what that would look like?

Visual studio slow down Mac

$
0
0

Visual studio takes 100, 200 or more percentage of CPU. New projects in solution are being created very slowly (2 minutes or more).

Visual Studio for Mac Preview, Version: Preview 5 (7.0 build 1659).
MacBook Pro, Intel Core i5 (2.6 GHz), Memory: 8 GB.

Propagate events from datatemplate.

$
0
0

I'm using a datatemplate on a listview which is working fine. But have no idea how to propagate events from the datatemplate to the listview codebehind?

...............................
class MyDataTemplateSelector : Xamarin.Forms.DataTemplateSelector
{
public DataTemplate QuestionType_Heading { get; set; }
public DataTemplate QuestionType_Numeric { get; set; }
public DataTemplate QuestionType_Switch { get; set; }
public DataTemplate QuestionType_Text { get; set; }

    public MyDataTemplateSelector()
    {
        // Retain instances!
        this.QuestionType_Heading = new DataTemplate(typeof(QuestionType_Heading));
        this.QuestionType_Numeric = new DataTemplate(typeof(QuestionType_Numeric));
        this.QuestionType_Switch = new DataTemplate(typeof(QuestionType_Switch));
        this.QuestionType_Text = new DataTemplate(typeof(QuestionType_Text));
    }

    private Command _diceRollCancelledCommand = new Command(DiceRollCancelledExecute);
    public ICommand DiceRollCancelledCommand { get { return _diceRollCancelledCommand; } }

    private static void DiceRollCancelledExecute()
    {
        //FireDisplayAlert("Dice Roll Cancelled", "got it", "OK");
    }


    protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
    {
        Trace.TraceInformation($"----------------------------------------------OnSelectTemplate :: QuestionId[{((FormResultQuestionModel)item).QuestionId}] QuestionText[{((FormResultQuestionModel)item).QuestionText}]  QuestionTypeId[{((FormResultQuestionModel)item).QuestionTypeId}] ");

        switch (((FormResultQuestionModel)item).QuestionTypeId)
        {
            case 1://heading
                return this.QuestionType_Heading;
            case 2:
                return this.QuestionType_Numeric;
            case 3:
                return this.QuestionType_Text;
            case 4://Numeric
                this.QuestionType_Numeric.SetValue(etech.audit.Views.QuestionType_Numeric.OnDiceRollCancelledProperty, DiceRollCancelledCommand);
                return this.QuestionType_Numeric;
            case 5://switch
                return this.QuestionType_Switch;
            default:
                return this.QuestionType_Text;
        }

    }

.............................

How to check if the user didn't do any action of the application for 15 min for example

$
0
0

How to check if the user didn't do any action of the application for 15 min for example

Thank you

Deleting files in SD Card

$
0
0

Hello,

Can someone let me know is Android allow us to delete files in SD Card? If yes then how we can do that, because its not letting me to delete, its showing error "Access to path 'specific file path' is denied". I'm also asking WriteExternalStorage permission but didn't succeed.

Please reply as soon as possible.

Thanks,
Hamad Shahid

Xamarin disconnects after connect with VS2017 and Pixel2

$
0
0

Visual Studio 2017 Community
Pixel2, Android 8.1.0
Xamarin disconnects as soon as I close the Xamarin Live Player pairing dialog in VS

Sometimes Image doesn't display on Old/Smaller Android devices

$
0
0

Sometimes the image doesn't display on my older Android (pre lollipop). I am guessing it is a memory issue, but it seems inconsistent. One one page no image shows up, the next page they all work. Sometimes an image will show up, and sometimes it won't. I can go to a page, no images show up. Go to the next page, then go back, and the images show up.
Everything works fine on other versions.

Is there anything I can to debug this, see why the images don't appear? I'm guessing it is memory related, but it seems a bit too inconsistent for that.


Is Possible to recover C# code from APK ?

$
0
0

Hello, my name is Leonan Fraga Leonardo and in the last week an inconvenience happened with me, I lost my application developed for my MSc thesis due to a failure in the SSD controller, however, I have the .APK file saved on my Smartphone. Is there a mechanism for retrieving the C # code based on APK? I'm pretty desperate.

Corner border for Frame

$
0
0

In Xamarin Forms by setting CornerRadius='some value' will render the frame accordingly in iOS and Android.
But in UWP frame is rendered as a sharp / rectangle border.

Fix for this:
In UWP native project we have to write a renderer class for FrameRenderer as below.

public class FrameRenderer : Xamarin.Forms.Platform.UWP.FrameRenderer
{           
        protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                var frame = e.NewElement;
                Windows.UI.Color frameBG = Windows.UI.Color.FromArgb(
                    (byte)(frame.BackgroundColor.A * 255),
                    (byte)(frame.BackgroundColor.R * 255),
                    (byte)(frame.BackgroundColor.G * 255),
                    (byte)(frame.BackgroundColor.B * 255));

                if (frame.CornerRadius > -1)
                {
                    Control.CornerRadius = new Windows.UI.Xaml.CornerRadius(frame.CornerRadius);
                    Control.Background = new SolidColorBrush(frameBG);
                    frame.BackgroundColor = Xamarin.Forms.Color.Transparent;
                }
            }
        }
    }

Drag and Drop in UWP

$
0
0

Let's say we have a set of positions and we have to drag filled position and drop into empty position.
In UWP render the custom control and

  1. add private field

    private DragDropGestureHandler dragAndDropHandler = new DragDropGestureHandler();
    
  2. in OnElementPropertyChanged function

    protected override void OnElementChanged(ElementChangedEventArgs<PositionCustomView> e)
    {
    
        base.OnElementChanged(e);
    
        if (e.OldElement == null)
        {
            this.CanDrag = true;
            this.AllowDrop = true;
            this.DragOver += dragAndDropHandler.PositionCustomViewRenderer_DragOver;
            this.DragStarting += dragAndDropHandler.PositionCustomViewRenderer_DragStarting;
            this.Drop += dragAndDropHandler.PositionCustomViewRenderer_Drop;
        }
    
        if (e.NewElement == null)
        {
            this.CanDrag = false;
            this.AllowDrop = false;
            this.DragOver -= dragAndDropHandler.PositionCustomViewRenderer_DragOver;
            this.DragStarting -= dragAndDropHandler.PositionCustomViewRenderer_DragStarting;
            this.Drop -= dragAndDropHandler.PositionCustomViewRenderer_Drop;
        }
    }
    
  3. DragDropGestureHandler

    public class DragDropGestureHandler
    
    {        
        public void PositionCustomViewRenderer_DragStarting(UIElement sender, DragStartingEventArgs args)
        {
            var viewRenderer = sender as PositionCustomViewRenderer;
            var element = viewRenderer?.Element;
            if (element.AllowMove)
            {
                args.Cancel = false;
                args.Data.Properties.Add("customView", (element));
                element.PositionMovingCommand?.Execute(element.Position);
            }
            else
            {
                args.Cancel = true;
            }
        }
    
    public async void PositionCustomViewRenderer_Drop(object sender, DragEventArgs e)
    {
        var viewRenderer = sender as PositionCustomViewRenderer;
        var element = viewRenderer?.Element;
        var result = e.DataView?.Properties?.
                    SingleOrDefault(p => p.Key == "customView" && p.Value.GetType() == typeof(PositionCustomView));
        var positionCustomView = result?.Value as PositionCustomView;
    
        element.PositionMovedCommand?.Execute(new Tuple<int, int?, int>(PositionCustomView.Position, PositionCustomView.SessionId, element.Position));
    }        
    
    public void PositionCustomViewRenderer_DragOver(object sender, DragEventArgs e)
    {
        var viewRenderer = sender as PositionCustomViewRenderer;
        var element = viewRenderer?.Element;
        if (element.AllowDrop)
        {
            e.AcceptedOperation = DataPackageOperation.Copy | DataPackageOperation.Move;
        }
        else
        {
            e.AcceptedOperation = DataPackageOperation.None;
        }
    }
    
    }
    

REST APIs are working in postman and browser but not working when applied on project.

$
0
0

Hi,

I have a strange problem.

I am working on a xamarin forms app. My REST APIs are working in postman and browsers, but when I apply these REST APIs to project they are not working. Already run many REST APIs in the project, but don't know why it is not working now. I am using the following code:

            HttpClient client = new HttpClient();
            Debug.WriteLine("Enter here");
            var siteIdResponse = await client.GetAsync(My REST API);
            Debug.WriteLine("siteIdResponse:>" + siteIdResponse);
            if (siteIdResponse.IsSuccessStatusCode)
            {
                   //codes
            }

Output:

[0:] Enter here
Thread started:  #7
07-09 18:48:10.231 D/Mono    (21753): Image addref Mono.Security[0xb8ebcc80] -> Mono.Security.dll[0xb8e9be58]: 2
07-09 18:48:10.231 D/Mono    (21753): Prepared to set up assembly 'Mono.Security' (Mono.Security.dll)
07-09 18:48:10.231 D/Mono    (21753): Assembly Mono.Security[0xb8ebcc80] added to domain RootDomain, ref_count=1
07-09 18:48:10.232 D/Mono    (21753): AOT: image 'Mono.Security.dll.so' not found: dlopen failed: library "/mnt/asec/com.pagematics.Business_App-1/lib/arm/libaot-Mono.Security.dll.so" not found
07-09 18:48:10.233 D/Mono    (21753): AOT: image '/usr/local/lib/mono/aot-cache/arm/Mono.Security.dll.so' not found: dlopen failed: library "/mnt/asec/com.pagematics.Business_App-1/lib/arm/libaot-Mono.Security.dll.so" not found
07-09 18:48:10.233 D/Mono    (21753): Config attempting to parse: 'Mono.Security.dll.config'.
07-09 18:48:10.234 D/Mono    (21753): Config attempting to parse: '/usr/local/etc/mono/assemblies/Mono.Security/Mono.Security.config'.
07-09 18:48:10.234 D/Mono    (21753): Assembly Ref addref System[0xb851f108] -> Mono.Security[0xb8ebcc80]: 2
07-09 18:48:10.234 D/Mono    (21753): Assembly Ref addref Mono.Security[0xb8ebcc80] -> mscorlib[0xb82cfaf0]: 58
Loaded assembly: Mono.Security.dll [External]
07-09 18:48:10.297 D/Mono    (21753): Assembly Ref addref System.Net.Http[0xb8e80b50] -> System.Core[0xb844e178]: 7
07-09 18:48:10.388 D/Mono    (21753): Assembly Ref addref Mono.Android[0xb834d360] -> System[0xb851f108]: 15
07-09 18:48:10.790 I/Choreographer(21753): Skipped 100 frames!  The application may be doing too much work on its main thread.
Thread started: <Thread Pool> #8
Thread started: <Thread Pool> #9
Thread finished: <Thread Pool> #5
The thread 'Unknown' (0x5) has exited with code 0 (0x0).
Thread finished: <Thread Pool> #9
The thread 'Unknown' (0x9) has exited with code 0 (0x0).
Thread finished: <Thread Pool> #2
Thread started: <Thread Pool> #10
The thread 'Unknown' (0x2) has exited with code 0 (0x0).

Thanks in advance :)

Cannot update GooglePlayServices 60.1142.0

$
0
0

I am trying to update googleplay services package to 60.1142.0. It seems like that you have change with Xamarin.GooglePlayServices.Basement package and I am getting error message as below. I tried to remove Xamarin.GooglePlayServices.Basement package and tried to install other package as advised but It is still not working? what is the solution here?

Removing package 'Xamarin.GooglePlayServices.Basement.60.1142.0 : Xamarin.Android.Support.Compat [26.0.2, ), Xamarin.Android.Support.Core.UI [26.0.2, ), Xamarin.Android.Support.Core.Utils [26.0.2, ), Xamarin.Android.Support.Fragment [26.0.2, ), Xamarin.Android.Support.Media.Compat [26.0.2, ), Xamarin.Build.Download [0.4.7, )' from folder 'C:\Git\nugetpackages'
Removed package 'Xamarin.GooglePlayServices.Basement.60.1142.0 : Xamarin.Android.Support.Compat [26.0.2, ), Xamarin.Android.Support.Core.UI [26.0.2, ), Xamarin.Android.Support.Core.Utils [26.0.2, ), Xamarin.Android.Support.Fragment [26.0.2, ), Xamarin.Android.Support.Media.Compat [26.0.2, ), Xamarin.Build.Download [0.4.7, )' from folder 'C:\Git\nugetpackages'
Executing nuget actions took 3,23 min
This collection is read-only.
Time Elapsed: 00:03:30.7351044
========== Finished ==========*

Viewing all 204402 articles
Browse latest View live