remoting problem

  • Thread starter Thread starter Broeden
  • Start date Start date
B

Broeden

I'm trying to send a simple serializable object over the network. The
problem is to get the receiver and sender to recognize the same class

using System;

[Serializable]
public class SerialEmployee
{
public int EmployeeID;
public string LastName;
public string FirstName;
public int YearsService;
public double Salary;

public SerialEmployee()
{
EmployeeID = 0;
LastName = null;
FirstName = null;
YearsService = 0;
Salary = 0.0;
}
}

The solution should be to create a dll-file of this class and include
it as a resource in both the sender and receiver programs. The problem
is that I don't know how to do this.

VS2005, Windows application

Any hints appreciated

/Broeden
 
I have solved it now.
- File/new/project/Class Library
- Name in MyClassLibrary
- include the class SerialEmployee
- Build
- In the other projects, add reference MyClassLibrary
- End

/Broeden
 
Hello Broeden

You can use reflection
Assembly a = Assembly.LoadFile("MyAssembly.dll");
Type type = a.GetType("MyNamespace.SerialEmployee",
true);
SerialEmployee e =
(SerialEmployee)Activator.CreateInstance(type);
or you can move SerialEmployee to a class library project, build it and
reference that dll on both side.

Hope this helps :)
 
Back
Top