Stophane
Stophane

Reputation: 31

C# What are the differences in using Components or Class Library?

I´m having problems to understand what the differences are. The actual behavior of using a .dll built from a class library is the same for me as the .dll created from components.

In both ways i create a class library first and add a component or a class.

Upvotes: 2

Views: 880

Answers (1)

Randy
Randy

Reputation: 2348

All Components in .NET inherit from MarshalByRefObject which brings along a lot of baggage with it. This class is used primarily for marshaling data between .NET and COM but was also used for some older remoting technologies introduced in .NET 2.0.

In a nutshell, MarshalByRefObject allows the runtime to insert message sinks into your object effectively intercepting method and property calls.

Generally speaking, don't inherit from or use objects inheriting from Component and or MarshalByRefObject unless you have to.

What is the major use of MarshalByRefObject?

Upvotes: 1

Related Questions