Not running in a hosted service or the Development Fabric (Production, not debug/local) - azure

Im just getting started with Windows Azure and have got a small MVC application running locally using the Azure emulator. I signed up for a free trial, downloaded my publishing profile and imported it into VS2012. Published to Azure and got some assembly reference errors. I resolved this by setting them to copy local = true and now i get:
Not running in a hosted service or the Development Fabric.
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.InvalidOperationException: Not running in a hosted service or the Development Fabric.
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.
Stack Trace:
[InvalidOperationException: Not running in a hosted service or the Development Fabric.]
Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.GetDefaultStartupInfoForCurrentRoleInstance() +447
Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener..ctor() +40
[ConfigurationErrorsException: Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.]
System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData) +6792949
System.Diagnostics.TypedElement.BaseGetRuntimeObject() +45
System.Diagnostics.ListenerElement.GetRuntimeObject() +83
System.Diagnostics.ListenerElementsCollection.GetRuntimeObject() +143
System.Diagnostics.TraceInternal.get_Listeners() +181
System.Diagnostics.TraceInternal.TraceEvent(TraceEventType eventType, Int32 id, String format, Object[] args) +155
DotNetOpenAuth.Loggers.TraceLogger.Info(Object message) +26
DotNetOpenAuth.Logger.CreateWithBanner(String name) +45
DotNetOpenAuth.Logger..cctor() +14
[TypeInitializationException: The type initializer for 'DotNetOpenAuth.Logger' threw an exception.]
DotNetOpenAuth.Logger.get_Library() +14
DotNetOpenAuth.Reporting.Initialize() +410
DotNetOpenAuth.Reporting.set_Enabled(Boolean value) +31
DotNetOpenAuth.Reporting..cctor() +285
[TypeInitializationException: The type initializer for 'DotNetOpenAuth.Reporting' threw an exception.]
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start() +41
[InvalidOperationException: The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: The type initializer for 'DotNetOpenAuth.Reporting' threw an exception..]
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): The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: The type initializer for 'DotNetOpenAuth.Reporting' threw an exception..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
--------------------------------------------------------------------------------
If seen this error if you are testing locally and have set the web project as the startup project rather than the cloud project, but as I say, this works fine locally against the emulator, but deploying into Azure causes this to fail.
Any ideas what I'm missing here?
Thanks

Try deleting the Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener trace listener configuration in your web.config. See this related SO post. DotNetOpenAuth.Logger seems to conflict with WAD (windows azure diagnostics).
Remove trace listener from web.config:
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>

Set the Windows Azure Role project as the "Startup" project. This solved my problem. I encountered the same issue when I set another webapp in the same solution as startup project.

Related

System.TypeLoadException: Method 'WriteFileAsync' in type 'ServiceStack.IO.MemoryVirtualFiles'

Getting this error on App startup when Azure DevOps builds my project. App works fine in Visual Studio.
Unhandled exception. System.TypeLoadException: Method 'WriteFileAsync' in type 'ServiceStack.IO.MemoryVirtualFiles' from assembly 'ServiceStack.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
at ServiceStack.ServiceStackHost..ctor(String serviceName, Assembly[] assembliesWithServices)
at ServiceStack.AppHostBase..ctor(String serviceName, Assembly[] assembliesWithServices) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\AppHostBase.NetCore.cs:line 31
at WebApp.AppHost..ctor() in D:\a\1\s\NCMSProgram\NCMSProgram\Startup.cs:line 340
at MyCtor()
at ServiceStack.ModularStartup.CreateStartupInstance(Type type)
at ServiceStack.ModularStartup.GetPriorityInstances()
at ServiceStack.ModularStartup.ConfigureServices(IServiceCollection services)
at ServiceStack.ModularStartupActivator.ConfigureServices(IServiceCollection services)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services, Object instance)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at WebApp.Program.Main(String[] args)
Whenever you get Type or Missing method exceptions from using the pre-release packages which referenced in yours project NuGet.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="ServiceStack MyGet feed" value="https://www.myget.org/F/servicestack" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
Typically it's due to downloading the same pre-release package version at different times which you can resolve by deleting your NuGet packages cache:
$ nuget locals all -clear
Then restoring your packages again which fetches the latest version of each package ensuring they're all built at the same time.
As an added precaution I've rebuilt and deployed all pre-release packages again, so just re-running the task again may also resolve it.

