I am using SikuliCSharp package v1.1.2 in Visual Studio 2015
I am trying to do following:
using (var session = Sikuli.CreateSession())
{
var pattern = Patterns.FromFile(#"C:\pathtoimage\image.png");
var value = session.Click(pattern);
}
But while running i get an exception:
An unhandled exception of type 'SikuliSharp.SikuliFindFailedException' occurred in SikuliSharp.dll.
Additional information: [error] Image: Image not valid, but TextSearch is switched off!
How to resolve this problem?
It should work if you delete var value = in front of session.Click(pattern);
Related
I have the following test
[TestMethod]
public void Render_WithDateTimeNow_ReturnsFormattedString()
{
var template = #"C:\temp\#(DateTime.Now.AddDays(-1).ToString(""yyyy_MM_MMMM\\dd"")).csv";
var result = new FilePathRenderer().Render(template);
result.Should().Be(#"C:\temp\" + DateTime.Now.AddDays(-1).ToString("yyyy_MM_MMMM\\dd") + ".csv");
}
The Render method looks like this:
public string Render(string filePath)
{
lock (renderLock)
{
var result = RenderAsync(filePath).GetAwaiter().GetResult();
return HttpUtility.HtmlDecode(result);
}
}
When running this test in visual studio 2019, it passes perfectly.
But when opening the same solution and running the same test without modification in visual studio 2022, it fails with the following error:
FilePathRenderer_Test.Render_WithDateTimeNow_ReturnsFormattedString threw exception:
Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with 'LanguageVersion 10.0 specified in the deps file could not be parsed.
', and was translated to Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException to avoid terminating the process hosting the test.
What could be the issue here?
Thanks in advance
When I use IronPython to call my Python method, it thrown an Exception:
An exception of type “IronPython.Runtime.Exceptions.TypeErrorException” occurred in Microsoft.Dynamic.dll but was not handled in user code
Other information: unsupported operand type(s) for +=: 'bytearray' and 'str'.
Here are my C# code:
public static void doPython()
{
ScriptEngine engine = Python.CreateEngine();
var paths = engine.GetSearchPaths();
paths.Add(#"D:\WorkSoft\ATTOptimize\test_python\");
paths.Add(#"D:\Python\Lib");
paths.Add(#"D:\Python\Lib\site-packages");
//my python installed in "D:\Python"
engine.SetSearchPaths(paths);
engine.ExecuteFile(#"D:\WorkSoft\mysqlConnection.py");
}
And this is my Python code:
import mysql.connector
from datetime import date, datetime, timedelta
cnx = mysql.connector.connect(user='root', password='1qaz2wsx', host='127.0.0.1', database='db_mes')
cursor = cnx.cursor()
query = "SELECT testId,testResult FROM db_mes.test "
cursor.execute(query)
for (testId,testResult) in cursor:
print testId,testResult
cursor.close()
cnx.close()
When I run my c# code it thrown that exception, can anyone tell me why? Thank you.
First time using SQLite, opted for SQLite.net-pcl,
I have a PCL library, that I consume from my UWP app, my PCL library has the DBContext class :
public NewspaperDataContext(ISQLitePlatform sqLitePlatform, string applicationPath, string dataBaseName)
{
_sqlConnection = new SQLiteAsyncConnection(()=> new SQLiteConnectionWithLock(sqLitePlatform,
new SQLite.Net.SQLiteConnectionString(Path.Combine(applicationPath, dataBaseName), storeDateTimeAsTicks: false)));
CreateTableAsync(_sqlConnection, typeof(Article)).Result.Wait();
CreateTableAsync(_sqlConnection, typeof(Author)).Result.Wait();
CreateTableAsync(_sqlConnection, typeof(Category)).Result.Wait();
CreateTableAsync(_sqlConnection, typeof(Group)).Result.Wait();
var c = _sqlConnection.Table<Article>();
}
private async Task<Task> CreateTableAsync(SQLiteAsyncConnection asyncConnection, Type table)
{
return asyncConnection.CreateTableAsync<Author>().ContinueWith((results) =>
{
Debug.WriteLine(!results.IsFaulted
? $"Error where creating the {nameof(table)} table !!"
: $"Table {nameof(table)} created sucessfully!");
});
}
I call the NewspaperDataContext from my UWP app like this :
private async void MainPage_OnLoaded(object sender, RoutedEventArgs e)
{
var n = new NewspaperDataContext(new SQLitePlatformWinRT(), ApplicationData.Current.LocalFolder.Path, "LiberteDB");
}
In the NewspaperDataContext constructor at the line :
var c = _sqlConnection.Table<Article>();
A strange MissingMethodException is thrown saying :
An exception of type 'System.MissingMethodException' occurred in
SQLite.Net.Async.dll but was not handled in user code
Additional information: Method not found: 'Void
SQLite.Net.SQLiteConnectionString..ctor(System.String, Boolean,
SQLite.Net.IBlobSerializer, SQLite.Net.IContractResolver)'.
Couldn't find anything related to this error in the internet, please can someone help.
The package sqlite-net-pcl should be added to only to PCL project. If you add it to any other platform such as Android, it will give this MethodMissingException. So, remove the package from other platforms as this package is required only for PCL project. I am giving this answer as I encountered the same issue and found the solution. I encountered this exception while developing apps using Xamarin.Forms.
I have a C# Model Class where I am trying to access a .cshtml page which is supposed to be an email format template. I'm using the following code:
string body = string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailConfTemplate.cshtml")))
{
body = reader.ReadToEnd();
}
But i am getting the following error message:
The name Server does not exist in the current context
Is there any error in the code or the Server class can't be accessed in POCO class. Please help.
To execute it inside a .Net pipeline, you can find it as an instance present in HttpContext
System.Web.HttpContext.Current.Server.MapPath()
Instead of
Server.MapPath("~/EmailConfTemplate.cshtml")
Try using
string fullPath = new DirectoryInfo(string.Format("{0}\\EmailConfTemplate.cshtml", HttpContext.Current.Server.MapPath(#"\"))).ToString();
I was executing code below :
class Program
{
static void Main(string[] args)
{
PerformanceCounter performanceCounter = new PerformanceCounter("Network Interface", "Bytes Sent/sec", "Intel(R) 82579V Gigabit Network Connection");
Console.WriteLine(performanceCounter.NextValue().ToString());
}
}
I'm getting this exception.
An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll
Additional information: Instance 'Intel(R) 82579V Gigabit Network Connection' does not exist in the specified Category.
I have tested the parameters with windows perfmon tool , it was working but in code its giving exception.
Can anybody please help..
Have you checked if the name is spelled correctly? Even with a minor error, this most likely won't work.
To check which names exist in this category, try (as suggested here: https://stackoverflow.com/a/29270209/1648463)
PerformanceCounterCategory category = new PerformanceCounterCategory("Network Interface");
String[] instancename = category.GetInstanceNames();
foreach (string name in instancename)
{
Console.WriteLine(name);
}
For example, one of the existing names for network interfaces on my computer is
Intel[R] 82579LM Gigabit Network Connection
(with brackets instead of round brackets).