M
Muthiah Samy
Hi All,
I am trying to call COM Component in .NET using PInvoke.
In the following scenario, ( I am getting an exception called SEH -
External component has thrown an exception)
UnManaged Code
---------------
virtual HRESULT IDispatch::GetIDSOfNames(const IID & riid, LPWSTR *
rgizNames, UINT CNames, LCID lcid, DISPID *rgDispID)
Managed Code (I have rewritten)
------------
int GetIDsOfNames ([In] System.Guid guid, ref System.String[]
rgNames,[In] System.UInt32 cNames, [In] System.UInt32 lcid,
[Out] out long[] dispID);
Public Test()
{
AXIDispatch pIScriptDispatch;
String[] wszScriptFunctions = new String[1];
wszScriptFunctions[0] = "entryMethod";
long[] dispIDFunctions = new long[1];
pIScriptHost.GetScriptDispatch (out pIScriptDispatch);
IntPtr p = Marshal.GetIDispatchForObject(pIScriptHost);
IntPtr ppv;
Marshal.QueryInterface(p,ref diug,out ppv);
pIScriptDispatch = (AXUtil.AXIDispatch)Marshal.GetObjectForIUnknown(ppv);
try
{
pIScriptDispatch.GetIDsOfNames (guid,ref wszScriptFunctions, 1,
1033, out dispIDFunctions);
}
catch (Exception ex)
{
Console.WriteLine (ex.ToString ());
}
}
If I execute Test() I will be getting the following Exception for
Invoking "GetIDsOfNames(....)"
System.Runtime.InteropServices.SEHException: External component has
thrown an exception.
What could be the reason to get this kind exeception, I don't know
what to do in order to handle it error. Could anyone
kindly help me to solve ? I will greatly appreciate.
Thanks & Regards
R. Muthiah Samy
I am trying to call COM Component in .NET using PInvoke.
In the following scenario, ( I am getting an exception called SEH -
External component has thrown an exception)
UnManaged Code
---------------
virtual HRESULT IDispatch::GetIDSOfNames(const IID & riid, LPWSTR *
rgizNames, UINT CNames, LCID lcid, DISPID *rgDispID)
Managed Code (I have rewritten)
------------
int GetIDsOfNames ([In] System.Guid guid, ref System.String[]
rgNames,[In] System.UInt32 cNames, [In] System.UInt32 lcid,
[Out] out long[] dispID);
Public Test()
{
AXIDispatch pIScriptDispatch;
String[] wszScriptFunctions = new String[1];
wszScriptFunctions[0] = "entryMethod";
long[] dispIDFunctions = new long[1];
pIScriptHost.GetScriptDispatch (out pIScriptDispatch);
IntPtr p = Marshal.GetIDispatchForObject(pIScriptHost);
IntPtr ppv;
Marshal.QueryInterface(p,ref diug,out ppv);
pIScriptDispatch = (AXUtil.AXIDispatch)Marshal.GetObjectForIUnknown(ppv);
try
{
pIScriptDispatch.GetIDsOfNames (guid,ref wszScriptFunctions, 1,
1033, out dispIDFunctions);
}
catch (Exception ex)
{
Console.WriteLine (ex.ToString ());
}
}
If I execute Test() I will be getting the following Exception for
Invoking "GetIDsOfNames(....)"
System.Runtime.InteropServices.SEHException: External component has
thrown an exception.
What could be the reason to get this kind exeception, I don't know
what to do in order to handle it error. Could anyone
kindly help me to solve ? I will greatly appreciate.
Thanks & Regards
R. Muthiah Samy