I am calling COM object (written in C#) from COBOL. But when I try to call it, I receive this error:
Exception 65540 not trapped by the class oleexceptionmanage
Description: "OLE Name not found"
(80020006): Unknown name.
Hit T to terminate program. Hit any other key to continue.
This error happens when processing invoke of method GetDate. I have generated unique GUIDs, also I have COM object signed with generated snk file. I already done this type of call, and it's working. But with this module, I am missing something.
COBOL code:
class-control.
CharacterArray is class "chararry"
OLESafeArray is class "olesafea"
FileCrDat is class "$OLE$LLPFileCreateDate.FileCreateDate".
....
05 FileCrDatObj object reference.
....
invoke FileCrDat "new" returning FileCrDatObj
invoke FileCrDatObj "GetDate" using w-file-test
returning w-file-date
end-invoke
C# code
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace LLPFileCreateDate
{
[Guid("057DAAB4-8D90-4C5F-922C-F0BEDC7C691C"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IFileCreateDate
{
[DispId(1)]
string GetDate(string file);
}
[Guid("39DDA4DD-9789-439F-BDD1-620AE0B3B1C5"),
ClassInterface(ClassInterfaceType.None)]
public class FileCreateDate : IFileCreateDate
{
public FileCreateDate() { }
public string GetDate(string file)
{
DateTime dateCreate = File.GetCreationTime(file);
string fileDate = dateCreate.ToString();
return fileDate;
}
}
}
I found solution. Method name can't start with set or get word. Because when it is, it's treated differently as getter or setter.