如何从斌加载第一次加载的所有程序集停止ASP.NET [英] How to stop ASP.NET from loading all assemblies from bin on first load

查看:145
本文介绍了如何从斌加载第一次加载的所有程序集停止ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个本地DOTNET的应用程序将加载在第一次使用的所有引用的程序集(及其参考资料)。但是,ASP.NET将加载第一次访问所有引用的程序集(及其参考资料)。


  1. 这是理解是否正确?


  2. 有没有办法强制ASP.NET以按需加载(如本地应用程序)

  3. 组件
  4. 我试图解决的具体方案是:


    • bin文件夹中包含2个文件: A.DLL 的和的 B.DLL

    • A.DLL 的引用 B.DLL

    • B.DLL 的引用 C.dll 的是别的地方的系统。在这种情况下,的 C.dll 的缺失。

    • A.DLL 的由主应用程序加载(使用反射)。

    • 错误遇到(的无法加载文件或程序... 的)涉及的 B.DLL 的一个缺失的依赖。

    • 我们希望应用程序作为正常的,如果的 C.dll 的缺失,因为这是主应用程序的一个可选组件。

    • 我们有超过之内容概不控制的 B.DLL C.dll



解决方案

要回答3点,在第一次访问加载,导致在bin文件夹中所有组件的设置可以在文件中找到的 C: \\ WINNT \\ Microsoft.NET \\框架\\ V2.0.50727 \\ CONFIG \\ web.config中的(根据您的环境)。从该文件剪切下来萃取:

 <&的System.Web GT;
    <编译>
        <&集会GT;
            <添加组件=*/>
        < /组件>
    < /编译>
< /system.web>

与通配符匹配的所有组件加载为初始编译的一部分。

通过修改web.config文件的应用程序(不会全球DOTNET的一个),包括Web服务的组装和排除通配符匹配,看来,如果可选的依赖是应用程序可以起到丢失:

 <&的System.Web GT;
    <编译>
        <&集会GT;
            <清除装配=*/>
            <添加组件=Main.Application.WebService,版本= 1.0.0.0,文化=中性公钥= YOURKEYHERE/>
        < /组件>
    < /编译>
< /system.web>

我们还在这个所以不知道实验,如果这彻底解决了问题,或有任何不寻常的副作用。

A native DotNet application will load all referenced assemblies (and their references) on first use. However, an ASP.NET will load all referenced assemblies (and their references) on first access.

  1. Is this understanding correct?

  2. Is there a way to force ASP.NET to load assemblies on demand (like local applications)?

  3. The specific scenario I am trying to resolve is:

    • The bin folder contains 2 files : A.dll and B.dll.
    • A.dll references B.dll.
    • B.dll references C.dll which is somewhere else on the system. In this case, C.dll is missing.
    • A.dll is loaded (using reflection) by the main application.
    • The error encountered (Could not load file or assembly...) relates to a missing dependency of B.dll.
    • We want the application to function as normal if C.dll is missing as this is an optional component of the main application.
    • We have no control over the contents of B.dll or C.dll.

解决方案

To answer point 3, the setting that causes all the assemblies in the bin folder to be loaded on first access can be found in the file C:\winnt\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config (depending on your environment). Cut-down extract from that file:

<system.web>
    <compilation>
        <assemblies>
            <add assembly="*" />
        </assemblies>
    </compilation>
</system.web>

All assemblies that match the wildcard are loaded as part of the initial compilation.

By modifying the web.config for the application (NOT the global DotNet one) to include the web service assembly and exclude the wildcard match, it appears that the application can function if the optional dependencies are missing:

<system.web>
    <compilation>
        <assemblies>
            <remove assembly="*" />
            <add assembly="Main.Application.WebService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=YOURKEYHERE" />
        </assemblies>
    </compilation>
</system.web>

We're still experimenting with this so not sure if this completely resolves the issue or has any unusual side-effects.

这篇关于如何从斌加载第一次加载的所有程序集停止ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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