Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Interop.ShDocVw.dll generates System.BadImageFormatException on my development machine!

$
0
0

I am trying to build a strong-named DLL for use on a Windows 2008 R2 server (x64, of course) using Visual Studio 2010 Express on a Windows 7 SP1 64 development PC and I am having considerable issues with this. The DLL needs to be developed against .NET Framework 3.5.

Everything seemed to be OK when I was just working without strong-naming, but the strong-naming seems to cause issues when I move the DLL to the 2008 R2 Server.

I have done quite a bit of research about this and have created a simple demo Company.Test.DLL and this is now not working on my Development machine, either. The assembly is strong-named against a standard certificate I made.

The Company.Test.DLL uses c:\Windows\System32\ShDocVw.dll (I assume this is 64-bit?) and therefore, I added it in as a Reference for the Company.Test.DLL (so it generated the Interop.ShDocVw.dll) and added a simple method for opening Internet Explorer, navigate to a URL and then shut it down. The DLL is built for the "Any CPU" platform.

Now, I have created a test harness (also strong-named), built for the "Any CPU" platform and have referenced the Company.Test.DLL. Now, when running in Debug and I call the DoStuff method, I get the following error:

System.BadImageFormatException was unhandled
  Message=Could not load file or assembly 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=69946da26bffb46a' or one of its dependencies. An attempt was made to load a program with an incorrect format.
  Source=Company.Test
  FileName=Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=69946da26bffb46a
  FusionLog==== Pre-bind state information ===
LOG: User = DNSCompany\fish
LOG: DisplayName = Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=69946da26bffb46a
 (Fully-specified)
LOG: Appbase = file:///G:/Documents/Visual Studio 2010/Projects/Company.Test.Harness/Company.Test.Harness/bin/Release/
LOG: Initial PrivatePath = NULL
Calling assembly : Company.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=69946da26bffb46a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: G:\Documents\Visual Studio 2010\Projects\Company.Test.Harness\Company.Test.Harness\bin\Release\Company.Test.Harness.vshost.exe.Config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=69946da26bffb46a
LOG: Attempting download of new URL file:///G:/Documents/Visual Studio 2010/Projects/Company.Test.Harness/Company.Test.Harness/bin/Release/Interop.SHDocVw.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

  StackTrace:
       at Company.Test.TestWorkflow.DoStuff(String sURL, String& sName)
       at Company.Test.Harness.Program.Main(String[] args) in G:\Documents\Visual Studio 2010\Projects\Company.Test.Harness\Company.Test.Harness\Program.cs:line 22
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

I am trying to work out what is going wrong.

All can I think is that the Interop DLL is referencing the wrong version (32-bit, not 64-bit) of the ShDocVw.DLL when it comes to running the Test application. I have tried copying the ShDocVw.DLL into the same directory as the bin directory, but I know that that is not going to be right.

Help, please?


Why can't Microsoft STOP developing software and START fixing software?


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>