简体   繁体   中英

Prevent a specific dll from loading in IIS

I am getting the common error of:

Could not load file or assembly '...' or one of its dependencies. The specified module could not be found.

The issue is this dll references unmanaged dlls so it will never be able to load properly. I just want IIS to ignore this file.

I'm playing around with the <remove assembly> tag in the web.config, but with no luck.

Any suggestions on how I can prevent my one dll from loading?

Though I couldn't figure out a way to limit a specific assembly, I was able to accomplish it by removing all assemblies and adding the specific ones back that I needed. changing the web.config file to:

<system.web>
    <compilation targetFramework="4.0">
        <assemblies>
            <remove assembly="*"/>
            <add assembly="example.dll"/>
        </assemblies>
    </compilation>
</system.web>

.Net runtime does not load assemblies for fun. It only does so when it is needed - ie you are actively using class/methods from that assembly. You may even reference assemblies that are not present as long as code that uses them is not executed.

So preventing the assembly from being loaded will not make your application to work - ie remove the assembly and see your application to crush due to missing dependency.

If you are loading assemblies yourself in some way (like Assembly.Load) than you need to figure out how to skip such assemblies...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM