473,946 Members | 12,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COM interoperatabil ity 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::GetI DSOfNames(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 pIScriptDispatc h;
String[] wszScriptFuncti ons = new String[1];
wszScriptFuncti ons[0] = "entryMetho d";
long[] dispIDFunctions = new long[1];

pIScriptHost.Ge tScriptDispatch (out pIScriptDispatc h);
IntPtr p = Marshal.GetIDis patchForObject( pIScriptHost);
IntPtr ppv;
Marshal.QueryIn terface(p,ref diug,out ppv);
pIScriptDispatc h = (AXUtil.AXIDisp atch)Marshal.Ge tObjectForIUnkn own(ppv);

try
{
pIScriptDispatc h.GetIDsOfNames (guid,ref wszScriptFuncti ons, 1,
1033, out dispIDFunctions );
}
catch (Exception ex)
{
Console.WriteLi ne (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 2600
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.co m

"Muthiah Samy" <mu******@aztec .soft.net> wrote in message
news:4b******** *************** ***@posting.goo gle.com...
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::GetI DSOfNames(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 pIScriptDispatc h;
String[] wszScriptFuncti ons = new String[1];
wszScriptFuncti ons[0] = "entryMetho d";
long[] dispIDFunctions = new long[1];

pIScriptHost.Ge tScriptDispatch (out pIScriptDispatc h);
IntPtr p = Marshal.GetIDis patchForObject( pIScriptHost);
IntPtr ppv;
Marshal.QueryIn terface(p,ref diug,out ppv);
pIScriptDispatc h = (AXUtil.AXIDisp atch)Marshal.Ge tObjectForIUnkn own(ppv);

try
{
pIScriptDispatc h.GetIDsOfNames (guid,ref wszScriptFuncti ons, 1,
1033, out dispIDFunctions );
}
catch (Exception ex)
{
Console.WriteLi ne (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
370
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 Code ---------------
5
3828
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 close to the point of origination. I'm trying to decide whether to refactor... What is the cost of throwing an exception in the CLR - relative to, say, a conditional statement? Are we taking talking 1+ orders of magnitude? Is there...
3
1925
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 debugger). In debug build, the exception is caught and reported gracefully to the user. When I build the release version and run it, the SEH frame does not catch the exception and the application crashes. Has anyone had a similar experience and if...
0
1004
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 System.Net.OSSOCK.gethostbyname(String host) at System.Net.Dns.GetHostByName(String hostname) at ByteFX.Data.Common.StreamCreator.GetStream(Int32 timeOut) at ByteFX.Data.MySqlClient.Driver.Open(MySqlConnectionString settings) --- End of inner exception stack trace --- at...
1
1603
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 into a SQL server. When the main form start out can I have a thread run this process and disable the menu item so that the user does not try to load the files until they are all downloaded. And is it ok to disable the dispose method of the form until...
3
1443
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 defined hanlder. In Release mode, however, the app would just crash at the point where the exception occurs. Why is that? Is there any way to solve this? Thanks in advance,
7
3335
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 exception handling. If i write "#define catch(...) ----" ; then it doesn't take ' ... ' as a string ; so, prompts an error.. error C2010: '.' : unexpected in macro formal parameter list what to be written in place of ' --- ' ; to be convert it into an...
2
5602
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 xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
0
1256
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 encoding, out extension, out streamids, out warnings); Here's the exception: A call to PInvoke function 'Microsoft.ReportViewer.Common!Microsoft.ReportingServices.Rendering.ImageRenderer.CompositionPDF+WindowsGDIWrapper::GetGlyphIndicesW'
7
10407
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 invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
0
10151
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9980
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11557
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10685
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8247
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7412
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6111
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6328
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4933
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.