No component for supporting the service CMS.Helpers.ICurrentCookieLevelProvider was found

Hi I am having a kentico 11 website. I am getting following error when am trying host and run it locally from IIS
Server Error in '/' Application.
No component for supporting the service CMS.Helpers.ICurrentCookieLevelProvider was found
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: Castle.MicroKernel.ComponentNotFoundException: No component for supporting the service CMS.Helpers.ICurrentCookieLevelProvider was found
Source Error:
Line 16: protected override void OnPreRender(EventArgs e)
Line 17: {
Line 18: base.OnPreRender(e);
Line 19:
Line 20: lblText.Text = "The web site doesn't contain any content. Sign in to administration and edit the content.";
Source File: \CMS\Default.aspx.cs Line: 18
Stack Trace:
[ComponentNotFoundException: No component for supporting the service CMS.Helpers.ICurrentCookieLevelProvider was found]
Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, Arguments arguments, IReleasePolicy policy, Boolean ignoreParentContext) +144
Castle.MicroKernel.DefaultKernel.Resolve(Type service, Arguments arguments) +40
Castle.Windsor.WindsorContainer.Resolve() +69
CMS.Core.IoCContainer.Resolve() +93
[ServiceResolutionException: Resolution of 'CMS.Helpers.ICurrentCookieLevelProvider' failed with the following error: No component for supporting the service CMS.Helpers.ICurrentCookieLevelProvider was found]
CMS.Core.IoCContainer.Resolve() +262
CMS.Helpers.CookieHelper.IsCookieAllowedInternal(String name) +38
CMS.Helpers.CookieHelper.GetValueInternal(String name, Boolean useDefaultValue, Boolean allowSensitiveData) +397
CMS.DocumentEngine.DocumentContext.GetCurrentStylesheet(PageInfo pageInfo) +87
CMS.UIControls.DocumentBase.get_CurrentStylesheet() +31
CMS.UIControls.DocumentBase.SetCSS() +21
CMS.UIControls.DocumentBase.PreRender() +44
_Default.OnPreRender(EventArgs e) in \CMS\Default.aspx.cs:18
System.Web.UI.Control.PreRenderRecursiveInternal() +132
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4005
Any help would be much appriciated.
Looks like some of CMS libraries may be missing. How did you setup the website: did you install Kentico or got the code and database backup? Check the missing references in CMS project in Visual Studio, clean, rebuild and try again.

Why SLAB SqlDatabaseSink stopped writing to Traces table?

