open office document using web browser component in c#.net 2008 ap

A

Aale

Hi,
I have a problem to open office document using web browser component in
C#.net 2008 application.

according to this article :
http://support.microsoft.com/kb/304662/

I want to open office document in my web browser component.
I worked on vs.2008 too.

my application compile and run correctly but when I want to open office
document, it show windown dialog that select open or save document (the
dialog that seems when wants to download file!) instead of open document in
web browser component.

I debugged my code,this is part of my code:

public void axWebBrowser1_NavigateComplete2(object sender,
AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
{

Object o = e.pDisp;
Console.WriteLine("0");
oDocument = o.GetType().InvokeMember("Document",
BindingFlags.GetProperty, null, o, null);
Console.WriteLine("1");
Object oApplication = o.GetType().InvokeMember("Application",
BindingFlags.GetProperty, null, oDocument, null);
Console.WriteLine("2");
Object oName = o.GetType().InvokeMember("Name",
BindingFlags.GetProperty, null, oApplication, null);
Console.WriteLine("3");
MessageBox.Show("File opened by: " + oName.ToString());
}

when I opened the document, program write in console 0 and 1 but not 2!!
so problem is in this line :
Object oApplication = o.GetType().InvokeMember("Application",
BindingFlags.GetProperty, null, oDocument, null);
and these line seem in console :
A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
A first chance exception of type
'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

please help me!
is this problem occured because I used vs.2008 instead of vs.2005?!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top