I am currently converting C#/Selenium test suites from .NET to .NET Core
Prior to conversion this little bit of code worked fine in one suite.
public void ClearConsoleErrors()
{
IJavaScriptExecutor js = (IJavaScriptExecutor)Driver;
String script = "console.clear();";
js.ExecuteScript(script);
Driver.Manage().Logs.GetLog(LogType.Browser);
}
Now we get this error
System.NullReferenceException: 'Object reference not set to an instance of an object.'
The error happens on this line - Driver.Manage().Logs.GetLog(LogType.Browser);
And ideas folks?
Related
I have downloaded the NuGet package Arduino Uploader (https://www.nuget.org/packages/ArduinoUploader/), and receive the following error when trying to run it using the example on the github page (https://github.com/twinearthsoftware/ArduinoSketchUploader) under the .Net package.
The code is as follows
var upload = new ArduinoSketchUploader(
new ArduinoSketchUploaderOptions()
{
FileName = #"location of the file",
PortName = "COM7",
ArduinoModel = ArduinoModel.Micro
});
upload.UploadSketch();
The error of Exception unhandled occurs on the upload.UploadSketch(); line giving off
ArduinoUploader.ArduinoUploaderException: 'Exception during close of the programmer: 'Object reference not set to an instance of an object.'.'`.
The details copied from Visual Studio are `ArduinoUploader.ArduinoUploaderException
HResult=0x80131500
Message=Exception during close of the programmer: 'Object reference not set to an instance of an object.'.
Source=ArduinoUploader
StackTrace:
at ArduinoUploader.BootloaderProgrammers.Protocols.AVR109.Avr109BootloaderProgrammer.Close()
at ArduinoUploader.ArduinoSketchUploader.UploadSketch(IEnumerable`1 hexFileContents)
at ArduinoUploader.ArduinoSketchUploader.UploadSketch()
at arduino_sending_code.Program.Main(String[] args) in C:\Users\User\source\repos\arduino sending code\arduino sending code\Program.cs:line 39
This exception was originally thrown at this call stack:
[External Code]
arduino_sending_code.Program.Main(string[]) in Program.cs
Are there any suggestions to overcome this error?
The error you recieved is due to a dodgy hex file. You need to find the hex file from temp folder on your computer where the computer places them. Thats the only file which works. Also later on you might face an issue with another error, make sure you have the right programmer on the arduino, the details are avilable under the bootloader column on the ArduinoUploader github page.
I am working on a application which needs to communicate via COM interface with multiple CAD applications (not in the same time). I want to have nice and reusable code, but I came across problems with type casting of COM objects when I made generic application handle getter method.
What I tried so far:
This is the attempt I would like the most if it worked.
public static TCadAppType CadApp<TCadAppType>()
{
dynamic cadApp = default(TCadAppType);
//Here under Dynamic View/Message there is already an error
// Message = "Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))"
// cadVersion.Value evaluates to "SldWorks.Application"
cadApp = (TCadAppType)Marshal.GetActiveObject(cadVersion.Value);
//Following 2 lines of code are for testing purposes only, i am testing with Solidworks API
AssemblyDoc Assembly;
//The exception is thrown when I try to access some method from the Solidworks API
Assembly = (AssemblyDoc)cadApp.OpenDoc6("some parametras...");
}
Attempt using Convert class
// Another attempt using Convert class
public static TCadAppType CadApp<TCadAppType>()
{
dynamic cadApp = default(TCadAppType);
// cadVersion.Value evaluates to "SldWorks.Application"
cadApp = Marshal.GetActiveObject(cadVersion.Value);
cadApp = Convert.ChangeType(cadApp, typeof(SldWorks.SldWorks));
// Exception is thrown with the following message:
// Message = "Object must implement IConvertible."
}
I really thought that I am on the right track, since there is an article on Microsoft Docs website explaining how dynamic can help you with com interopt: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/types/using-type-dynamic#com-interop
Any ideas how I can do this runtime casting a keep my code as reusable as possible?
My software setup:
Win 10
Project is targeted for .NET 4.7.2
First Tests are with Solidworks 2019
Turns out that the my coding attempt 1 was valid c# code indeed.
I tried it using with Autodesk Inventor, and it works.
So the only thing left for me is to conclude that this is some bug from Solidworks and their COM interfacing.
Thank you Optional Option for your interest in the topic.
I have the following code in my class that extends IWizard:
public void ProjectFinishedGenerating(Project project)
{
MessageBox.Show(project.Name);
}
But it gives me the error:
System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object.
Saying that project is null. Which is right according to my debugger. However, what on earth causes this? I would've thought the method only gets called with a non-null project. How can I fix this?
today i was trying to add Ninect.web.common to my project but surprisingly i received a strange error for the first time:
My project is running well and no build error at all, but as i try to add this package, i receive this error:
********** Action *********
public ActionResult Index()
{
......
return View((object)totalValue);
}
************** View **********
#model decimal
<div>
Total value:#Model
</div>
Error CS7003 Unexpected use of an unbound generic name
Error CS0037 Cannot convert null to 'decimal' because it is a non-nullable
Two errors are referencing the first line of view!
I removed previously installed Ninject packages and installed all of them form scratch!
Installation completed and now i can use Ninject in my project.
This error appears again if i try to update packeges!
I want to know if it's possible to get / know the current page in wpf.
In my project, I put this code and I have the correct page:
var current_page = (Window.Current.Content as Frame).Content.GetType();
Windows.Current.Content was null.
But in my UI Test project, I have the following error:
Result Message:
Test method CodedUITestProject1.CodedUiTest.CodedUITestMethod1 threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.