By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,965 Members | 2,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,965 IT Pros & Developers. It's quick & easy.

Crash when hooking common dialog boxes in namespace extension

P: n/a
Hello all. Not sure which group this problem best relates to, so I'm
posting to both with a follow up.

I started learning C# and .NET last august for a project for my
employer. The project involved extending explorer by creating a
context-menu extension and allow certain actions to be performed on
certain files. I was able to get that up and running through much
searching on google, but the overall goal of the projects seems like it
would be better served as a namespace extension.

I started researching creating namespace extensions in january and
managed to extened explorer seemingly successfully. I turned then to
making the extension work from within the common dialog boxes so users
could browse it inside other applications when they are opening/saving
their files. Here is where I have hit my problem.

I have browsing of the extension working fine, but I would like to be
able to know when the open or save button is clicked as I may need have
the extension perform some action on the selected file prior to letting
the application open it, or do something after the application saves
the file. To allow for this, I decided to try setting a hook on the
dialog box and watch for the approiate button press message. This
seemed to be working ok until I tried typing in a filename.

The auto-complete list that XP shows when typing a name causes problems
when this hook is in place. It causes the application to crash upon
use and I'm not sure why. The problem only exists if I have the hook
in place on the dialog. If I don't hook the dialog, everything works
just fine it seems. The program throws a NullReferenceException, but I
can't tell where it's being thrown from. When I run the program
through the debugger it tells me:

---------------------------------------------------------------------------
An unhandled exception of type 'System.NullReferenceException' occurred
in Unknown Module.

Additional information: Object reference not set to an instance of an
object.

---------------------------------------------------------------------------

If I try and break, I just get 'No source code available' and nothing
happens. Enabling debugging of unmanaged code doesn't help too much
either. With unmanaged debugging on, I get an error like this:
---------------------------------------------------------------------------
Unhandled exception at 0x01137516 in notepad.exe: 0xC0000096:
Privileged instruction.
---------------------------------------------------------------------------

and breaking drops me into some assembler code.

I narrowed down my application to what I think is the smallest I can
make it. It is still fairly large though. I uploaded it to my site
here: http://www.aoeex.com/testcase.zip If you do download the code
and want to try and run it, I think I have included the necessary
dependencies. The way I have been running it is to copy the dll files
to c:\windows, then running 'regasm Projectmanagerv2.dll' to register
it it. then I launch notepad from the windows directory and use it's
open dialog box to test.
I would much appricate any help in solving this problem that can be
provided. I have other ways to do what I need if necessary, but they
would be less user friendly than if I could get this dialog box
interaction working properly. I also apologize for any horrid code one
may find. As I said above, I've just started learning C#/.NET and
shell extensions for this, and have been learning as I go.
Thanks,
Keith M.

Mar 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Keith,
Hello all. Not sure which group this problem best relates to, so I'm
posting to both with a follow up.

The "best" is for sure not the newsgroup General. My opinion is the other
one.

This is in my opinion by instance not a general problem

Cor


Mar 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.