473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

COM interoperatability using PInvoke (SEH Exception)

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
Nov 22 '05 #1
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

Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
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...
5
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...
3
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...
0
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...
1
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...
3
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...
7
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...
2
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 ...
0
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...
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.