简体   繁体   English

为什么AppDomain.CurrentDomain.GetAssemblies()在某些条件下不返回Global.asax中的依赖程序集?

[英]Why does AppDomain.CurrentDomain.GetAssemblies() not return dependant assemblies in Global.asax under certain conditions?

EDIT : This was previously entitled "App Init behaviour different between IIS Restart and Application Initialisation". 编辑 :此前称为“IIS重启和应用程序初始化之间的App Init行为不同”。 I have changed the title to expand the question out from IIS/Application Initialisation because the observed behaviour relates to AppDomain.CurrentDomain.GetAssemblies(); 我已经更改了标题以从IIS /应用程序初始化中扩展问题,因为观察到的行为与AppDomain.CurrentDomain.GetAssemblies();

I am using the IIS Application Initialisation module to warm-up an asmx wed service. 我正在使用IIS应用程序初始化模块来预热asmx wed服务。

I have implemented some warm-up code to ensure app application initialisation successfully JIT's my asmx service in Global.asax Application_Start event. 我已经实现了一些预热代码,以确保应用程序应用程序初始化成功JIT是我在Global.asax Application_Start事件中的asmx服务。 This uses System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod() to iterate through all of the assemblies in the application (it also picks up all of the assembly dependencies) to ensure that the first call to the service is as fast as possible. 这使用System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod()来遍历应用程序中的所有程序集(它还会获取所有程序集依赖项),以确保第一次调用服务的速度尽可能快。

When I obeserve this behaviour utilising "net stop w3svc & net start w3svc" I can see (via logging) that ALL of the assemblies are JIT'ted and the first call to the service is fast as expected. 当我使用“net stop w3svc&net start w3svc”来观察这种行为时,我可以看到(通过记录)所有程序集都是JIT,并且第一次调用服务的速度很快。

However, when the application pool is automatically recycled on its configured time schedule (03:00:00) the log shows only the directly referenced assemblies are JIT'ted, not the dependencies that also sit in the folder. 但是,当应用程序池在其配置的时间表(03:00:00)上自动回收时,日志仅显示直接引用的程序集是JIT,而不是也位于文件夹中的依赖项。

This is resulting in an unacceptable overhead on the first call to the service. 这导致第一次调用服务时产生不可接受的开销。

The App Init performs exactly as expected in all other respects but why does the IIS re-cycle of the Application Pool only JIT compile the directly referenced assemblies and not its dependencies? App Init在所有其他方面完全按预期执行,但为什么应用程序池的IIS重新循环只有JIT编译直接引用的程序集而不是它的依赖项?

Well the post mentioned in my comment above led me in the right direction and then I found the answer on this post: Difference between AppDomain.GetAssemblies and BuildManager.GetReferencedAssemblies 我在上面的评论中提到的帖子让我朝着正确的方向前进,然后我在这篇文章中找到了答案: AppDomain.GetAssemblies和BuildManager.GetReferencedAssemblies之间的区别

So my code was changed to var assemblies = BuildManager.GetReferencedAssemblies(); 所以我的代码改为var assemblies = BuildManager.GetReferencedAssemblies();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 `GetReferencedAssemblies` 是 `AppDomain.CurrentDomain.GetAssemblies()` 的子集吗? - Is `GetReferencedAssemblies` a subset of `AppDomain.CurrentDomain.GetAssemblies()`? ASP.NET - AppDomain.CurrentDomain.GetAssemblies() - AppDomain重新启动后丢失的程序集 - ASP.NET - AppDomain.CurrentDomain.GetAssemblies() - Assemblies missing after AppDomain restart C#WinForm中的AppDomain.CurrentDomain.GetAssemblies() - AppDomain.CurrentDomain.GetAssemblies() In C# WinForm AppDomain.CurrentDomain.GetAssemblies失败并显示ReflectionTypeLoadException - AppDomain.CurrentDomain.GetAssemblies fails with ReflectionTypeLoadException AppDomain.CurrentDomain.GetAssemblies()。SelectMany()发生了什么变化? - What has changed with AppDomain.CurrentDomain.GetAssemblies().SelectMany()? 使用Sybase时AppDomain.CurrentDomain.GetAssemblies()引发System.Reflection.ReflectionTypeLoadException - AppDomain.CurrentDomain.GetAssemblies() throws System.Reflection.ReflectionTypeLoadException when using Sybase 如果我使用AppDomain.CurrentDomain.GetAssemblies()。GetTypes(),有人可以执行代码注入攻击吗? - Would somebody be able to execute a code injection attack if I use AppDomain.CurrentDomain.GetAssemblies().GetTypes()? 为什么System.AppDomain.CurrentDomain.BaseDirectory返回不同的结果? - Why does System.AppDomain.CurrentDomain.BaseDirectory return different results? 为什么有些.Net程序集不能通过AppDomain的GetAssemblies()方法获得? - Why are some .Net assemblies not available via an AppDomain's GetAssemblies() method? 使用Global.asax - Using the Global.asax
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM