locked
.NET optional assembly RRS feed

  • Question

  • Hi all.  I'm pretty sure this is not possible, but I thought I'd check anyways.

    I have an application and we might need to exclude a certain assembly (foo.dll) from a production build.  There are maybe 5 lines in the actual application that call into foo.dll.

    Right now the application has a reference to foo.dll.  If foo.dll is not there, the application refuses to load due to binding errors.  From what I understand, it would be pretty much impossible to 'catch' or ignore binding errors.  Can anyone confirm this?

     

    The solution then is to use late binding... which is fine... but if there's a simple way to simply catch/ignore the binding errors, the would be great too.

     

    Y

    Thursday, November 18, 2010 4:53 PM

Answers

  • Hi Yamin,

    You could load the dll dynamically using a DI container (StructureMap, MEF, Castle etc). Then on resolving the type you could catch the error.

    Kind regards,
    Tom de Koning


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Marked as answer by Cookie Luo Wednesday, November 24, 2010 8:37 AM
    • Unmarked as answer by Cookie Luo Wednesday, November 24, 2010 8:52 AM
    • Proposed as answer by Cookie Luo Wednesday, November 24, 2010 8:52 AM
    • Marked as answer by eryang Tuesday, December 7, 2010 7:36 AM
    Thursday, November 18, 2010 6:46 PM