0

I have a problem starting a Web Application of mine, which runs under IIS 8. The 'yellow screen of death' states this:

Could not load file or assembly 'RegexAssemblyBuilder, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b40604c47d15475b' or one of its dependencies. The system cannot find the file specified.
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.IO.FileNotFoundException: Could not load file or assembly 'RegexAssemblyBuilder, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b40604c47d15475b' or one of its dependencies. The system cannot find the file specified.

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 'RegexAssemblyBuilder, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b40604c47d15475b' could not be loaded.


=== Pre-bind state information ===
LOG: User = IIS APPPOOL\XYZweb
LOG: DisplayName = RegexAssemblyBuilder, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b40604c47d15475b
 (Fully-specified)
LOG: Appbase = file:///C:/Code/Application/XYZ 4-Web/ABC.XYZ.Web/
LOG: Initial PrivatePath = C:\Code\Application\XYZ 4-Web\ABC.XYZ.Web\bin
Calling assembly : ABC.RegularExpressions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=f59eabe05cc67589.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Code\Application\XYZ 4-Web\ABC.XYZ.Web\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: RegexAssemblyBuilder, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b40604c47d15475b
LOG: The same bind was seen before, and was failed with hr = 0x80070002.


Stack Trace:


[FileNotFoundException: Could not load file or assembly 'RegexAssemblyBuilder, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b40604c47d15475b' or one of its dependencies. The system cannot find the file specified.]
   System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
   System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +371
   System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +19
   System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +319
   System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +203
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +1179
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +146
   WebActivator.AssemblyExtensions.GetActivationAttributes(Assembly assembly) +114
   WebActivator.ActivationManager.RunActivationMethods() +286
   WebActivator.ActivationManager.RunPreStartMethods() +38
   WebActivator.ActivationManager.Run() +56

[InvalidOperationException: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load file or assembly 'RegexAssemblyBuilder, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b40604c47d15475b' or one of its dependencies. The system cannot find the file specified..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +12880923
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +12880632
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +240
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load file or assembly 'RegexAssemblyBuilder, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b40604c47d15475b' or one of its dependencies. The system cannot find the file specified..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12880068
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12721257

Now, I do have this RegexAssemblyBuilder.exe file in my solution and if I paste it into the bin folder and refresh the page everything works. It is also very likely that there is some issue about the calling assembly which looks for this file, and I have already informed my colleagues about that (I didn't develop it...). In the meantime, to make it work, and for future knowledge, I would like to know if there is the chance to tell IIS not to resolve this binding (which by the way I never use). I can't remove the calling .dll though. Thank you

4

1 回答 1

1

您可以将 Build Action 设置为 Content,然后将 Copy To Output Directory 设置为 Copy Always,以便始终将此程序集直接添加到 bin。否则,您可以从项目属性中删除对可执行文件的引用,或者检查以确保 web.config 文件中没有提及它。当在项目中引用程序集时,没有任何方法可以防止 IIS 绑定到程序集。IIS 在对应用程序的第一个请求进行初始编译时构建所有引用的程序集。

于 2013-04-26T13:40:48.103 回答