Project reference vs. DLL Reference - Which is better?

前端 未结 5 1029
心在旅途
心在旅途 2020-12-13 18:10

I know there are other questions regarding this subject, and I\'ve looked at this question, but I\'d like to see a little bit more discussion and information on both sides o

相关标签:
5条回答
  • 2020-12-13 18:15

    It's not much of a choice. If you have a solution with both projects then use a project reference. If your solution doesn't have the project then you have to use an assembly reference.

    So the real question should probably be: do I create a solution with both projects? Yes, as long as the project is still in the debug stage and liable to require bug fixes.

    0 讨论(0)
  • 2020-12-13 18:16

    If you only have the dll then you're stuck with a dll reference (obviously).

    If you have the source then it's usually better to use a project reference. There might be cases where you have a utility library that's never going to change, but if there's the slightest chance of you needing a bug fix then having a project reference is going to make debugging a lot easier.

    0 讨论(0)
  • 2020-12-13 18:16

    Well, project references are helpful when you are building and testing in both debug and release mode. If you directly add a DLL then you are locked into whatever that particular DLL was built as. The project reference allows this to be a build time decision.

    0 讨论(0)
  • 2020-12-13 18:18

    Relative to your project architecture, you should always stick to projects within your problem domain. You should be using the GAC, if that is applicable to your environment.

    0 讨论(0)
  • 2020-12-13 18:23

    Summary - Project Reference by Project vs by DLL

    Reference by project

    • code is visible
    • finds all references e.g. on a class (because code is visible)
    • better for testing (over all)
    • better for code redesign (impact)

    Reference by DLL

    • code is hidden
    • separation between e.g. framework and project (for deliver of framework)
    • quicker compilation (because DLL is already compiled)
    0 讨论(0)
提交回复
热议问题