I've the following class in XmlSer.dll
namespace xmlser
{
public class XmlSer
{
public Type test(string s)
{
return Type.GetType(s);
}
//...other code
}
}
and the following code in MyApp.exe, which links XmlSer.dll as a reference
namespace MyApp
{
public class TestClass
{
public int f1 = 1;
public float f2 = 2.34f;
public double f3 = 3.14;
public string f4 = "ciao";
}
class MainClass
{
public static void Main(string[] args)
{
TestClass tc = new TestClass();
XmlSer ser = new XmlSer();
Console.WriteLine(ser.test("MyApp.TestClass")!=null);
}
}
Running MyApp.exe I get false, that means that ser instance of XmlSer is not able to get the type of Testclass (result is null). Putting XmlSer class directly in MyApp.exe code I correctly get the type of TestClass.
Checking on the net i've found that the problem is related to the assemblies. That means, the assembly of .exe is not visible to the XmlSer.test method so it can't resolve the type of TestClass.
How can I resolve the problem maintaing XmlSer in XmlSer.dll and MyApp.MainClass in MyApp.exe ?
Thanks.
Alessandro