1

I guess most of .NET devs have received a FileNotFoundException before and been awarded with this or similar view:

Could not load file or assembly...

Most of the time, the stack trace looks something like this:

[FileNotFoundException: Could not load file or assembly 'Microsoft.WindowsAzure.Mobile.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 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) +152
   System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +158
   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) +91
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +438
   System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103
   System.Reflection.RuntimeAssembly.GetCustomAttributes(Boolean inherit) +37
   Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName, IList`1 errors, Boolean& conflict) +106
   Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList`1 errors) +46
   Owin.Loader.DefaultLoader.LoadImplementation(String startupName, IList`1 errorDetails) +75
   Owin.Loader.DefaultLoader.Load(String startupName, IList`1 errorDetails) +21
   Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +115
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28
   System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +534
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

Stack trace provides no hints to where in my own code the assembly is directly or indirectly referenced. It does say where in System/Microsoft assemblies it is referenced.

Reference chain

As I see it, the compiler is aware of what assemblies are 'my code' and what assemblies are System/Microsoft and third-party.

Q: Is there any way to determine the last line in 'my code' (like an extended stack trace) or is it made impossible for threading reasons or other shared memory issues ?

Marcus
  • 8,230
  • 11
  • 61
  • 88
  • Show your Owin startup class – haim770 Dec 07 '15 at 08:23
  • 1
    You can use [Fusion Log Viewer](https://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.110).aspx). Also see http://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net. – Martin Liversage Dec 07 '15 at 08:24
  • I was under the impression that the binding viewer only displayed successfully bound assemblies, my mistake. Thank you! – Marcus Dec 07 '15 at 08:54

0 Answers0