Code Organization

In the examples that I have looked at so far, I have distributed the assembly that contains the remotable types to both the client and the server. In many cases, you will not want to do this. Another approach is to expose only an ICompany interface that contains the same methods as the Company class. To do this, you remove the Company class from the SharedLibrary assembly and then add the following interface to the assembly. Therefore, the complete contents of the SharedLibrary assembly will be as follows:

 1. using System; 2. using System.Collections; 3. using System.Runtime.Remoting.Lifetime; 4. namespace SharedLibrary 5. { 6. [Serializable] 7. public class Employee 8. { 9. private int mID; 10. private DateTime mHireDate; ...

Get .NET and COM Interoperability Handbook, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.