c# - Could not load file or assembly Hunspellx64.dll while using NHUnspell NuGet package? -


i have asp.net/mvc web role using nhunspell nuget package. when try run following error message:

could not load file or assembly 'hunspellx64.dll' or 1 of dependencies. module expected contain assembly manifest. 

this strange because far know, web role project should not trying load unmanaged hunspellx64.dll @ all. should handled managed nhunspell dll. dll copied on /bin directory of web role build step.

update: thomas's comment webactivator being outdated able fix issue. duplicating reply comment accepted answer make sure others have problem see fix:

i had nhunspell working before error started occurring. broke things installing attributerouting nuget. attributerouting drags in old version of webactivator (1.0.0.0). unfortunately nuget not suggest update when execute update operation. have manually update via package manager console per web page's instructions:

http://www.nuget.org/packages/webactivator

here rest of original post before fix received:

i have scoured project direct references/linkages hunspellx64.dll including nuget packages configuration, packages.config, web.config, references list, raw project file, etc. can't find direct reference dll. else can or else can try stop project trying load unmanaged dll directly? here asp.net error dump:

[badimageformatexception: not load file or assembly 'hunspellx64.dll' or 1 of dependencies. module expected contain assembly manifest.]    system.reflection.runtimeassembly._nload(assemblyname filename, string codebase, evidence assemblysecurity, runtimeassembly locationhint, stackcrawlmark& stackmark, intptr pprivhostbinder, boolean throwonfilenotfound, boolean forintrospection, boolean suppresssecuritychecks) +0    system.reflection.runtimeassembly.nload(assemblyname filename, string codebase, evidence assemblysecurity, runtimeassembly locationhint, stackcrawlmark& stackmark, intptr pprivhostbinder, boolean throwonfilenotfound, boolean forintrospection, boolean suppresssecuritychecks) +34    system.reflection.runtimeassembly.internalloadassemblyname(assemblyname assemblyref, evidence assemblysecurity, runtimeassembly reqassembly, stackcrawlmark& stackmark, intptr pprivhostbinder, boolean throwonfilenotfound, boolean forintrospection, boolean suppresssecuritychecks) +152    system.reflection.runtimeassembly.internalloadfrom(string assemblyfile, evidence securityevidence, byte[] hashvalue, assemblyhashalgorithm hashalgorithm, boolean forintrospection, boolean suppresssecuritychecks, stackcrawlmark& stackmark) +102    system.reflection.assembly.loadfrom(string assemblyfile) +34    webactivator.preapplicationstartcode.start() in d:\code\bitbucket\webactivator\webactivator\preapplicationstartcode.cs:11  [invalidoperationexception: pre-application start initialization method start on type webactivator.preapplicationstartcode threw exception following error message: not load file or assembly 'hunspellx64.dll' or 1 of dependencies. module expected contain assembly manifest..]    system.web.compilation.buildmanager.invokeprestartinitmethodscore(icollection`1 methods, func`1 sethostingenvironmentcultures) +550    system.web.compilation.buildmanager.invokeprestartinitmethods(icollection`1 methods) +132    system.web.compilation.buildmanager.callprestartinitmethods(string prestartinitlistpath) +90    system.web.compilation.buildmanager.executepreappstart() +135    system.web.hosting.hostingenvironment.initialize(applicationmanager appmanager, iapplicationhost apphost, iconfigmappathfactory configmappathfactory, hostingenvironmentparameters hostingparameters, policylevel policylevel, exception appdomaincreationexception) +516  [httpexception (0x80004005): pre-application start initialization method start on type webactivator.preapplicationstartcode threw exception following error message: not load file or assembly 'hunspellx64.dll' or 1 of dependencies. module expected contain assembly manifest..]    system.web.httpruntime.firstrequestinit(httpcontext context) +9874568    system.web.httpruntime.ensurefirstrequestinit(httpcontext context) +101    system.web.httpruntime.processrequestnotificationprivate(iis7workerrequest wr, httpcontext context) +254 

the webactivator start method doesn't handle unmanaged dlls in bin folder. see in code file: https://bitbucket.org/dfowler/webactivator/src/4c558d93cf3a/webactivator/preapplicationstartcode.cs

 public static void start() {             lock (initlock) {                 if (!hasinited) {                     // go through bin assemblies                     foreach (var assemblyfile in getassemblyfiles()) {                         var assembly = assembly.loadfrom(assemblyfile);                          // go through preapplicationstartmethodattribute attributes                         // note *our* attribute, not system.web namesake                         foreach (preapplicationstartmethodattribute prestartattrib in assembly.getcustomattributes(                             typeof(preapplicationstartmethodattribute),                             inherit: false)) {                              // if asks called after global.asax app_start, keep track of method. otherwise call                             if (prestartattrib.callafterglobalappstart && hostingenvironment.ishosted) {                                 attribstocallafterstart.add(prestartattrib);                             }                             else {                                 // invoke method attribute points                                 prestartattrib.invokemethod();                             }                         }                     } 

the start() method loads dlls assemblies probe preapplicationstartmethodattribute. fails unmanaged dll because there no assembly manifest.

it looks using branch (dfolwler?) or outdated version of webactivator because current version can handle ignoring exceptions on assembly load.

private static ienumerable<assembly> assemblies {         {         if (_assemblies == null)         {             // cache list of relevant assemblies, since need both pre , post             _assemblies = new list<assembly>();             foreach (var assemblyfile in getassemblyfiles())             {                 try                 {                     // ignore assemblies can't load. native, etc...                     _assemblies.add(assembly.loadfrom(assemblyfile));                 }                 catch                 {                 }             }         }          return _assemblies;     } } 

update webactivator recent version.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -