I was developing my app using SQLite, on "Debug" mode, worked perfectly.
When I try to "Release" it (Compiling "Native"), the problem started, looks like UWP doesn't support Reflexion.
I'm currently using this packages:
SQLite.Core.UAP
SQLite.Net-PCL
For example, if I try to do this:
private void CreateDatabase()
{
var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "StoredEvents.sqlite");
SQLiteConnection SQLiteConn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath, false);
SQLiteConn.CreateTable<StoredEvents>();
}
These are some of the error:
ILTransform_0027: Method 'CreateLambda' within 'System.Linq.Expressions.Expression' could not be found.
Error at SerializationAssemblyGenerator.Program.AddKnownContractsLists(McgCodeTypeDeclaration container, ContractTables tables)
Severity Code Description Project File Line Suppression State
Error at SerializationAssemblyGenerator.Program.GenerateDataContractSerializerHelperCode(IEnumerable`1 contracts, IEnumerable`1 jsonContracts, IEnumerable`1 wcfSerializers)
ILTransform_0000: MCG : warning MCG0006: Unresolved P/Invoke method '_TPM_Init!tpm.dll' in assembly 'TSS.UWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because it is not available in UWP applications. Please either use an another API , or use [DllImport(ExactSpelling=true)
How should I refactor the code?
Should I use a different Library?
I had the same issue when i was updating my apps from Silverlight to UWP. I read an article somewhere ( Tried to find it but was unable to ) which says SQLlite for UWP is available for Windows 10 deployment.
The above is a VS Extension. You can get there from Tools ->> Extensions & Updates
Below is how my References look like.
Also I noticed that you are not closing your db connection. Always better to use it inside a using statement. your CreateTables() will look something like below.
private void CreateDatabase()
{
var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "StoredEvents.sqlite");
using (SQLiteConnection SQLiteConn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath, false))
{
SQLiteConn.CreateTable<StoredEvents>();
}
}
Related
Hello I am trying execute a xamarin app and I would like to create an actor, through the actor system of the akka library, but I receive the error “Configuration system failed initialize” just when trying to create the ActorSystem.
private static readonly ActorSystem _system;
public static readonly IActorRef _coordinator;
static CrawlingSystem ()
{
_system = ActorSystem.Create ("crawling-system");
_coordinator = _system.ActorOf (Props.Create <BackupActor> (), "backupactor");
}
The static CreawlingSystem class is called directly by MainPage.Xaml.cs
I am using visual Studio 2019, an empty Xamarin.Forms project, akka 1.4.21, Xamarin.Forms 5.0.0.2012.
Also i tried with versions: akka 1.3.9, Xamarin.Forms 3.3.0912540, but the error persists
Try changing your ActorSystem.Create call to the following:
_system = ActorSystem.Create ("crawling-system", ""); // empty config
This will stop Akka.NET from trying to query against System.Configuration.ConfigurationManager, which is apparently not supported on Xamarin and gets loaded automatically when no default configuration is provided.
I am using Xamarin forms to create a chat application and to achieve that i am using Sharp.XMPP library from Nuget but i ran into issues.
It was stated that it doesn't support in PCL at here
So i converted the project into shared .net standard library following this blog
After adding following code
using Sharp.Xmpp.Client;
async void OnLoginButtonClicked(object sender, EventArgs e)
{
var user = new User
{
Username = usernameEntry.Text,
Password = passwordEntry.Text
};
string hostname = "localhost";
string username = user.Username;
string password = user.Password;
using (var client = new XmppClient(hostname, username, password))
{
client.Connect();
messageLabel.Text = "Login Success";
client.SendMessage("axcl#localhost", "juyugygyg");
}
}
Error Recieved :
Severity Code Description Project File Line Suppression State
Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Sharp.Xmpp, Version=1.0.2.2, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Sharp.Xmpp.dll'
at Java.Int rop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver) app.Android
Can anyone help me out to how to bind a .net library dll into the project so that it can be used in xamarin forms.
Another alternative is agsXMPP .NET SDK but am not sure much of it.
If i missed something. Sorry for that
First remove sharp nuget and clone this.
https://github.com/pgstath/Sharp.Xmpp .
Open the solution of sharp and build it.
You will get Sharp.Xmpp.dll under bin\debug.
Add reference of this .dll to your project.
I am attempting to compile my Xamarin project and I am getting a compiler error that I dont understand. What does the following error mean and how can i fix this?
Data\SQLiteClient.cs(4,4): Error CS0012: The type 'System.Threading.Tasks.TaskScheduler' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. (CS0012) (DtoToVm.Droid)
Relevant information:
Xamarin Forms blank project PCL
Project set to .NET 4.5 or later
Profile: PCL 4.5 - Profile78
Alot of references are not happy but I haven't manually setup or editted these. Maybe a nuget package conflict?
using Xamarin.Forms;
using DtoToVm.Droid.Data;
[assembly: Dependency (typeof(SQLiteClient))]
namespace DtoToVm.Droid.Data
{
using System;
using DtoToVm.Data;
using SQLite.Net.Async;
using System.IO;
using SQLite.Net.Platform.XamarinAndroid;
using SQLite.Net;
public class SQLiteClient : ISQLite
{
public SQLiteAsyncConnection GetConnection ()
{
var sqliteFilename = "Conferences.db3";
var documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
var path = Path.Combine (documentsPath, sqliteFilename);
var platform = new SQLitePlatformAndroid ();
var connectionWithLock = new SQLiteConnectionWithLock (
platform,
new SQLiteConnectionString (path, true));
// The below line causes the compile error
var connection = new SQLiteAsyncConnection (() => connectionWithLock);
return connection;
}
}
}
Edit:
According to this thread I shd change the profile to 7. I've done this and it got rid of all errors but produced a new one:
DtoToVm\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll: Error CS1703: An assembly with the same identity 'System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' has already been imported. Try removing one of the duplicate references. (CS1703) (DtoToVm)
What file could this duplicate reference be in?
I don't really know if System.Threading.Tasks namespace exists in Xamarin or not, If it's exists then reference it, If not then use the regular SqliteConnection and don't use Async one.
I'm new in Dapper. I trying to create new project and map local database by Dapper. Unfortunately I always receive this error:
Could not load type 'Dapper.SqlMapper' from assembly 'Dapper,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
I added Dapper by NuGet (Dapper v. 1.39.0.0). This is example of my code:
public static IEnumerable<TBMobileDetails> Allmobilelisting()
{
SqlConnection con = new SqlConnection(#"Data Source=(LocalDB)\v11.0;AttachDbFilename=""c:\users\database.mdf"";Integrated Security=True");
string query = "select * from Mobiledata";
var result = con.Query<TBMobileDetails>(query);
return result;
}
Where is the problem?
This problem occurs generally when there is an object / class / type named
Dapper
dapper
Do following steps to remove this issue
Create a Fresh Project and do NOT name anything in it with Dapper (case insensitive). Even if you change name of exiting 'dapper' object in your existing project then too it might create problems so its better to create a fresh project! I think it has something to do with assembly or hardcoding somewhere in dapper or visual studio (not sure!).
Use Nuget Manager again to Install Dapper.
It should work fine now.
My problem was that there was a namespace collision. Maybe a little obvious, but don't name anything "dapper" in your project.
I am trying to create a Solution from a single source file and tested different solutions.
One of them is the following:
var info = ProjectInfo.Create(
projectId,
version: VersionStamp.Default,
name: "TestProject",
assemblyName: "TestProject.dll",
language: LanguageNames.CSharp);
using (var ws = new CustomWorkspace())
{
var project = ws.AddProject(info);
}
But when running this code, I just get an exception saying that "language is not supported".
Any hint about what is happening?
You need to make sure Microsoft.CodeAnalysis.Workspaces.CSharp.dll is copied alongside your project. We detect that it's there and load it to provide C# support.