Unhandled exception error when running skm dotnet run command - c#

I've installed Splashkit SDK and .Net Core SDK following the instructions below.
https://splashkit.io/articles/installation/mac/step-2/
Im using C#.net framework by following the above instructions from the website.
Below is the code
using System;
using SplashKitSDK;
namespace test
{
public class Program
{
public static void Main()
{
Console.WriteLine("Hello, World!");
Window w = new Window("My First Program", 200, 100);
w.DrawText("Hello, World", Color.Black, 10, 45);
w.Refresh(60);
SplashKit.Delay(5000);
}
}
}
When I run the above code the Hello World prints to the console but the window object is not working. Screeshot attached with error code.
I tried adding as much information as I could, If theres anything i've missed please let me know.
I tried copying the shared library which is native to the usr/local/library but that did not work, I also tried what the error message has said, I'm not very expereinced so I might be doing it worng, I'm not sure.
I'm expecting a window to open with the hello world.

Related

Unable to view console/logging output when using Avalonia

I'm trying to print to stdout with Avalonia from inside my MainWindow.axaml.cs file. I'm unable to view the output of Console.WriteLine. This github ticket says to use System.Diagnostics.Debug.WriteLine, but that doesn't work either. It does however point to this wiki page about Avalonia's logging infrastructure, but that page doesn't have examples of using the logging. After some digging, I saw the following usages throughout a lot of Avalonia code
using Avalonia.Logging;
// ...
Logger.TryGet(/* event level */, /* log area */)?.Log(/* calling object */, "log string")
// example
Logger.TryGet(LogEventLevel.Warning, LogArea.Visual)?.Log(this, "TryGetPointAndTangentAtDistance is not available in Direct2D.");
I've tried specifying different LoggingLevels and LoggingAreas within the main method, as well as placing the logging before and after InitializeComponent in the constructor, but nothing seems to work.
Steps to reproduce:
create new dotnet app with Avalonia.MVMM template
Place any of the mentioned logging attempts (writeline, system diagnostics, avalonia.logging) inside of Views/MainWindow.axaml.cs
dotnet run will open up the welcome to Avalonia window, but the console won't have any output.
Attaching a debugger (VS Debugging or Rider) and viewing the Debug output will show anything logged via Logger.TryGet and System.Diagnostics.Debug.WriteLine. Creating a new project and with the following MainWindow.axaml.cs:
using Avalonia.Logging;
public partial class MainWindow : Window
{
public MainWindow()
{
Logger.TryGet(LogEventLevel.Fatal, LogArea.Control)?.Log(this, "Avalonia Infrastructure");
System.Diagnostics.Debug.WriteLine("System Diagnostics Debug");
InitializeComponent();
}
}
Shows the following output in the Rider debug output:
...
[Control] Avalonia Infrastructure (MainWindow #33726620)
System Diagnostics Debug
...

How do I add Hyperlinking in NUnit Test Output?

I want to be able to add hyperlinks to relevant data in the output for a unit test.
I have the following test:
using NUnit.Framework;
namespace BioFire.PanelSoftware.Service.Tests
{
[TestFixture]
public class SimpleTest
{
[Test]
public void Test1()
{
Console.WriteLine("www.google.com"); //not hyperlink
Console.WriteLine(#"C:\Program Files"); //not hyperlink
throw new Exception("My output window will somehow give me a hyperlink to here.");
}
}
}
According to this question, it isn't possible in C#. But it is clearly working for nUnit somehow:
This is very specific to the terminal you are using and I don't believe anything in C# can achieve clickable text. You can technically use Process.Start() from the System.Diagnostics namespace to trigger the default browser to open the webpage you want, but this isn't a hyperlink and would rather be triggered by your specifications
If you are running from within an IDE, you would have to look into the underlying shell and try to swap it out for a different profile (ex. this should be easy on VS Code but I'm unsure if Visual Studio can support it). If you are running from cmd line, then try using the new Windows Terminal App as it supports this functionality

Notepad ++: CS script Error CS0009 for reading CoolProp.dll file

Some background: I am a newbie to C# and programming in general. Utilizing notepad ++ for my script writer and compiling the program through the command prompt. I am using the CS-script plug in for building CS projects. I am a full time mechanical engineer and trying to utilize an open source alternative to Refprop which is CoolProp (https://github.com/CoolProp/CoolProp) for pulling fluid properties for refrigeration equipment sizing. Trying to develop tools for myself in component evaluation in design.
The problem: I have saved the CoolProp.dll file in the same location to the CS script that I am writing. The CS-Script has found the .dll file for reference but still outputs a CS0009 error. I have tried to trouble shoot the issue by looking through the CoolProp, CS-Script, and CS0009 error discussions on stack overflow. No luck...
Below is my source code (not much written because I am trying to troubleshoot this issue):
//css_args /ac
using System;
using CoolProp;
public class SystemTools.cs
{
public static void Main()
{
double p;
p = CoolProp.PropsSI("P", "T", 300, "D", 1, "Propane");
}
}
Thanks for the help in advance everyone.

Bitmap cannot be found

I'm looking at creating a small program in C# that takes in an image, crops it and spits out the cropped image as a new image.
I'm just getting started with the program and I'm having some errors regarding System.Drawing and the Bitmap data type.
I've declared a Bitmap object in main() and receive this error:
So next thing I try is declaring using System.Drawing.Common;. Doing so gives me this error:
I am serious stumped with what to do as I can't seem to find anything online. Any help would be amazing!
If it helps, I'm using Visual Studio Code to write my code and my OS is MacOS Catalina. I've also attached the full code file. Its not much but that's all I've got.
Thanks in advance!
using System;
using System.Drawing;
using System.Drawing.Common;
namespace consoleproject
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Bitmap bitmap = new Bitmap();
}
}
}
It seems you are missing the System.Drawing.Common package. It is not added by default in .Net core projects. To add it:
dotnet add package System.Drawing.Common

