aws / aws-xray-dotnet-agent

The official AWS X-Ray Auto Instrumentation Agent for .Net.
Apache License 2.0
23 stars 15 forks source link

Could not find file 'C:\Program Files\AWSXRayAgent\Net45\System.Web.Mvc.resources.dll'. #18

Open sdolier opened 4 years ago

sdolier commented 4 years ago

I have installed the AWS X-Ray .NET Agent and the IIS module has been installed.

My site is a .net MVC project and running the site results in the exception below.

It looks like Amazon.XRay.Recorder.AutoInstrumentation.AspNetAutoInstrumentationModule.LoadBytesFromAssembly(path) is trying to load an assembly it shouldn't be.

[FileNotFoundException: Could not find file 'C:\Program Files\AWSXRayAgent\Net45\System.Web.Mvc.resources.dll'.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +1404
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1242
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +126
   Amazon.XRay.Recorder.AutoInstrumentation.AspNetAutoInstrumentationModule.LoadBytesFromAssembly(String path) +94
   Amazon.XRay.Recorder.AutoInstrumentation.AspNetAutoInstrumentationModule.AWSXRayAutoInstrumentationDependency(Object sender, ResolveEventArgs args) +132
   System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName) +177

[FileNotFoundException: Could not load file or assembly 'System.Web.Mvc.resources, Version=5.2.3.0, Culture=en-AU, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   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.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark) +341
   System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark) +245
   System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) +491
   System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) +1008
   System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) +43
   System.Resources.ResourceManager.GetString(String name, CultureInfo culture) +567
   System.Web.Mvc.Razor.MvcCSharpRazorCodeParser.ModelDirective() +69
   System.Web.Razor.Parser.CSharpCodeParser.AfterTransition() +474
   System.Web.Razor.Parser.CSharpCodeParser.ParseBlock() +598
   System.Web.Razor.Parser.HtmlMarkupParser.OtherParserBlock() +154
   System.Web.Razor.Parser.HtmlMarkupParser.SkipToAndParseCode(Func`2 condition) +484
   System.Web.Razor.Parser.HtmlMarkupParser.ParseDocument() +161
   System.Web.Razor.Parser.RazorParser.ParseCore(ITextDocument input) +150
   System.Web.Razor.RazorTemplateEngine.GenerateCodeCore(ITextDocument input, String className, String rootNamespace, String sourceFileName, Nullable`1 cancelToken) +171
   System.Web.WebPages.Razor.RazorBuildProvider.EnsureGeneratedCode() +315
   System.Web.WebPages.Razor.RazorBuildProvider.get_CodeCompilerType() +27
   System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) +164
   System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() +230
   System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +31
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +583
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +351
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +146
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +11735252
   System.Web.Compilation.BuildManager.GetCompiledType(VirtualPath virtualPath) +22
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +88
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +91
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +188
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +32
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +46
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +431
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +75
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +158
lupengamzn commented 4 years ago

Hi @sdolier ,

Thanks for your feedback

The AspNetAutoInstrumentationModule will try to load the required assemblies for tracing Asp.Net application, but since you've imported AWSXRayRecorder.AutoInstrumentation library in your application, the required satellite assemblies are already shipped within your application and this step is unnecessary in the current state, which, in your case, may try to load other missing assemblies in the C:\Program Files\AWSXRayAgent\Net45\ in the runtime.

We will fix this in our next release soon

Before that, you can try:

  1. Comment this method
  2. Follow steps here and deploy your app on IIS