Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

Posted

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.

Posted

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.

Posted

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.

Posted

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

Posted

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.

Posted (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

 

thanks

keyboard remapper -complet again -.zip

Edited by PlausiblyDamp
  • 5 months later...
Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...