exception while changing cursor - wpf

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type 'filehelpertest.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.
Hi all,
i'v wanted to change my grid's cursor to a custom one using this code:
//using resources is already in the references assembly
Cursor gameCursor = new Cursor(Application.GetResourceStream(new Uri("pack://application:,,,/Pictures/Cursor.cur")).Stream);
MenuGrid.Cursor = gameCursor;
but for some reason this exception jumps when im running the program.
the .cur file has been added to the project and marked as a resource.
any ideas?

Related

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Cannot read property 'defaultView' of undefined [duplicate]

I am trying to use Selenium for Python eith the Chrome webdriver to automate the download of a file.
My program works perfectly up to the last step (clicking on the 'download' button) at which point a dialog box is triggered with the text:
"An error has occured in 'site url': Uncaught TypeError: Cannot read property 'getColomnSet' of undefined41"
What does this error mean and what are the most probable causes?
For reference, here are the last few commands of my program:
try:
elem = wait.until(EC.presence_of_element_located((By.ID,'element_1_id')))
finally:
elem1 = driver.find_element_by_id('element_1_id')
elem2 = driver.find_element_by_id('element_2_id')
action = ActionChains(driver).move_to_element(elem1).move_to_element(elem2)
action.perform()
elem2.click()
This error message...
An error has occured in 'site url': Uncaught TypeError: Cannot read property 'getColomnSet' of undefined
...implies that your program was unable to read the property getColomnSet while trying to download the desired file.
Possibly, the main problem is the js involved to download the document is invoked before the client renders the HTML DOM completely.
The relevant HTML, a bit more of your previous lines of code and the error stack trace would have given us some more idea about what's going wrong.
Solution
You can induce some measures to wait till the complete DOM Tree is rendered following the discussion:
Generic funtion to check if page has completely loaded in Selenium
A couple of facts:
In your code trials I don't see you interacting with the element (By.ID,'element_1_id') so possibly you can remove the step of presence_of_element_located() for the element (By.ID,'element_1_id').
If you still require presence_of_element_located((By.ID,'element_1_id')) catch the exception and initiate required steps.
As you invoke move_to_element() over elem1 and elem2 and moving ahead invoke perform() you need to induce WebDriverWait with expected_conditions as element_to_be_clickable(locator)
tl;dr (references)
Cannot read property 'getContext' of null, using canvas
Uncaught TypeError: Cannot read property 'getContext' of undefined
Uncaught Error remote.js
Try the following - it works on Salesforce Lightning UI screens:
WebElement element = driver.findElement(By.id("your ID"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll Additional information: Could not find file

I don`t know where to find it was!
Program was working properly, but once it happened
Private Sub InserPP_Load(sender As Object, e As EventArgs)HandlesMyBase.Load
'TODO: This line of code loads data into the 'DataSet2.plump' table. You can move, or remove it, as needed.
Me.PlumpTableAdapter.Fill(Me.DataSet2.plump)
End Sub
An unhandled exception of type System.Data.OleDb.OleDbException occurred in System.Data.dll
Additional information:
Could not find file 'F:\proj visual\test1\test1\bin\Debug\plump.accdb'.

How to use ReactiveUI with WinForms

I have decided to learn ReactiveUI after seeing what can be done with it, but my enthusiasm has been broken at the first attempt to run a simple project. I have recreated the example from this article, using reactiveui-winforms.Net40 version 6.5.0 from NuGet. Everything compiles ok, but i get an exception during runtime at the following line
var OKCmdObs = this.WhenAny(vm => vm.EnteredText,
s => !string.IsNullOrWhiteSpace(s.Value));
System.InvalidOperationException occurred
HResult=-2146233079
Message=The current thread has no Dispatcher associated with it.
Source=System.Reactive.Windows.Threading
StackTrace:
at System.Reactive.Concurrency.DispatcherScheduler.get_Current()
at ReactiveUI.PlatformRegistrations.<>c.<Register>b__0_7() in C:\workspace\git-perso\ReactiveUI\ReactiveUI\Platform\Registrations.cs:line 75
InnerException:
Does anyone have any idea of what's happening ?
The mentioned article does not have the compiled project available for download, and i didn't find any complete "Hello-World" project for reactiveui-winforms.
My test project can be downloaded here.
In Visual Studio, if i Continue(F5), another exception occures :
System.NullReferenceException occurred
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=ReactiveUI
StackTrace:
at ReactiveUI.IROObservableForProperty.<>c__DisplayClass1_0.<GetNotificationForProperty>b__6(IReactivePropertyChangedEventArgs`1 x) in C:\workspace\git-perso\ReactiveUI\ReactiveUI\IROObservableForProperty.cs:line 44
InnerException:
If i continue to hit F5 i get :
System.Exception was unhandled by user code
HResult=-2146233088
Message=An OnError occurred on an object (usually ObservableAsPropertyHelper) that would break a binding or command. To prevent this, Subscribe to the ThrownExceptions property of your objects
Source=ReactiveUI
This exception is caused because RxUI always tries to initialize for WPF, even though (because you're also using the winforms package) it'll override this setting with a Winforms-based scheduler right after.
It should be harmless though, as it's catched and ignored. You're probably hitting it within VS ?

Exception of type 'System.IO.IOException'

I have the following error message:
An unhandled exception of type 'System.IO.IOException' occurred in PresentationFramework.dll
Additional information: Cannot locate resource 'Sections/MainWindow.xaml'.
I created folder and then moved my MainWindow.xaml into the folder named Sections. I got the error and then found the question that is already on here about making sure that I change my starupURI to Sections/mainwindow.xaml
However I'm still getting the error message and I don't know why.
Edit: So i ran the code again, not making any changes and now I'm getting this
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '5' and line position '54'.
The code that I have at that position:
<Window x:Class="CTaC_Information_System.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStartupLocation="CenterScreen"
Title="CTaC Information System" Height="828" Width="1486.5" Icon="AISLogov2.ico" Loaded="Window_Loaded" FontFamily="Georgia">
The red line is under the >. I went to the end of my code and added the </Window> because for some reason I was still getting the error message.
All help is greatly appreciated.
I think the second error is being caused by your icon. Try removing that bit of code and re-compiling to check if that isolates the problem. You could try changing the icon image to a .png rather than .ico.
For me this happen, when i moved classes MainWindows.xaml and App.xaml from root folder to /UI folder.
When i moved them back - all become normal again, error gone.

How to make non-Localizable SplashScreen in WPF

I'm just adding internationalization to my next WPF application, and have followed the instructions here.
I then noticed that there would be a fair amount of duplication in the satellite DLL, so marked the images that won't be localized in the .csproj as
<Localizable>False</Localizable>
Unfortunately, one of my resources is used in a SplashScreen thus:
SplashScreen ss = new SplashScreen("Images/splash.png");
ss.Show(false);
And this throws an exception when the Show call is executed. Here's the exception output
A first chance exception of type 'System.IO.IOException' occurred in WindowsBase.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Step into: Stepping over method without symbols 'System.RuntimeType.CreateInstanceImpl'
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Step into: Stepping over method without symbols 'MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance'
A first chance exception of type 'System.Xaml.XamlObjectWriterException' occurred in System.Xaml.dll
Step into: Stepping over method without symbols 'System.Windows.Markup.WpfXamlLoader.Load'
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type 'MainWindow' that matches the specified binding constraints threw an exception.' Line number '4' and line position '9'.
When I remove the False line it works again.
Is there any way to load the resource I want, which is stored in test.unlocalizable.g.resources?

Resources