Xamarin unable to connect to mysql - c#

db is my MySqlConnection. When I'm trying to run: db.Open(); I get this error:
The type 'System.Data.Common.DbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”.
So I followed it and added System.Data reference. Now I get this error:
Reference to type 'Component' claims it is defined in System but it could not be found
I am using .NET Framework v4.0, MySQL Connector v6.9.9, Xamarin Forms v2.3.2.127 and all Android Support v23.4.0.1
P.S. I read something about PCL but I don't know if the package I am using i PCL.

Please specify database name in connection string
Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;
Pwd=myPassword

Maybe it's not a great solution, but I moved entire code to specific Android project and it works perfectly.

Related

OpenSilver with Service References

Im trying to migrate a Silverlight application to OpenSilver.
The application uses WCF service references that are included in the project.
I followed the OpenSilver example on migrating from Silverlight to OpenSilver
https://doc.opensilver.net/documentation/migrate-from-silverlight/example.html
After wrapping the application with the OpenSilver files I get an error that my services namespace could not be found, then when trying to add that missing service reference to the project I get "The target framework 'netcoreapp2.0' is out of support"
Is there a step I am missing in setting this up?
If you get the error because you copy-pasted the server references as well
If you double click that error it should bring you to the Reference.svcmap file of your WCF service reference. Find the Reference.cs file in Solution Explorer next to Reference.svcmap.
Open it and you will see the same error multiple times in the code:
"The type name 'IHttpCookieContainerManager' could not be found in the namespace 'System.ServiceModel.Channels'. This type has been forwarded to assembly 'System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly."
Solution: add the following nuget package: System.ServiceModel.Http
If you try to add a new service reference then follow this workaround: https://github.com/dotnet/wcf/issues/4766#issuecomment-1007859628
I hope that helps.

Error when using RazorTemplates library: 'CS0012: The type 'System.Attribute' is defined in an assembly that is not referenced'

On some machines, executing a razor template via RazorTemplates works OK.
On others, I receive the following message:
TemplateCompilationException
error CS0012: The type 'System.Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Info:
This is within a WPF application running on .NET 4.7.
The assembly has a reference to System.Runtime.4.3.0\lib\net462\System.Runtime.dll (v4.1.1.0)
However at runtime, this assembly does not show up in the 'Modules' list.
It seems the Attribute object exists in both System.Runtime and mscorlib.
Looks like this is an underlying issue somewhere between win10 and the RazorTemplates library.
In the end i switched from RazorTemplates to RazorEngine: https://github.com/Antaris/RazorEngine
And there is a page here that explains how to fix the problem via a Resolver:
https://github.com/Antaris/RazorEngine/issues/416
System.Runtime is part of the .Net Framework and is installed in the GAC during framework installation.
This could happen for two possible reasons:
It's not on the machine.
It's the wrong version.
For the machines this fails on check what version of the .Net runtime they have and/or inspect the GAC for this file and version.
Missing the framework, install it. :-)
If machines have a version but it's not the expected version do either:
Install the correct framework version
Use a binding redirect in your config file

Creating a library for ASP.NET Core, but using System.Data.SqlClient

I want to create a library for ASP.NET Core in VS17 that uses System.Data.SqlClient for accesing database. I picked .NET Core Library Class.
The problem is that I'm getting errors like :
CS0012 The type 'Object' is defined in an assembly that is not >referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, >Culture=neutral, PublicKeyToken=b77a5c561934e089'.
On stackoverflow I found a thread with advice to add NuGet package : Microsoft.NETCore.Portable.Compatibility, but then it just throws following exception :
FileNotFoundException: Could not load file or assembly 'System.Data, >Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
I tried getting other library types like .NET Standard or .NET Framework, but I am also getting errors e.g. some types from standard System.Data.SqlClient are unavailable.
Is there a way to create a library for ASP.NET Core that uses SqlClient for accesing database then?
I had a similar problem of your.
Try simply run dotnet restore myProjectName on package manager console or on command prompt.
In this way the packages and SDK's on your project are download and reference problems will go away.

Can you use Microsoft.AspNet.SignalR.Client with .NET Core (dnxcore)

This could be a simple No if it's not possible, so first I'll ask outright, Is it possible to use Microsoft.AspNet.SignalR.Client with dnxcore50 right now?
If it should be possible, details of the error I'm hitting are below, this a vNext Console Application:
After adding a dependency on Microsoft.AspNet.SignalR.Client version 2.2.0 the code compiles correctly for dnx451, however for dnxcore50, I am getting an error that I can't seem to figure out:
var hubConnection = new HubConnection("http://localhost");
IHubProxy hubProxy = hubConnection.CreateHubProxy("MyHubName");
Visual Studio underlines the CreateHubProxy() method with the error:
The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'
Obviously as I want to use dnxcore50 I can't just add a reference to mscorlib. I'm trying to figure out if there's something under System that I should referencing here or if this package is just not compatible.
I've found out that at the moment, there's no (reasonably simple) way to get this running on dnxcore50.
I asked Scott Hanselman on Twitter too and he confirmed that you can't right now.
With this I will continue to use the vNext Console Application project so that when the SignalR Client Libraries offer support it should be the case of a config change and package update to run this on both Linux and Mac using .NET Core

Xamarin Studio iOS assembly error

After I updated my Xamarin Studio (iOS) it gives me this error when trying to build/debug.
I ain't got no clue how to fix this, would appreciate some help
Error:
The type 'MonoTouch.UIKit.UIView' is defined in an assembly that is not referenced.
Consider adding a reference to assembly 'monotouch, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null'
I am using "AlexTouch.MBProgressHUD.dll" and I have added it to my usings.
The public key token of monotouch.dll changed in Xamarin.iOS 6.2 (it's not null anymore).
You'll need to recompile bindings (or assemblies) that refers to monotouch.dll or use the tool (from this thread) to update them.

Categories