I have followed Jon, Morten and Mohanmoss advice, but still not work.
Can someone pls give some comments about the following codes of interface and implements ?
2 files, ITrans.cs and DDDBIQ.cs (is part of the whole solution)
In file ITrans.cs,
namespace Trans
{
interface ITrans
{
string DoTrans(string strXML);
}
}
In file DDDBIQ.cs,
using CDBUtil;
namespace Trans
{
public class DDDBIQ : ITrans
{
public string DoTrans(string strXML)
{
Log.WriteLine(strXML, "DoTrans");
return "<XML><ValidCode>Axis</ValidCode><STATUS>00</STATUS></XML>";
}
}
}
Now I make the DoTrans as public.
When I build the solution, I have the following error.
C:\Inetpub\wwwroot\CDBWebService\Service1.asmx.cs( 75): Cannot implicitly convert type 'object' to 'Trans.ITrans'
The following code in Service1.asmx.cs get the error.
string strResponse = string.Empty;
Type typ = Type.GetType("WebService1.Trans." + strClassName);
Trans.ITrans objITrans = Activator.CreateInstance(typ); =====>>>> this line Activator.CreateInstance give error
strResponse = objITrans.DoTrans(strXML);
How to reslove this? Thanks.