C# ChromeDriver throws exception when executed dynamically by reflection

I'm trying to execute test program which uses selenium web driver in custom test runner.
In the test runner, selenium web driver equiped test method is invoked by reflection.
When the test program is run by Visual Studio Test Explorer, it works fine.
Problem occurs when it is run dynamically by reflection.
The test program is as follows.
namespace TrialWebUnitTest
{
public class WebDriverTest01
{
private IWebDriver driver;
[TestMethod]
public void NavigateToSeleniumHQByChrome()
{
string TargetUrl = "https://www.seleniumhq.org/projects/webdriver/";
this.driver = new ChromeDriver();
driver.Manage().Window.Size = new System.Drawing.Size(1000, 800); // <- driver throws exception here.
this.driver.Navigate().GoToUrl(TargetUrl);
this.driver.Dispose();
}
}
}
The custom test runner's core test executing method is as follows.
namespace TrialWebUnitTestRunner
{
public partial class TestForm : Form
{
// test button click's event handler.
private void TestButton_Click(object sender, EventArgs e)
{
string retErrorMsg = string.Empty;
if (!ExecTestDynamically(ref retErrorMsg))
{
// show error information in UI textbox.
this.this.ResultMessage.Text = retErrorMsg;
}
}
internal bool ExecTestDynamically(ref string retErrorMsg)
{
var target = new TrialWebUnitTest.WebDriverTest01();
System.Type targetType = typeof(TrialWebUnitTest.WebDriverTest01);
var method = targetType.GetMethod("NavigateToSeleniumHQByChrome");
try
{
method.Invoke(target, null);
return true
}
catch (Exception exp)
{
retErrorMsg = exp.Message + Environment.NewLine + exp.StackTrance;
return false;
}
}
}
}
Exception information
System.InvalidOperationException:
disconnected: unable to connect to renderer
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.31.488763
Sample program
I've written a sample program to reproduce the error.
Please download it from my dropbox url: https://db.tt/HqUTMOKWBl
You can click the link and download 'TrialWebTestForInspection.zip'.
Please extract it in any arbitrary folder and find TrialWebTestForInspection.sln.
The solution consists of two projects, "TrialWebUnitTest" and "TrialWebUnitTestRunner".
The first one is MS Unit Test, and you can run 3 test methods from Visual Studio Test Explorer.
The 3 test methods are very simple. They just launch the browser correspond to the webdriver, and navigate to Selenium HQ site.
The other project is a WindowsForm application which provide a very simple test runner.
It kicks the test methods in previous test project.
When you choose the test method using IE or FireFox driver, it works fine.
On the other hand, when you choose Chrome driver test, it thows exception which I mentioned above.
Things I'd like to know.
First I'd like to know, if it is a bug of current Chrome driver version, or it is a part of specification.
Then I'd like to know, if there is a way to avoid this problem or not.
What I'm afraid of is the possibility that IWebDriver specification originally does not support correct action whent it is run by reflection.
spec of sample program
.NET Framework version 4.6.1
nuget package
MSTest.TestFramework.1.2.0 MSTest.TestAdapter.1.2.0
Selenium.WebDriver.3.11.0 Selenium.WebDriver.ChromeDriver.2.37.0
Selenium.WebDriver.IEDriver.3.11.1 Selenium.Firefox.WebDriver.0.20.0
Chrome Browser version 65.0.3325.181(Official Build)(64 bit)
The problem was solved. Please refer to this.
The custom TestRunner application didn't refer to the latest chrome-driver version. I had to install selenium.webdrivers not only to the testclass, but also to the testrunner program.
For further information, please refer to the following issue in GitHUB.
https://github.com/SeleniumHQ/selenium/issues/5705

Categories

Resources