I am currently working with project which uses defined layer to send messages over remoting, currently it is working so that all data access methods are wrapped inside of that layer. For eg:
public class RemoteLayer: MarshalByRefObject
{
DataAccessThing1()
{
//Do things
}
However, these layers are got very huge over time. I though i can make generic factory for asking remote objects from other appdomain:
public class Abc : MarshalRefObject // This layer also residues in server, to its remoted.
public T Factory<T> ()
{
return (T) Activator.CreateInstance(typeof(T));
}
I though i can use it like this in client side:
var fooDA = _remoteLayer.Factory<DataAccessClassForFoo>();
var Foo = FooClass(FooDA); // Now class uses data access over remote layer.
However, this alone doesn't work. It only works when I add direct reference to type in source which i am going to use with factory. For eg:
private ExampleType Foo() { return null; } // This method is unused.
public T Factory<T> ()
{
return (T) Activator.CreateInstance(typeof(T));
}
This works. Example type is referenced to assembly and it works ok. Without that direct call to type for some reason i get error: Could not load file or assembly 'AssemblyForExampleType', version ...
I have AssemblyForExampleType referenced for all cases to project, however without direct use in source it seems reference doesn't help.
Is there something what i have completly missed? Do assembly lack metadata or something without direct usage of type in source? Or is this idea completly bad anyway.
I have tried use where T: ExampleType, however, now every consumer of interface needs to reference all types defined after where, that i really don't want...
Ty.