I am creating a COM visible dll and I was trying to overload a method.
So basically this code:
[ComVisible(true)]
[ProgId("TAF.TextLog")]
[Guid("af3f89ed-4732-4367-a222-2a95b8b75659")]
public class TextLog
{
String _logFilePath;
public TextLog()
{
}
[ComVisible(true)]
public void Create(string filePath)
{
String path = Path.GetDirectoryName(filePath);
if (Directory.Exists(path))
{
_logFilePath = filePath;
}
[ComVisible(true)]
public void Write(string message)
{
WriteMessage(null, message, AlertMsg.MsgTypes.Info);
}
[ComVisible(true)]
public void Write(string title, string message, AlertMsg.MsgTypes messageType)
{
WriteMessage(title, message, messageType);
}
private void WriteMessage(string title, string message, AlertMsg.MsgTypes messageType)
{
using (StreamWriter file = new StreamWriter(_logFilePath, true))
{
if (title == null)
file.WriteLine(String.Format("{0:yyyy-MM-dd HH:mm:ss}\t{1}", DateTime.Now, message));
else
file.WriteLine(String.Format("{0:yyyy-MM-dd HH:mm:ss}\t{1}\t{2}\t{3}", DateTime.Now, title, message, messageType));
}
}
}
Looks like this is not possible however. If I call .Write from the calling program (which is a very simple VBSCript by the way), i get an error that my parameters are not correct.
This is the calling VBscript code:
Set myObj = CreateObject("TAF.TextLog")
myObj.Create("C:\temp\textlog.txt")
myObj.Write "title", "test message 1", 1
If I have only one .Write method in the dll it works fine. Can someone tell me if overloading like this is even possible in a dll?