0

I have implemented the Tessnet2 library to work in my Web Project. While debugging i've gotten rid of all the "usual" bugs++.

When i deploy this solution to the webserver with visual studio 2010, and test the site i get the error message:

Could not load file or assembly 'tessnet2_32' or one of its dependencies. 
An attempt was made to load a program with an incorrect format.

The stacktrace is as follows:

[BadImageFormatException: Could not load file or assembly 'tessnet2_32' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +123

[ConfigurationErrorsException: Could not load file or assembly 'tessnet2_32' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11568160
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +485
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +79
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +337
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1167

[HttpException (0x80004005): Could not load file or assembly 'tessnet2_32' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700896
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +11532014

Question is, has anybody seen this before? and handled it? or know a fix?

I have tried moving tessdata-folder to bin folder on server, i've made sure the tessnet2_32.dll file and pdb file is on server in bin folder...

All other libs should also be present.

Bjørn
  • 1,138
  • 2
  • 16
  • 47

1 Answers1

1

The server is a 64-bit process and tessnet2_32.dll is 32-bit. So you can't load the DLL and get this exception.

fero
  • 6,050
  • 1
  • 33
  • 56
  • That makes sense... i'll try to switch to the 64-bit dll... :) – Bjørn May 23 '12 at 13:28
  • My question then changes and how would i develop with the 64 bit version in Visual Studio 2010? I can only get the 32-bit one to work there... – Bjørn May 23 '12 at 13:30
  • That depends on which web server you're using for development. The architecture of Visual Studio itself doesn't matter. Make sure you have the 64-bit version of Windows. Then you should switch to the "real" IIS while developing (check your project settings for this) so you have an environment more similar to the production environment. The architecture of the web server defines which type of DLLs can be loaded. – fero May 23 '12 at 13:35
  • I am using the built in webserver for developing. The one Visual Studio provides, and i use IIS 7.5 on my hosting server. So you are saying "switch" from the visual-studio-web-server that has built in debugger++ and continue developing on the IIS 7.5? (Yes i have 64 bit windows on both server and workstation that i develop on) – Bjørn May 23 '12 at 13:41
  • @BjørnØyvindHalvorsen: I would recommend using [IIS express](http://learn.iis.net/page.aspx/868/iis-express-overview/) for development. It integrates within Visual Studio well and has many advantages over the old web server built-in in Visual Studio. – Ňuf May 23 '12 at 13:49
  • 2
    I found another question related to your problem: You can also change the AppPool settings to enable 32-bit applications. http://stackoverflow.com/a/6754373/722149 – fero May 23 '12 at 13:53