# Managed DirectX Question

## Recommended Posts

I recently decided to try and learn a bit about managed DirectX and ran into a problem I can't seem to solve. When I try to set the cooperative level for a keyboard device I always get an InputException. As far as I can tell, I am following Tom Miller's code example exactly. Any ideas? Thanks all.
try
{
device = new Device(SystemGuid.Keyboard);
device.SetCooperativeLevel(this,CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
device.Acquire();
}
catch (InputException e)
{

MessageBox.Show(e.Message, "error");

}



##### Share on other sites
Can you post the actual Error message.

##### Share on other sites
What is the 'this' context you are working with; a form or a picturebox?

##### Share on other sites
What is the exact debug output that you are getting? An InputException could be any number of things, so try to be more specific. Thanks.

##### Share on other sites
Hi all,

Unfortunately, InputException is the exact error. I am not getting one of the derived errors that inherits from InputException. I have placed catch blocks for all of the possible InputException types (and taken out the generic InputException) and I just get an "Exception not handled" error, so I have been unable to pin down exactly what it is complaining about.

The e.message message is simply "Error in application". I have even gone into the debugger and looked at every single field of e (boy there are a lot) and there is absolutly no message that is more specific as to what is wrong. They all just have this generic InputException.

"this" refers to the form. I have tried replacing it with the actual name of the form, but got the same results.

thanks again

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628332
• Total Posts
2982120

• 22
• 9
• 9
• 13
• 11