Problems with existing site after integrating BlogEngine

Topics: ASP.NET 2.0
Jun 8, 2009 at 4:29 PM

I am having problems with an existing site after I have integrated BlogEngine into it.  The problem occurs in the global.asax file.  I am getting the following error:

Could not load file or assembly 'c:\Project Name\bin\XStandard.Aspell.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

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 'C:\Project Name\bin\XStandard.Aspell.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

Source Error:

Line 52:   void Application_Start(object sender, EventArgs e)
Line 53:   {
Line 54:     ArrayList codeAssemblies = Utils.CodeAssemblies();
Line 55:     List<SortedExtension> sortedExtensions = new List<SortedExtension>();
Line 56: 


Source File: c:\Project Name\Global.asax    Line: 54

Assembly Load Trace: The following information can be helpful to determine why the assembly 'C:\Project Name\bin\XStandard.Aspell.dll' could not be loaded.

I have contacted the vendor of the .dll file in question and have determined that the dll is not a .NET dll and so I believe the Utils.CodeAssemblies() is trying to cache the non .NET dll file unsuccessfully.  I am wondering if anyone has any ideas on how I might keep BlogEngine from trying to cache this .dll file.  Any help in this matter would be greatly appreciated.

 

Thanks,

Matt

Jun 9, 2009 at 6:48 AM

Hi Matt,

Have you tried by turning off the Cache for the BlogEngine?

:Ajay

http://www.ajaymatharu.com

Jun 9, 2009 at 7:49 AM

Perhaps it's useful to modify [Utils.cs]'s method [GetCompiledExtensions], the purpose is using "try catch " to skip the exception when BE load non .net dll. After modify it, You must rebuild BlogEngine.Core.dll.

Before:
        public static void GetCompiledExtensions(ArrayList assemblies)
        {
            string s = Path.Combine(HttpContext.Current.Server.MapPath("~/"), "bin");
            string[] fileEntries = Directory.GetFiles(s);
            foreach (string fileName in fileEntries)
            {
                if (fileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                {
                    Assembly asm = Assembly.LoadFrom(fileName);
                    object[] attr = asm.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
                    if (attr != null && attr.Length > 0)
                    {
                        AssemblyConfigurationAttribute aca = (AssemblyConfigurationAttribute)attr[0];
                        if (aca != null && aca.Configuration == "BlogEngineExtension")
                        {
                            assemblies.Add(asm);
                        }
                    }
                }
            }
        }

After:
        public static void GetCompiledExtensions(ArrayList assemblies)
        {
            string s = Path.Combine(HttpContext.Current.Server.MapPath("~/"), "bin");
            string[] fileEntries = Directory.GetFiles(s);
            foreach (string fileName in fileEntries)
            {
                try {
                    if (fileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                    {
                        Assembly asm = Assembly.LoadFrom(fileName);
                        object[] attr = asm.GetCustomAttributes(typeof (AssemblyConfigurationAttribute), false);
                        if (attr != null && attr.Length > 0)
                        {
                            AssemblyConfigurationAttribute aca = (AssemblyConfigurationAttribute) attr[0];
                            if (aca != null && aca.Configuration == "BlogEngineExtension")
                            {
                                assemblies.Add(asm);
                            }
                        }
                    }
                } catch
                {
                }
            }
        }