Why the method InitializeComponent throw an error? - xaml

I have created a new SplitPage inside VS2012 and I load this page with:
this.Frame.Navigate(typeof(SplitPage), "AllGroups");
An error is throw from :
this.InitializeComponent();
Visual Studio show me this exception :
An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred
in IC2.exe but was not handled in user code
WinRT information: Cannot find a Resource with the Name/Key SubtitleTextStyle
[Line: 88 Position: 104]
If I catch the error I found the message :
Unspecified error
How can I avoid this error ?

I think the problem lies in the xaml where you don't have the style in the resources that is being call "SubtitleTextStyle". You may want to check on that or remove that line away in your xaml.

Related

Factory method 'tomcatReactiveWebServerFactory' threw exception with message: jakarta/servlet/Servlet

I have the following in my build.gradle:
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent
implementation('org.springframework.boot:spring-boot-starter-parent:3.0.2')
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter
implementation("org.springframework.boot:spring-boot-starter:3.0.2")
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-webflux
implementation("org.springframework.boot:spring-boot-starter-webflux:3.0.2")
But I get the following exception on startup.
Factory method 'tomcatReactiveWebServerFactory' threw exception with message: jakarta/servlet/Servlet
What dependency am i missing?
It looks like commenting out the following additional dependency is removing the above error:
implementation('org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2')

How it is possible to debugging Windows.UI.Xaml.Markup.XamlParseException

During the methode
InitializeComponent()
in the main class of a customized control occurs the error with the follow message:ยจ
Message "System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Windows.UI.Xaml.Markup.XamlParseException: Der Text zu diesem Fehlercode wurde nicht gefunden.\r\n\r\nCannot create instance of type 'Uwp.UI.Control.OneNotePicker.OnenotePicker' [Line: 37 Position: 42]\r\n at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)\r\n at TestEnvironment.Uwp.MainPage.InitializeCom" string
This error is an unhandled exception and is shown with a debug break under App.g.i.cs
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
It seems, there is an error during parsing the Xaml file. My question is now, how I can find exactly the row of the Xaml file, where the error occurs.
Thanks for help
The issue might be caused by a spelling mistake of the resource name that you defined in the Page.Resources or App.Resources.Please check where you are setting the resources and make sure the spelling is correct.

Allow UnhandledException event handler to run when debugging using Visual Studio 2013 Ultimate

I have a WinForms application that uses Application.UnhandledException to display a dialog to prompt user to report the error. When the application is published and run on its own, it works fine (apart from the obvious problem that there is an unhandled exception floating around).
To test changes to it, I've been trying just throwing an exception on clicking a button. Unfortunately, the debugger gets in the way. It will break at the exception (which is not a problem in other cases because I want to know something is wrong) and not let me continue into the UnhandledException handler, instead telling me that the exception is unhandled every time I click the continue button. I've tried disabling breaking on any exception, specific types of exception and the Just My Code option in the Options screens to no avail.
Is there any way of disabling this behaviour?
Repro code below, as requested. It's from a bog-standard, common-or-garden WinForms app with a single button (ThrowButton) on the startup form. Application Framework is enabled by default on creating the project.
Form1.vb
Public Class Form1
Private Sub ThrowButton_Click(sender As Object, e As EventArgs) Handles ThrowButton.Click
Throw New Exception
End Sub
End Class
ApplicationEvents.vb
Namespace My
Partial Friend Class MyApplication
Private Sub MyApplication_UnhandledException(sender As Object, e As ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
MsgBox("Application event")
End Sub
End Class
End Namespace
I've also put a copy of the solution up on Drive, in case that would be helpful. I scanned it before uploading it, but obviously can't vouch for what happens to it after that.
https://drive.google.com/file/d/0By6VJrYK_X0-QklFWWYtSDBPblU/view?usp=sharing
This answer was given for C# code, before OP prepared VB.NET code for download. May it still be useful for someone. If you disagree, flag it as not-an-answer.
The C# behavior follows the MSDN steps for exception dispatching, which says in step 3:
... but the process is being debugged, the system notifies the debugger a second time.
Considering code like
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
throw new Exception("Help! I am unhandled!");
}
private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Console.WriteLine("Caught unhandled exception.");
Console.WriteLine(e.IsTerminating ? "Terminating" : "Not terminating");
}
I'd say the behavior of Visual Studio is expected.
The unhandled exception handler is executed (which you can verify by looking at the console output)
The process is going to terminate, because you can't set the exception as handled in the handler
Before the process terminates, the debugger jumps in
The same happens not only in Visual Studio but in WinDbg (running the same executable):
0:000> .exr -1
ExceptionAddress: 750bc42d (KERNELBASE!RaiseException+0x00000058)
ExceptionCode: e0434352 (CLR exception)
ExceptionFlags: 00000001
NumberParameters: 5
Parameter[0]: 80131500
Parameter[1]: 00000000
Parameter[2]: 00000000
Parameter[3]: 00000000
Parameter[4]: 713e0000
0:000> !pe
Exception object: 02573148
Exception type: System.Exception
Message: Help! I am unhandled!
InnerException: <none>
StackTrace (generated):
SP IP Function
0038F0DC 001D04B4 UnhandledExceptionHandler!UnhandledExceptionHandler.Program.Main(System.String[])+0x6c
StackTraceString: <none>
HResult: 80131500
Where the exception flags tell us that this is a second chance exception.

asp.net mvc exception in controller not beign handled at custom ErroHandler

I have a global ErrorHanlder (Derive from HandleErrorAttribute) that works fine and catches all errors that occur. But I have a situation in which, home controller can throw exception. I inspected and saw that error thrown from controller is not handled in my custom ErrorHandler and asp.net gives this:
Exception of type 'Exception' was thrown.
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Would you help me please ?
Code:
public HomeController()
{
_ServiceAsync = new ServiceAsyncProvider();
}
class ServiceAsyncProvider
{
public ServiceAsyncProvider()
{
throw new Exception();
}
}
While your code snippet is a little unclear on this point, it looks like your _ServiceAsync is being initialized in your controller's constructor. Exceptions thrown during controller construction are not handled by the HandleError filter.
See this related question for more information: Handling Exceptions that happen in a asp.net MVC Controller Constructor
You are throwing an exception in the constructor. These exceptions are not handled by the filter.

How to solve " A first chance exception of type" exception when

I am using the following code to connect to an Microsoft SQl Server database but I always get an error
var conn = #"Server=(local)\localhost;Database=Training;";
using (SqlConnection objSqlConnection = new SqlConnection(conn))
{
try
{
objSqlConnection.Open();
Console.Write("Connection is successfull");
}
catch (System.Data.SqlClient.SqlException sqlException)
{
Console.WriteLine(sqlException.Message);
}
}
and the error I get is:
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
The thread 'vshost.RunParkingWindow' (0xd28) has exited with code 0 (0x0).
The thread '<No Name>' (0x1550) has exited with code 0 (0x0).
The program '[6440] DataAccess.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
Make sure your System.Data.dll is correctly referenced in your code.
First chance exception messages most often do not mean there is a problem in the code. For applications / components which handle exceptions gracefully, first chance exception messages let the developer know that an exceptional situation was encountered and was handled.
For code without exception handling, the debugger will receive a second chance exception notification and will stop with a unhandled exception.