akashdeep

Member
Joined
Jul 17, 2013
Messages
7
Programming Experience
3-5
Hi
I coded a pretty basic VB.net app with .NET framework 3.5 in VS 2012 on a Windows 8 Pro 64-bit machine. The app doesn't use any database connectivity or any other prerequsite. I built it for x86 CPU configuration. I don't need to use ClickOnce to deploy since the .exe in the Release folder is self-sufficient. I tested it on my Windows 8 machine, a Windows 7 Ultimate 32-bit machine and a Windows XP Professional 32-bit machine.
While it works perfectly and smoothly on Windows 8 and Windows 7, on Windows XP it throws an error on starting and doesn't run. The error details are
VB.NET:
EventType : clr20r3     P1 : naughts and crosses.exe     P2 : 1.0.0.0     
P3 : 51fcdff6     P4 : naughts and crosses     P5 : 1.0.0.0     P6 : 51fcdff6
P7 : 11     P8 : c6     P9 : system.invalidoperationexception

Help please! And thanks for you time. Have a nice day.
 
Handle the UnhandledException event of the application (which you should be doing for every Windows app anyway) so that you can get more detailed information about the exception; most importantly, where it is thrown.
 
Handle the UnhandledException event of the application (which you should be doing for every Windows app anyway) so that you can get more detailed information about the exception; most importantly, where it is thrown.

Thanks for the reply Sir! Can you please tell me how to do what you just told me. I don't have much experience with VB, and so don't know where to do that.
 
The Application page of the project properties has a button to open the code file for the application events. You can use the drop-down lists at the top of the page to add the appropriate event handler(s) in the same way you can in a form. In the UnhandledException event handler, you can get the exception itself from the 'e' parameter and then call ToString on that to get the error message and stack trace.
 
It worked!

The Application page of the project properties has a button to open the code file for the application events. You can use the drop-down lists at the top of the page to add the appropriate event handler(s) in the same way you can in a form. In the UnhandledException event handler, you can get the exception itself from the 'e' parameter and then call ToString on that to get the error message and stack trace.
Thank you Sir! Your solution worked perfectly. On getting the UnhandledException to store the Error in the Event Log, I was able to find out what I had done wrong. The problem was pretty obscure actually. In the Properties->Application->Assembly Information box, I had made some changes. One of them was changing Neutral Language to English(India). This was what was causing the Exception. Apparently, Windows XP didn't recognise it, so I changed it back to the default which was (none). And, the error was gone.
The code I had written in the ApplicationEvents.vb file was:
VB.NET:
Private Sub MyApplication_UnhandledException(sender As Object, e As ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
Try
'write log, which is nessted in Application Data folder
My.Application.Log.WriteException( _
e.Exception, _
TraceEventType.Critical, _
"Unhandled Exception!")
'check up if the Event folder exists.
'if not - create new one
If Not EventLog.SourceExists("My software") Then
EventLog.CreateEventSource("My software", "My Software")
End If
'write event log, can be seen by Event Viewer
EventLog.WriteEntry("My software", _
e.Exception.ToString(), _
EventLogEntryType.Error)
Catch ex As Exception
End Try
End Sub

The Error log was as folows:
VB.NET:
Event Type:    Error
Event Source:    My software
Event Category:    None
Event ID:    0
Date:        8/4/2013
Time:        9:58:00 PM
User:        N/A
Computer:    XPGUEST
Description:
System.InvalidOperationException: An error occurred creating the form. See Exception.InnerException for details.  The error is: The NeutralResourcesLanguageAttribute on the assembly "Naughts And Crosses, Version=0.0.1.3, Culture=neutral, PublicKeyToken=null" specifies an invalid culture name: "en-IN". ---> System.ArgumentException: The NeutralResourcesLanguageAttribute on the assembly "Naughts And Crosses, Version=0.0.1.3, Culture=neutral, PublicKeyToken=null" specifies an invalid culture name: "en-IN". ---> System.ArgumentException: Culture name 'en-IN' is not supported.
Parameter name: name
   at System.Globalization.CultureInfo.GetCultureInfo(String name)
   at System.Resources.ResourceManager.GetNeutralResourcesLanguage(Assembly a, UltimateResourceFallbackLocation& fallbackLocation)
   --- End of inner exception stack trace ---
   at System.Resources.ResourceManager.GetNeutralResourcesLanguage(Assembly a, UltimateResourceFallbackLocation& fallbackLocation)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
   at System.Resources.ResourceManager.GetObject(String name)
   at Naughts_And_Crosses.NaughtsAndCrosses.InitializeComponent()
   at Naughts_And_Crosses.NaughtsAndCrosses..ctor()
   --- End of inner exception stack trace ---
   at Naughts_And_Crosses.My.MyProject.MyForms.Create__Instance__[T](T Instance)
   at Naughts_And_Crosses.My.MyProject.MyForms.get_NaughtsAndCrosses()
   at Naughts_And_Crosses.My.MyApplication.OnCreateMainForm()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
 

Latest posts

Back
Top