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(p pv);
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 1 2558
Muthiah,
You should not have to call GetIdsOfNames. If you want to make late
bound calls, you should use reflection instead. What exactly are you trying
to do? Are you indeed trying to make late bound calls?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Muthiah Samy" <mu******@aztec.soft.net> wrote in message
news:4b**************************@posting.google.c om... 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(p pv);
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Muthiah Samy |
last post by:
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...
|
by: Miyra |
last post by:
Hi. I'm working with an app that uses exceptions for control flow.
These are code blocks where exceptions are thrown/caught regularly. A
couple hundred exceptions occur per hour and they're caught...
|
by: HairlipDog58 |
last post by:
I have a VC++6 project where I need to delay load a DLL. I used a structured
exception handling frame and all seems to work when I build the debug version
and run it (either in or out of the...
|
by: Don Lopez |
last post by:
I get this exception when I try to run open on the MySQLConnection
object. It goes like this:
System.TypeLoadException: Invalid PInvoke metadata format.
at...
|
by: IT |
last post by:
I want to fire off threads to start retrieving File from several locations.
FTP and the local network. Is it ok to start these threads on the main form
load.
Ex.
Every day we load EDI files...
|
by: Johnny |
last post by:
Hi guys,
I created a user-defined SEH by following Crash Course SEH article by Matt
Pietrek. When building the app in Debug mode, it has no problem catching
exception and entering the user...
|
by: yogeshnelwadkar |
last post by:
Hello, i have a problem with replacing c++ exception handling with
structured exception handling. How to replace the " catch(...) " in
c++ exception handling with, __except , a structured...
|
by: yewen |
last post by:
My C# client (.dotNet 2.0 and WSE 3.0) generated the following SOAP
message.
<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope
...
|
by: =?Utf-8?B?UXVpbWJseQ==?= |
last post by:
We're the ReportViewer Control in a .NET 2.0 winforms app.
Here's the call I'm making:
byte reportBytes = this.reportViewerInstallRpt.LocalReport.Render("PDF",
null, out mimeType, out...
|
by: j4richard |
last post by:
Help please,
I am getting this "Unhandled Exception has occurred in your application"
" A Generic error occurred in GDI+"
See the end of this message for details on...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |