COM 표시 DLL을 만들고 메서드를 오버로드하려고했습니다.com 표시 DLL에서 메서드 오버로드
그래서 기본적으로이 코드 :
[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));
}
}
}
은 다음과 같습니다 그러나 수 없습니다. 내가 전화를하면 (매우 간단한 VBSCript 방식으로) 호출 프로그램에서 쓰기, 나는 내 매개 변수가 올바르지 않은 오류가 발생합니다. 나는 DLL에 하나에 .write 방법이있는 경우
Set myObj = CreateObject("TAF.TextLog")
myObj.Create("C:\temp\textlog.txt")
myObj.Write "title", "test message 1", 1
가 잘 작동 :
이
는 호출 VBScript 코드입니다. 누군가가이 같은 과부하가 dll에서도 가능하다고 말할 수 있습니까?
확인. 설명해 주셔서 감사합니다. – Mytzenka