0

I am trying to open IE Explorer from my windows forms application. I have method A which makes call to another method B, which uses SHDocVw to open the browser. The place where i get this error is When i try to call the method B from method A, the call is not even transferred to B even when a break point is set. This is the exception thrown "Could not load file or assembly 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040". But the same code works fine in other windows forms applications. I am using VS 2008 . The reference to SHDOCVW is added from C:\Windows\System32 .

    private void Form1_Load(object sender, EventArgs e)
    {
        OpenBrowser();

    }
    private static void OpenBrowser()
    {
        MyClass.CallBrowser();


    }
     public static class MyClass
    {
    public static void CallBrowser()
    {
        SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorerClass();
        IWebBrowserApp wb = (IWebBrowserApp)ie;
        wb.Visible = true;
        object o = null;

        wb.Navigate("www.google.com", ref o, ref o, ref o, ref o);
    }
    }
Jester
  • 56,577
  • 4
  • 81
  • 125
  • Your problem looks like a duplicate of http://stackoverflow.com/questions/215026/the-located-assemblys-manifest-definition-does-not-match-the-assembly-reference. – EFrank Mar 28 '14 at 12:28
  • Unusual problem, there are not many versions of the PIA in the wild. You must post the trace you get out of Fuslogvw.exe to get help. – Hans Passant Mar 28 '14 at 13:43

1 Answers1

0

It is not an exact answer to your question, but I would suggest to use the built-in WebBrowser control already there in Windows Forms.

This makes your life a lot easier. It does not require all the Win32 stuff to work (it is behind the scenes for you).

There might be a solution for you in the answer on MSDN.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
  • I tried using the solution using the same link that you had given above, but does not work. The same approach works well in other applications in VS 2008. Only in one of the forms i get this exception – user3428250 Mar 28 '14 at 12:34