2

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.

Stophane
  • 31
  • 5
  • Haven't you read [this](https://msdn.microsoft.com/de-de/0b1dk63b(v=vs.120)) chapter prior to asking? – Sinatr Dec 11 '15 at 14:59
  • 2
    Or just in case he is not fluent in German: https://msdn.microsoft.com/en-gb/0b1dk63b – Alex K. Dec 11 '15 at 15:02
  • 1
    A component is just a class that implements IComponent. Almost always by inheriting from the Component class. That gives it extra capabilities at design-time. It will show up in the toolbox, you can drop it on a form and edit its properties in the Properties window. Might be useful, it is not always. Certainly not if you don't use it in a Winforms app. – Hans Passant Dec 11 '15 at 15:10
  • Thank you for these answers! To summarize my understandings: 1. A Component is a class which I give the special ability to be used in Design-Time respectively Toolbox. // 2. Design-Time (only?) exists in Forms, User-Controls and Components and allows me to build my code visually in the ...Designer.cs in other words a creating a Component for a simple Console-Application would not make any sense ?! // 3. In anyway i can treat Components the same way as simple classes but with the little extra that i could use it in a Designer. – Stophane Dec 12 '15 at 10:51

1 Answers1

1

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?

Community
  • 1
  • 1
Randy
  • 2,270
  • 1
  • 15
  • 24