aximp of shdocvw.dll -> problem with ShellExecute

  • Thread starter Thread starter Wiktor Zychla
  • Start date Start date
W

Wiktor Zychla

I have a problem I cannot solve.

My application hosts IE activex control. I follow the standard procedure: I
just aximp shdocvw.dll. Note that this gives you two files: axshdocvw.dll
and shdocvw.dll.

And there comes the problem. I reference the libraries from my project. For
this to work, I put the libraries in the same directory as the application.
Now, from my code I try to ShellExecute to a link (to show it in a new
window):

Process p = new Process();
p.StartInfo.FileName = http://www.google.com;
p.Start();

this, of course, does not work: the ShellExecute method uses the ShdocVw.dll
that is in the current directory (the imported one) instead of the proper
one (I had spent 3 hours until I've realized that)!

this is how I tried to solve the problem:
1. aximp to another name than shdocvw does not work (if you run aximp
/out:blah then only the first imported dll is renamed to blah.dll. the
shdocvw.dll is still shdocvw.dll!)
2. renaming the shdocvw.dll manually and modiify the references does not
work (the runtime cries about missing interfaces when trying to show a form
with hosted explorer component).
3. moving the imported shdocvw.dll to another directory is not an option,
the library should be in the same directory as the main module.

Now, I am stuck. I have no idea why aximp creates TWO libraries and why one
of them MUST be named shdocvw.dll, just like the original one. I have no
idea how, then, use ShellExecute that would use proper shdocvw.dll.

Thanks form your help,
Wiktor Zychla

----------------------------------------------------------------------------
---------------
steps to reproduce my problem:
1. aximp shdocvw.dll gives you axshdocvw.dll and shdocvw.dll.
2. put imported axshdocvw.dll and shdocvw.dll in a directory and create a
new application.
3. put a code into the application:

....
Process p = new Process();
p.StartInfo.FileName = http://www.google.com;
p.Start();

you get an error because the ShellExecute inside p.Start() uses the
shdocvw.dll from the current directory (the Exception.Message is
misleading).

4. remove shdocvw.dll from the current directory. run the application. it
works ok.
 
<ciach>
try to use
aximp with /source option
rename shdocvw.dll
compile axshdocvw.cs
i don't try it but mayby it works


pozdrawiam
 
Wiktor,

The following is mentioned in the documentation for AXIMP.EXE, and I
think it applies to your situation:

Running Aximp.exe over the ActiveX Control shdocvw.dll will always create
another file named shdocvw.dll in the directory from which the tool is run.
If this generated file is placed in the Documents and Settings directory, it
causes problems for Microsoft Internet Explorer and Windows Explorer. When
the computer is rebooted, Windows looks in the Documents and Settings
directory before the system32 directory to find a copy of shdocvw.dll. It
will use the copy it finds in Documents and Settings and attempt to load the
managed wrappers. Internet Explorer and Windows Explorer will not function
properly because they rely on the rendering engine in the version of
shdocvw.dll located in the system32 directory. If this problem occurs,
delete the copy of shdocvw.dll in the Documents and Settings directory and
reboot the computer.

What I would recommend doing is using AXIMP.EXE to generate your
wrappers. Then, use ILDASM do disassemble the wrappers for both. Once you
have that, you can recompile the IL for ShDocVw.dll (the one that AXIMP
generated) into another assembly with a different name. Then, you should be
able to do the same with the IL for AxShDocVw.dll, adding a reference to the
new dll that you just compiled. You should then be able to have these in
your directory and use them no problem.

Hope this helps.
 
What I would recommend doing is using AXIMP.EXE to generate your
wrappers. Then, use ILDASM do disassemble the wrappers for both. Once you
have that, you can recompile the IL for ShDocVw.dll (the one that AXIMP
generated) into another assembly with a different name. Then, you should be
able to do the same with the IL for AxShDocVw.dll, adding a reference to the
new dll that you just compiled. You should then be able to have these in
your directory and use them no problem.

Hope this helps.

big thanks to you both, especially to you, Nicholas. your trick works
perfectly. I am amazed.

Regards,
Wiktor
 
Back
Top