简体   繁体   中英

Dll usage by .NET application

Have a question for .NET experts.

I have a set of WinForms applications which uses some subset of dll's (some of them are shared between those apps). All binaries resides in the same directory. I need to split those WinForms apps and take only dll's which are needed by concrete app. How can I easily do that (need fast "5-min" solution)?

Options I considered:

  1. domain.ExecuteAssembly(@"exefilename"); domain.GetAssemblies(); //to determine what assemblies are used by the app.

    Needs single thread apartment attribute or a separate thread. Has issues with x86, x64 and AnyCPU builds. A lot of tricks with security, framework versions and so on.

    So, I think this is not a "5 min" solution and needs some additional investigation.

  2. Assembly.GetReferencedAssemblies()

    Has 1 level limitation (doesn't work when assembly references assembly which in turn references another assembly). Does not work for raw assembly loading (when you read it from the file and load by AppDomain.Load Method (Byte[], Byte[]))

  3. Process.Modules (from System.Diagnostics)

    Doesn't work for starting from .NET 4 (it is a bug on msft connect entered for this issue). Would be great "5min" solution for .NET 3.5, but I need a solution for .NET 4.5.

  4. Just execute the app and delete every dll in the folder. Those are used will not be deleted (file will be locked out). But still, doesn't work for raw assembly loading.

Do you have any other ideas?

如果我没记错的话, IlDasm.exe会为您递归检查DLL依赖项。

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