locked
Cannot run iTextSharp.dll in IIS 7 & Windows 7 but works in windows XP Pro RRS feed

  • Question

  • User1555937759 posted

     hi,

    I have reference of iTextSharp.dll files required to create pdf files on Windows XP Pro and Visual Studio 2008, which when deployed runs fine. If I run using ASP.NET Development server in Visual studio 2008 / windows 7 it works fine too.

    But if I try to deploy the application on IIS 7 and use Visual Studio 2008 to publish it. After I open it in web browser, I get this error.

    Please help me here. Thanks.

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

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.BadImageFormatException: Could not load file or assembly 'iText' or one of its dependencies. An attempt was made to load a program with an incorrect format.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Assembly Load Trace: The following information can be helpful to determine why the assembly 'iText' could not be loaded.

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
    

    Stack Trace:

    [BadImageFormatException: Could not load file or assembly 'iText' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
       System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
       System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +416
       System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166
       System.Reflection.Assembly.Load(String assemblyString) +35
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190
    
    [ConfigurationErrorsException: Could not load file or assembly 'iText' 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) +11207304
       System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +388
       System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +232
       System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +48
       System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +210
       System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +76
       System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +283
       System.Web.Compilation.BuildManager.CompileGlobalAsax() +50
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +676
    
    [HttpException (0x80004005): Could not load file or assembly 'iText' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
       System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +76
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +1012
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +1025
    
    [HttpException (0x80004005): Could not load file or assembly 'iText' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11301302
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
       System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +11174792
    

     

    Sunday, October 10, 2010 2:49 PM

Answers

  • User197322208 posted

    Is Windows 64 ? IF so, i the properties of the site you must configure to load 32 bit app...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 10, 2010 4:48 PM

All replies

  • User197322208 posted

    Is Windows 64 ? IF so, i the properties of the site you must configure to load 32 bit app...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 10, 2010 4:48 PM
  • User1555937759 posted

    ignatandrei,


    Thanks for your pointer. With your help I checked the Application Pool's properties and set it to run enable 32bit applications.

    http://www.codedigest.com/Articles/IIS/21_IIS7_-_Running_32-bit_and_64-bit_ASPNET_versions_at_the_same_time_on_different_worker_processes.aspx

    I was getting access denied after that as some permission was missing. I thought simply giving IIS_IUSR would work, but I had to add anonymous for folder permissions. Not sure why.


    Tuesday, October 12, 2010 12:38 PM
  • User-1109278330 posted

    Did you finally get this to work?  I can use iTextSharp in my project when it is hosted by the ASP.NET Development Server, but not IIS7.5.  Did you need to modify the server configuration or add the assembly to IIS?  If so, how?

    Friday, June 3, 2011 4:10 PM
  • User-157201395 posted

    I was running into the same issue with a website hosted on IIS7 - 64bit processor. I changed the Application Pool from running on "Integrated" mode to "Classic" mode and iTextSharp started running correctly. Looks like iTextSharp eeds II6 core components to run correctly on 64bit machines.

    Tuesday, February 26, 2013 12:08 PM