为什么AppDomain.CurrentDomain.GetAssemblies()未在一定条件下在Global.asax中返回依赖程序集? [英] Why does AppDomain.CurrentDomain.GetAssemblies() not return dependant assemblies in Global.asax under certain conditions?

查看:766
本文介绍了为什么AppDomain.CurrentDomain.GetAssemblies()未在一定条件下在Global.asax中返回依赖程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修改:这是pviously题为应用程序初始化行为IIS重新启动与应用初始化的不同的$ P $。我已经改变了标题出扩大的问题,从IIS /应用程序初始化,因为观察到的行为涉及 AppDomain.CurrentDomain.GetAssemblies();

EDIT: This was previously entitled "App Init behaviour different between IIS Restart and Application Initialisation". I have changed the title to expand the question out from IIS/Application Initialisation because the observed behaviour relates to AppDomain.CurrentDomain.GetAssemblies();

我使用的是IIS应用程序初始化模块热身的ASMX结婚服务。

I am using the IIS Application Initialisation module to warm-up an asmx wed service.

我已经实现了一些热身code,以确保成功应用程序初始化在Global.asax中的Application_Start事件JIT是我的asmx服务。这使用System.Runtime.CompilerServices.RuntimeHelpers。prepareMethod()通过所有的组件在应用程序遍历(它也拿起所有的组件依赖),以确保该服务的第一个电话是一样快可能的。

I have implemented some warm-up code to ensure app application initialisation successfully JIT's my asmx service in Global.asax Application_Start event. 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.

当我obeserve这种行为利用净停止W3SVC&放大器; NET START W3SVC。我可以看到(通过日志记录),所有的组件都JIT'ted和服务的第一个电话是快如预期。

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.

然而,当应用程序池会自动在其配置的时间安排回收(03:00:00)日志显示只有直接引用的组件是J​​IT'ted,而不是也坐不住文件夹中的依赖关系。

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.

这是导致在第一次调用该服务无法接受的开销。

This is resulting in an unacceptable overhead on the first call to the service.

应用程序初始化执行完全一样有望在所有其他方面,但为什么应用程序池的IIS重新周期只有JIT编译直接引用的程序集,而不是它的依赖?

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?

推荐答案

远高于我的评论中提到的职位使我在正确的方向,然后我发现这个职位的答案:<一href=\"http://stackoverflow.com/questions/2477787/difference-between-appdomain-getassemblies-and-buildmanager-getreferencedassembl\">Difference AppDomain.GetAssemblies之间BuildManager.GetReferencedAssemblies

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

所以,我的code改为 VAR组件= BuildManager.GetReferencedAssemblies();

So my code was changed to var assemblies = BuildManager.GetReferencedAssemblies();

这篇关于为什么AppDomain.CurrentDomain.GetAssemblies()未在一定条件下在Global.asax中返回依赖程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