I have a Type Library Project "MyLib" where I have to add a new method as shown below. When called from my C# client application it should take IntPtr as an argument.
Below is the IDL definition of the method inside "MyLib" project:
[id(9), helpstring("method PrintFile"), local]
HRESULT PrintFile([in] HANDLE pDevMode);
Can anyone please tell me what type I should use for that perticular argument in my IDL file?
Below are my C# Client Project codes:
PrintDialog PrntDlg = new PrintDialog();
PrintDocument printDocument = new PrintDocument();
printDocument.DocumentName = "filename";
PrntDlg.Document = printDocument;
PrntDlg.AllowSelection = true;
PrntDlg.AllowSomePages = true;
if (PrntDlg.ShowDialog() == DialogResult.OK)
{
IntPtr PDevMode = PrntDlg.PrinterSettings.GetHdevmode();
MyLib.PrintFile(PDevMode);
}
When I am using HANDLE inside the IDL definition the following exception get's thrown:
Unable to cast COM object of type 'System.__ComObject' to interface type ...