Lets say you have a Class library called MyClassLibrary, and you want an application called MyApplication to run a method on a object in MyClassLibrary without adding a project reference that you can do something like this:
MyClassLibrary:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyClassLibrary
{
public class MyClass
{
public MyClass()
{
}
public string SomeValue
{
get { return "Setec astronomy"; }
}
}
}
MyApplication:
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
Assembly assembly = Assembly.LoadFile(@"C:\Temp\MyClassLibrary\MyClassLibrary\bin\Debug\MyClassLibrary.dll");
Type type = assembly.GetType("MyClass");
object instance = type.GetConstructor(Type.EmptyTypes).Invoke(new object[0]);
string theValue = type.GetProperty("SomeValue").GetValue(instance, null);
}
}
}
This would load the assembly at runtime using a path rather than a project reference and the use reflection to find and invoke the constructor and the property.
Hope this helps.