I try to use Sikuli Integrator for C#.
I create new project in Visual Studio 2015, and I Install SikuliIntegrator.
After the installation JSikuliModule.jar, it will be part of my solution, together with some additional files. After that Properties to set “Copy to Output Directory” property to “Copy always” of JSikuliModule.jar
and then I try my code :
class Program
{
static void Main(string[] args)
{
String pattern = #"C:\\Users\\amin-\\Documents\\Visual Studio 2015\\Projects\\SikuliTest\\SikuliTest\\img\\logo.png";
SikuliAction.Click(pattern);
//if (SikuliAction.Exists(pattern).IsEmpty)
//{
// Console.WriteLine("Nope! It's gone...");
//}
//else
//{
// Console.WriteLine("Yep! It's there...");
//}
}
}
If I run the code, this is the errors shows :
An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll Additional information: Access to the path 'C:\SikuliOutputLog.txt' is denied.
If I run the code as an administrator, this is the errors shows :
An unhandled exception of type 'System.Exception' occurred in SikuliModule.dl Additional information: ###FAILURE
Manually create a text file 'C:\SikuliOutputLog.txt' then run the code.
It works for me.
In Windows10 besides manually adding C:\SikuliOutputLog.txt you need also to make sure current user have the 'Write' control to this file.
Related
I was playing with my "Debug -> Options -> Debugging -> General -> Enable Just my code" checkbox
When I check it everythng works fine but when I uncheck it I get the following:
A first chance exception of type 'System.EntryPointNotFoundException'
occurred in mscorlib.dll
Additional information: Unable to find an entry point named
'EventSetInformation' in DLL 'advapi32.dll'.
Method:
public IEnumerable<TEntity> GetAll()
{
return Context.Set<TEntity>().ToList();
}
I have no idea what it means, and anything I search on internet is based on some C++ projects - any ideas?
I get the following error at runtime from a C# WPF application:
A first chance exception of type
'System.Windows.Markup.XamlParseException' occurred in
PresentationFramework.dll
Additional information: 'Set property
'System.Windows.Controls.ContentControl.Content' threw an exception.'
Line number '6' and line position '6'.
How can I find which file this is associated with? The Visual Studio solution contains two XAML files, app.xaml and MainWindow.xaml.
I am using VS 2010 on Windows 7. The application targets .NET 4.0.
UPDATE:
Following up on Kasper's helpful suggestion, I displayed the exception in detail, and this is what it showed:
Based on the information in there, I was able to gather that a certain DLL was missing. Supplying the DLL fixed this problem, but I still have other XAML parse errors coming up.
In the code-behind, the XAML code is parsed in the method InitializeComponent which is automatically generated. This method is called in the Window object's constructor. So to have more details about the exception, put the call to InitializeComponent in a try/catch block. This way, you have access to the useless XamlParseException, but also to its InnerExceptions and to the StackTrace.
UPDATE!
You can call the inner exception using a MessageDialog.
public partial class Window1 : System.Windows.Window
{
public Window1()
{
try
{
InitializeComponent();
}
catch ( Exception ex )
{
// Log error (including InnerExceptions!)
// Handle exception
MessageDialog dialog = new MessageDialog(ex.InnerException);
dialog.ShowAsync();
}
}
}
Hope that helps :)
There is also another trick to this:
Open the "Exceptions" window (Debug/Exceptions) in Visual Studio.
Click "add"
Add "System.Windows.Markup.XamlParseException"
Check the box to break on throw for this exception.
Hit F5!
You'll find that the XamlParseException you catch is much more descriptive, and will give the correct position in the xaml file.
Let me know if this was easier :)
Trying to recognise a set of images in a folder (using Puma .NET OCR library), the first image is recognised successfully, but after that I get an error:
An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in Puma.Net.dll
Additional information: <0x00000000>: ?????? ???.
I have a special class for recognition, and the error happens on this line:
Puma.Net.PumaPage inputFile = new Puma.Net.PumaPage(imagePath);
I found this link and this one, but they don't seem to help in my case.
Thank you
I found the answer by using 'using' statement
using(Puma.Net.PumaPage inputFile = new Puma.Net.PumaPage(imagePath))
{
}
Is there a way to persist CS-Script internal assembly cache between subsequent application's runs?
Used component: http://www.csscript.net/
The desired behavior is:
when I compile an assembly form a script string and I close the application, the next time I run the application the compiled assembly with matching script string is found and no recompilation is needed.
This question is follow-up of another question:
Is there a way to call C# script files with better performance results?
Here is my code, but every script string requires recompilation with every restart of parent .NET application.
public interface ICalculateScript
{
Exception Calculate(QSift qsift, QSExamParams exam);
}
...
void Calculate(string script)
{
CSScript.CacheEnabled = true;
//Can following command use built-in cache to load assembly, compiled by this line of code, but by another instance of this app which run in the past and has been meanwhile closed?
Assembly assembly = = CSScript.LoadCode(script, null);
AsmHelper asmHelper = new AsmHelper(assembly);
ICalculateScript calcScript = (ICalculateScript)asmHelper.CreateObject("Script");
calcScript.Calculate(this, exam);
}
Related problem:
The folder of temp scripts created by Cache in CS Script C:\Users\vdohnal\AppData\Local\Temp\CSSCRIPT\Cache\2015108000 has 41 MB and growing with files few months old.
In the output window of WPF App there are first chance exceptions:
A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll
'ESClient.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\vdohnal\AppData\Local\Temp\CSSCRIPT\Cache\2015108000\af621e10-d711-40d7-9b77-0a8e7de28831.tmp.compiled'
C:\Users\vdohnal\AppData\Local\Temp\CSSCRIPT\Cache\2015108000
I got an answer fom Oleg Shilo which pointed me in the right direction:
The cache folder indeed grows as new scripts are compiled/loaded. This
is the nature of the caching. It seems that it "grows without control"
though it is not. Once cache is created for a given script file it is
never duplicated and the new cache update is always written over the
existing one.
The problem in your case is that every time you load the file you give
it a unique name thus you are creating a new unique cache. To fix it
you need to start using the same name for the script file every time
you load/execute it.
Alternatively you can completely take over the caching location and
specify what ever cache name you want. It is that second parameter
that you pass null for:
Assembly assembly = CSScript.LoadCode(script, null);
I used following code:
if (assemblyFileName == null)
assembly = CSScript.LoadCode(script, null); //In case there is no name specified - when my custom temp folder cannot be created etc.
else
assembly = CSScript.LoadCode(script, assemblyFileName, false, null); //Specify full path and file name with extension
Thanks to this I have complete control over cached assembly name and location.
If cached assembly with appropriate script already exists, I can simply load it instead of compiling a new one:
Assembly assembly = Assembly.LoadFrom(assemblyFileName);
AsmHelper asmHelper = new AsmHelper(assembly)
The speed of initial loading is better and there is no uncontrollably growing cache.
I am trying to add an image to a button (C# Winform, VS2010). I have added the resource by Adding Existing Item in the Resources.resx file. I then assign my image to the button and all appears well. When i run my program i get:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: Could not load file or assembly 'BmsReplayAnalysis.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
in this code:
public static System.Drawing.Bitmap play1 {
get {
object obj = ResourceManager.GetObject("play1", resourceCulture); <-- DIES HERE
return ((System.Drawing.Bitmap)(obj));
}
}
Can anyone tell me what i am doing wrong?
When you just give it a name of a file, when you run it, it looks for it in the folder that it is running out of. If you are running in debug mode, it will look for play1 inside the debug folder. if its not there its an error.