Search code examples
c#.netassembliesmulti-tier

Assembly dependencies within a multi tier application


I am taking a 1st attempt at creating a reuable multi tier application.

I have created a Data Access layer project which is referenced by a business layer project. I created a website that references the business layer project and plan to use this in many other website.

I have dropped the complied business layer project dll into the website bin folder and done a file reference. When I make a call to the business layer it throws a cannot load Data Access assembly. To solve this I drop the Data Access dll into the website bin folder and everything works.

In the future I expect the Business Layer to make many references to different projects so I expect to be adding all project dlls that the Business Layer references into the bin folder for each website. Is this the correct way I am doing this or is there a simplified approach to this?


Solution

  • There are 2 ways you can handle this

    1) Add project reference.

    Click add reference on web project -> click Projects options -> click solution -> check business layer.

    You need to do same on business layer to add data layer project reference.

    2) Seconds approach is using nuget packages. You can create nuget package for csproj to be shared. This is approach is very useful when you sharing dlls across multiple projects and need version control between different projects. Command to create nuget package from csproj.

    nuget pack BusinessLayer.csproj