samer_ali Posted February 17, 2004 Posted February 17, 2004 Hi, Well im developing an application "Keyboard Remmaper" using Keyboard API Like keybd_event and LowLevelKeyboardProcDelegate Well will the program is running it edit the button the user inpute like if the user press A the result is o and some stuff like this the problem is im sometimes got this error suddenlly without no reason. The Dubugger Point At this line > Public Class Form1 And The error is: An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll Additional information: Object reference not set to an instance of an object. If Anybody have got the error before and solved it plz contact me and i will send him the Full code Sorry I cant send it here :rolleyes: Quote
a_jam_sandwich Posted February 17, 2004 Posted February 17, 2004 The error will occur when you have an object that has no instance (Not created) i.e. is a reference What execlty is the section of code that has the problem Andy Quote Code today gone tomorrow!
samer_ali Posted February 17, 2004 Author Posted February 17, 2004 The Whole Error Text Is: An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll Additional information: Object reference not set to an instance of an object. Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, IntPtr hwnd, Int32 msgMin, Int32 msgMax, Int32 remove) at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) I dont know y it happens everything sounds good but suddenlly i got this error after using keyboard for sometime. Quote
Moderators Robby Posted February 17, 2004 Moderators Posted February 17, 2004 I'm curious what is this application used for, and can you post some of the code. Quote Visit...Bassic Software
pendragon Posted February 17, 2004 Posted February 17, 2004 I Would be interested to know what your program is doing, I had a similar problem with a program that navigated around a recordset that then setup other recordsets and showed the information on a tabcontrol. If the user pressed the buttons too fast I got the error, ended up having to turn off the buttons do the work and show the results then turn them back on. Never did find out what was causing this, but as I found a work around, the user didn't really notice anything only a flashing button text and there seemed to be no other problems with it, I left it alone (If it aint broke don't fix it sprang to mind) as dead line was fast approaching. I think something was jumping into the message queue at the wrong place and being run before it should have, but as I said I didn't find out so could be completely wrong. Quote
whizkid Posted February 18, 2004 Posted February 18, 2004 Similar experience Yes, I was also getting into similar situations. When doing some stress kind of testing. In my case, error was with a Browse button click which opens a folder dialog. Before clicking on button, if i produce errors in parent dialog repeatedly, that was showing our custom error balloon, then the folder dialog gives exception like : SehException : external component has thrown some exception... I think, This was concerned with some unmanaged memory used to produce those balloons. If any one has similar experience and came over it, then share the info.. Thanx. Quote
samer_ali Posted February 19, 2004 Author Posted February 19, 2004 hi again well here is the whole source of the application Well now try to over use ur keyboard and u will get that error plz somebody tell me what is going one im really tired of it.keyboard remapper.zip Quote
Moderators Robby Posted February 19, 2004 Moderators Posted February 19, 2004 I'm still curious as to what this application is used for. Quote Visit...Bassic Software
samer_ali Posted February 19, 2004 Author Posted February 19, 2004 lol Robby some one asked me for it because he dont speak in english i guess bangladish or something and he have as i think alot of letters or something anyway i want anybody to help me solving the problem plz it's the 4th day trying to find where the problem thanks Quote
samer_ali Posted February 20, 2004 Author Posted February 20, 2004 (edited) Sorry I Posted The Wrong File hi again sorry i posted the project without the xml files that the app use here is the new copykeyboard remapper -complete-.zip Edited July 31, 2004 by PlausiblyDamp Quote
pendragon Posted February 21, 2004 Posted February 21, 2004 I download the code to have a look but as I have not done anything with api's yet I am unable to find the problem. However, I don't know if this will help you, When I was running the program if I start it, selected a line in the first listview, Pressed edit, press update, then select line in first listview again, press edit, press update, I now press a key and I get the error, this happened everytime and it did not matter what had focus. Hope that gives you an idea of where to look. Quote
samer_ali Posted February 22, 2004 Author Posted February 22, 2004 (edited) hi pendragon well the error is not from this too now the application doesnot have interface see the zip code well the the main function KeyboardProc Which hook the keyboard when u press on button i get the real value of the button by Getchr function and i get the Virtual Code for a button by GetVK function when the user press a key the function run and start see if it matches any condtions of the 1,2 or 3 replacment keys if not it will return the normal key if not it will return the modified code see next coditions and try it. Note: that the deadkey which is "g" will not give the user value if he pressed on it . the problem is that object thing error every thing work fine but after a time i got this error. l > o i > k U > k o > Y k + g > r m + g > e Y + g > q j + g + e > r w + g + s > e Q + g + Q > e thankskeyboard remapper -complet again -.zip Edited July 31, 2004 by PlausiblyDamp Quote
tgraupmann Posted July 31, 2004 Posted July 31, 2004 I'm running into the same issue. The problem is with PeekMessage. [DllImport("user32.dll")] public static extern bool PeekMessage(out MSG lpMsg, HandleRef hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg); MSG is being sent by reference. However, the garbage collector is collecting in MSG before it can return from the pinvoke. // Check if there was a message if (Win32.PeekMessage(out msg, new HandleRef(this,GameWindow.m_hWnd), 0, 0, Win32.PM_REMOVE)) { I've tried a multitude of solutions, but I just get one of these two errors: [Resource lookup failed - infinite recursion detected. Resource name: TypeInitialization_Type] or Object reference not set to an instance of an object. because MSG is getting recycled too fast. I've tried GC.KeepAlive but it doesn't help. Any ideas? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.