Yogi
Yogi

Reputation: 9739

Inter project (class library) communication in .Net

Let's say I have a simple web application project created with Visual Studio MVC template, and a class library project which is referenced in the web project.

Now when the web application calls a method in the class library, which protocol it uses for such communications under the hood? Is it TCP/IP or Named Pipe? And which port it uses?

Upvotes: 1

Views: 232

Answers (1)

T.S.
T.S.

Reputation: 19330

Protocols are normally used for inter-process communication.

Referencing libraries in .NET, is for in-process operations. Your library A is compiled and has a public API with its signature (public methods/properties). Your MVC project output (also a library) gets compiled against library A and it resolves signatures of all methods called in your MVC library. At runtime, both libraries are loaded into AppDomain and live inside a single process, with all the signatures being resolved. This is called "Early Binding"

Additionally you can have a Late Binding

string s = "param";
dynamic x = new SomeClass();
x.SomeMethod(s); 

In the example above, SomeMethod is not resolved during compilation. It will be searched for and resolved at runtime.

Late or early binding are all part of the same process and no protocol is required. But if you have multiple processes and need to communicate between them - then you can use a DB, File, Protocol, Memory Mapped File, etc.

Upvotes: 1

Related Questions