I get this error
Enlisting in Ambient transactions is not supported
when dedugging the code below in .net core 2 console app on my win 10 PC with VS 2017 15.3.2 (System.Data.SqlClient v4.4.0)
using (TransactionScope scope = new TransactionScope())
{
using (SqlConnection connection1 = new SqlConnection(_configuration["ConnectionString"]))
{
connection1.Open();
}
scope.Complete();
}
Transactionscope is part of the .net standard 2 and the code above was taken from microsoft's documentation
https://learn.microsoft.com/en-gb/dotnet/api/system.transactions.transactionscope?view=netcore-2.0
I think this has already been reported to Microsoft as an issue on GitHub
https://github.com/dotnet/corefx/issues/24282
Installing System.Data.SqlClient >= 4.8.2 should fix this issue.
Related
I am checking for an alternative of my automation framework that is built in UFT.
I came accross WinAppDriver tool. Looks promising.
But currently getting an error when it tries to launch the application under test-
{"Status":13, "Value":{"error":"unknown error","message":"failed to locate opened application with appid:"XXXXXX.jnlp" and processId:XXXX"}}
The application that i am trying to automate is a Java swing based application.
I tried running a simple java code in IntelliJ just to check whether i can have a quick working sample POC-
private static WindowsDriver appSession = null;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“app”, “XXXX.jnlp”);
capabilities.setCapability(“platformName”,”Windows”);
capabilities.setCapability(“deviceName”, “WindowsPC”);
capabilities.setCapability(“ms:waitForAppLaunch”, “20”);
appSession = new WindowsDriver(new URL(“http://127.0.0.1:4723”), capabilities);
Please help.
Thanks.
I'm using this section of this official MSDN tutorial: Use a SQLite database in a UWP app but I'm getting the following error:
REMARK: There are many online posts related (or similar) to this issue but none seems to have a solution. Most of these posts are a few years old so I thought this issue would have been resolved by now. Moreover, the above mentioned tutorial is using .NET Standard Class library project, as well. And the online posts regarding the issue do not have .NET Standard involved. So, I was wondering if the issue is caused by the use of .NET Standard library. Regardless, a solution will be greatly appreciated.
SQLite Error 14: 'unable to open database file'
Error occurs at line db.Open() of this code:
public static void InitializeDatabase()
{
using (SqliteConnection db =
new SqliteConnection("Filename=sqliteSample.db"))
{
db.Open();
String tableCommand = "CREATE TABLE IF NOT " +
"EXISTS MyTable (Primary_Key INTEGER PRIMARY KEY, " +
"Text_Entry NVARCHAR(2048) NULL)";
SqliteCommand createTable = new SqliteCommand(tableCommand, db);
createTable.ExecuteReader();
}
}
NOTES:
The line just below the above code reads: This code creates the SQLite database and stores it in the application's local data store. That means the app should have access to that local data store.
I'm using latest version 16.3.5 of VS2019 on Windows 10. The target version on the project is selected as Windows 10 1903 and min version as Windows 10 1903
UPDATE
This similar official 3 years old sample works fine. So, the problem seems to be related to newer versions of .NET Core. But I need to use latest version of .NET Core for other features my app is using that are not available in the older versions.
I also tried this similar old tutorial, but it did not on new version of .NET Core work either - giving exact same error.
The old problem reported in 2016 here to Microsoft seems to have resurfaced again with the new version of .NET Core.
This is a misunderstanding, SqliteConnection db = new SqliteConnection("Filename=sqliteSample.db") can not create a Sqlite file, but access the existing Sqlite database file through the path.
So you need to create a valid sqliteSample.db file and place it in the root directory of the UWP project. Select the content in the Properties -> Build operation to ensure it will be loaded into the application directory.
Update
Please create the sqliteSample.db file in LocalFolder first.
await ApplicationData.Current.LocalFolder.CreateFileAsync("sqliteSample.db", CreationCollisionOption.OpenIfExists);
Then use the path to access the database file
string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, "sqliteSample.db");
using (SqliteConnection db =
new SqliteConnection($"Filename={path}"))
{
// ...
}
Best regards.
We are developing applications in .Net Core and one of them require to access a serial port.
As I learned that System.IO.Ports won't be implemented in .Net Core, I was looking for a nuget library that supplies that functionality, but couldn't get one compatible with .net core (VS Code is showing an error message).
Is there any alternative out there?
UPDATE: I found that the official SerialPort API is being taken into consideration for porting to .Net Core (see https://github.com/dotnet/corefx/issues/984)
I managed to compile https://github.com/jcurl/SerialPortStream for netstandard1.5 with some minor modifications.
Have a look at the pull request: https://github.com/jcurl/SerialPortStream/pull/13
Experimental nuget package: https://www.nuget.org/packages/SerialPortStreamCore/2.1.0
This is now fully cross platform in 2021.
Simply NuGet install either using the command line or your IDE : "System.IO.Ports"
The following example is a .NET 5 console mode program that compiles and works on both Linux and Windows.
using System;
using System.IO.Ports;
namespace PipelinesTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Reading a GPS Device on COM3");
SerialPort _port = new SerialPort("COM3", 4800, Parity.None, 8, StopBits.One);
_port.DataReceived += PortOnDataReceived;
_port.Open();
Console.WriteLine("Press Return to Exit");
Console.ReadLine();
_port.Close();
_port.DataReceived -= PortOnDataReceived;
Console.WriteLine("Ended");
}
private static void PortOnDataReceived(object sender, SerialDataReceivedEventArgs e)
{
SerialPort port = sender as SerialPort;
var line = port.ReadLine();
Console.WriteLine(line);
}
}
}
NOTE: I should have mentioned when I first answered this, you'll need to change the "COM3" in the constructor above to something like "/dev/ttys0" or similar for Linux. You MIGHT also have to run your app as Root/SU on a Linux machine, this is just the nature of Linux's multi user security unfortunately.
I am having a really wired issue where I have created a new ASP.Net 4.6 web application (Visual Studio 2015 Community Edition) and everything works fine.
The app will compile without any issues at all but as soon as I try to run the app on the development machine (Windows 10 Enterprise) I get the following error every time and I cannot figure out why?
BC30002: Type 'ConnectionOptions' is not defined.
The code I am using is as follows:
Dim Options As New ConnectionOptions()
Options.Username = HttpContext.Current.Application("WMIUser")
Options.Password = HttpContext.Current.Application("WMIPsssword")
Dim scope As New ManagementScope("\\" & server_name & "\root\cimv2", Options)
scope.Connect()
Dim objectQuery As New ObjectQuery("SELECT FreeSpace FROM Win32_LogicalDisk where DeviceID=""" + deviceId + ":""")
Dim objectSearcher As New ManagementObjectSearcher(scope, objectQuery)
Dim objectCollection As ManagementObjectCollection = objectSearcher.[Get]()
For Each m As ManagementObject In objectCollection
Dim FreeSpace As Double = Convert.ToDouble(m("FreeSpace"))
Next
I have a reference to the System.Management DLL in the references for the application and I have an Imports declaration for it also.
Has anyone come across this before? My searching all leads back to the DLL not being referenced in the application but I have added and removed and re-added without any change.
Please help this is driving me nuts :-(
OK so this is a funny one, posting up just in case someone else comes across the issue.
The way I resolved this problem on the development machine was under References for the project, you have the option to copy local, set this to true and rebuilt the application, ran it and hey presto it all worked.
I can only assume that this could be a permissions thing but this works for the moment anyway.
Hope this helps someone in the future.
I am having problems connecting to a Sqlite database through System.Data.Sqlite. I was trying to use FluentNhibernate but that didn't work, so I went back to basics but got the same error: Cannot find entry point sqlite3_open_v2 in DLL sqlite3.
This is my (fairly simple I believe) code:
using (SQLiteConnection connection = new SQLiteConnection("Data Source=Stripper.s3db;Initial Catalog=main;"))
{
using (SQLiteCommand cmd = new SQLiteCommand("select * from album", connection))
{
cmd.Connection.Open();
object t = cmd.ExecuteScalar();
cmd.Connection.Close();
}
}
I have a reference to System.Data.SQLite so everything seems fine to me. The few explanations (you can barely call them tutorials) on the internet haven't helped me out.
It may be the version of Sqlite3 you are working against. The V2 methods are relatively new - introduced in v3.5
Another possible explanation is that you're using a 32 bit version of the provider in a 64 bit application.
I just downloaded v1.0.60.0 from the System.Data.Sqlite website (sqlite.phxsoftware.com/) which leads to http://sourceforge.net/project/showfiles.php?group_id=132486. As you can see there isn't much choice, so I can't think I'm doing anything wrong there. If I am not mistaken, Sqlite3 is included in System.Data.Sqlite so one would expect it to be the good version.
I am definitely working with the 32bit version on a 32bit application.
I have downloaded the installer and will try with that (I was using the binaries).