简体   繁体   中英

Referencing another project using a dll

I am working on a massive ERP on student lifecycle management.

My platform is ASP.NET Web Forms.

Originally, I created my project using the N-tier format, where I had separate tiers for the data access, business logic, and the view.

I had to create different types of view based on different stakeholders, and so my project had different folders to hold the views of a particular stakeholder.

I had folders to hold my data access and business logic as well.

Overall, my project structure was like this:

Project
--BusinessLogic
    --class files
--DataAccess
    --class files
--Student
    --html pages
--Principal
    --html pages
--AccountsDept
    --html pages
--Teacher
    --html pages
--LoginSystem
    --html pages

Now, I want to breakdown this structure, because I want to host my student and teacher portals on different servers. But the student and teacher portal will use the same data access layer and the same business logic layer, so I want to make any code changes to these layers from one single page.

I am thinking of this structure

Project 1
--BusinessLogic
    --dll files
--DataAccess
    --dll files


Student Portal
--Student
    --html pages
--LoginSystem
    --html pages


Teacher Portal
--Teacher
    --html pages
--LoginSystem
    --html pages

My view related projects will reference the dlls created from publishing Project 1.

Previously, when I published my single project, I saw that all my c# class files compiled into a single dll files. I think it is possible to reference this dll file in my view related project.

The problem is that, I have a intuition / hunch that this might be possible. But I am not even sure. I do not know whether this is the right way or not.

I am also not wanting to use multiple projects inside a single solution. I want to keep everything separate.

You can think of DLLs like plugins, which can be used across any compatible application as references(this is what you see under References section of your project anyway). The great thing is that DLL can be created by anyone - either Microsoft, third-party company or even yourself, there is no limitations.

Reusing your own components is completely fine and I strongly encourage you to do this. Just remember that if you have some layers, which you want to separate, create additional project as Class Library . Of course it is possible to reference DLLs created as a result of building your web project, but this can cause either errors or unexpected application behavior, since Class Library is designed in a way that it only exposes its interface, without triggering any application life cycle events.

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