SLAB SqlDatabaseSink stopped writing to Traces table
I added a FlatFileSink in parallel to make sure the listener is not the issue, which writes fine to a file.
I also have a Unit Test for the SqlDatabaseSink which works fine, but when subscribing from the main project via Global.asax only the FlatFileSink works. Screenshots below.
Added SLAB internal event listener per #manikrish 's suggestion (thank you very much for that), here is the underlying SQLDatabaseSink error from that log "Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'" - details below, SLAB Internal Log.
Next, I compared the reference properties of Newtonsoft.Json between main project and Unit Test project (who's SQLDatabaseSink works), both using version 6.0.8 (I believe WebApi 5.2.3 came with it), but noticed the Specific Version was False in the latter. So, I made the same change in the main project, still no luck.
Also, the main project's web.config and unit test project's app.config have the same assembly binding for it also:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
Next, I tried addressing the binding redirect issue by changing reference properties in web.config, packages.config, csproj; reinstalling/updating the Newtonsoft.Json and also the calling assembly's (Microsoft.Practices.EnterpriseLibrary.SemanticLogging) NuGet package based on other stackoverflow questions (links below), still no luck - same binding error in the SLAB Internal Log, there is no evidence of my biding redirect.
SLAB Internal Log:
Opcode : Info
Task : 65433
Version : 0
Payload : [message : System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming)
at System.Data.SqlClient.SqlParameter.GetCoercedValue()
at System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc)
at System.Data.SqlClient.SqlCommand.SetUpRPCParameters(_SqlRPC rpc, Int32 startCount, Boolean inSchema, SqlParameterCollection parameters)
at System.Data.SqlClient.SqlCommand.BuildRPC(Boolean inSchema, SqlParameterCollection parameters, _SqlRPC& rpc)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.BeginExecuteNonQueryInternal(AsyncCallback callback, Object stateObject, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.BeginExecuteNonQueryAsync(AsyncCallback callback, Object stateObject)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl(Func`3 beginMethod, Func`2 endFunction, Action`1 endAction, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory`1.FromAsync(Func`3 beginMethod, Func`2 endMethod, Object state)
at System.Data.SqlClient.SqlCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.SqlDatabaseSink.<>c__DisplayClass14.<<UseStoredProcedure>b__13>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.SqlDatabaseSink.<UseStoredProcedure>d__1d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Sinks.SqlDatabaseSink.<PublishEventsAsync>d__0.MoveNext()
=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
(Fully-specified)
LOG: Appbase = file:///C:/work/StarLims/AMO/server/TFS/AMO/eyeNet/AI.eyeNet/
LOG: Initial PrivatePath = C:\work\StarLims\AMO\server\TFS\AMO\eyeNet\AI.eyeNet\bin
Calling assembly : Microsoft.Practices.EnterpriseLibrary.SemanticLogging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\work\StarLims\AMO\server\TFS\AMO\eyeNet\AI.eyeNet\web.config
LOG: Using host configuration file: C:\Users\siliodx\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/74a40fb9/3b0c98c/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/74a40fb9/3b0c98c/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/work/StarLims/AMO/server/TFS/AMO/eyeNet/AI.eyeNet/bin/Newtonsoft.Json.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
]
EventName : DatabaseSinkPublishEventsFailedInfo
Timestamp : 2015-06-05T11:56:54.5518724Z
ProcessId : 6752
ThreadId : 12060
StackOverflow supporting links:
Infamous assembly binding error
Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. Manifest definition does not match the assembly reference
Newtonsoft.Json.dll issue when using multiple projects
Assembly mismatch despite having assembly redirect and loading correct version
Screenshots:
The Semantic logging application block logs internal events to a pre-defined event source called the SemanticLoggingEventSource. You could create an additional listener which logs the events from this event source to a different sink.
For example, the snippet below shows how to log internal events to a file:
var slabInternalNotificationsListener = new ObservableEventListener();
slabInternalNotificationsListener.LogToFlatFile(#".\errors.txt");
slabInternalNotificationsListener.EnableEvents(SemanticLoggingEventSource.Log, System.Diagnostics.Tracing.EventLevel.Verbose, Keywords.All);
Please take a look at the logs from the SemanticLoggingEventSource to see why the SQL sink is not logging events.
The root cause was a missing dependentAssembly tag around one of the assemblies in web.config:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
Thank you very much to Mani and the other SLAB team members that helped me, especially since the root cause had nothing to do with their project.

Not running in a hosted service or the Development Fabric. Error in deployed version

I have Diagnostic trace listener on in my application deployed on web role. Everything works fine in development environment when run through emulator. But I am receiving following error when deployed on azure
Not running in a hosted service or the Development Fabric.
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.InvalidOperationException: Not running in a hosted service or the Development Fabric.
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.
Stack Trace:
[InvalidOperationException: Not running in a hosted service or the Development Fabric.]
Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.GetDefaultStartupInfoForCurrentRoleInstance() +518
Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener..ctor() +34
[ConfigurationErrorsException: Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.]
System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData) +9004943
System.Diagnostics.TypedElement.BaseGetRuntimeObject() +110
System.Diagnostics.ListenerElement.GetRuntimeObject() +989
System.Diagnostics.ListenerElementsCollection.GetRuntimeObject() +252
System.Diagnostics.TraceInternal.get_Listeners() +331
System.Diagnostics.TraceInternal.WriteLine(String message) +161
AVAWebApplication.Global.Application_Start(Object sender, EventArgs e) +28
[HttpException (0x80004005): Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +581
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +179
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +322
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +384
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +397
[HttpException (0x80004005): Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +678
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +810
Can Anybody please help ?
DotNetOpenAuth.Logger seems to conflict with WAD (windows azure diagnostics). Also see this post: Not running in a hosted service or the Development Fabric (Production, not debug/local)
Remove trace listener from web.config:
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>

IIS skip assembly binding

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
You could just set the Build Action to Content and then set Copy To Output Directory to Copy Always to have this assembly added to the bin directly at all tiimes. Otherwise, you could remove the reference to the executable from the project properties, or check to make sure that there is no mention of it in the web.config file. There is no method to prevent IIS from binding to an assembly when it is referenced inside a project. IIS builds up all the referenced assemblies when it does its initial compilation on the first request of the application.

Resources