被例外困惑 [英] baffled by exception

查看:107
本文介绍了被例外困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。

有人知道C#调用COM

对象的方式和C ++调用COM对象的方式有什么区别吗?无论如何要使

后者模仿前者?


我有一个看似无法用C ++实例化的COM对象,但是可以

使用C#和VB,这让我疯了 - 我不能弄清楚什么是错的

用它。

当任何C ++代码尝试实例化它时,它似乎抛出异常,引用用户断点作为原因



如果当它处于调试模式时,我点击''继续''异常,它重新抛出

它为:

System.Runtime.InteropServices.COMException(0xC0000096) :例外来自

HRESULT:0xC0000096。


但是当try..catch为圆形时它仍然会抛出消息框!

这个COM对象,我完全拥有并且它的加密狗已插入。就像我说的那样,

我可以用其他语言实例化这个COM对象并且我可以实例化

使用这些的其他COM对象C ++中的方法。


他们可能不希望你从C ++中使用它,并且可以

告诉吗?

有什么想法吗?

干杯!

Hello.
Does anybody know if there is a difference between the way C# calls a COM
object, and the way C++ calls a COM object? And is there anyway to make the
latter emulate the former?

I have a COM object which seemingly can''t be instantiated using C++, but can
using C# and VB, and it''s driving me insane - I can''t work out what''s wrong
with it.
It just seems to throw an exception, citing ''User Breakpoint'' as the cause
of the exception when any C++ code tried to instantiate it.
If I click ''continue'' to the exception when it''s in debug mode, it rethrows
it as:
System.Runtime.InteropServices.COMException (0xC0000096): Exception from
HRESULT: 0xC0000096.

But it still throws up the message box when the try..catch is round it!
This COM object, I fully own and the dongle to it is plugged in. Like I say,
I can instantiate this COM object in other languages and I can instantiate
other COM objects using these methods in C++.

Is it possible they could have not wanted you to use it from C++, and can
tell?
Any ideas?
Cheers!

推荐答案

Bonj,


这个对我来说似乎不太可能,因为.NET中的机制最终使用与C ++相同的机制。你能说明你是如何在

..NET中做到的,以及你是如何用C ++做的?也许你没有正确设置

环境或公寓,这可能是你的
问题的根源。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Bonj" <博** @ discussions.microsoft.com>在消息中写道

新闻:D7 ********************************** @ microsof t.com ...
Bonj,

This seems highly unlikely to me, as the mechanism in .NET ultimately
uses the same mechanism that C++ uses. Can you show how you are doing it in
..NET and how you are doing it in C++? Perhaps you are not setting up the
environment or the apartment correctly, and this could be the source of your
problems.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bonj" <Bo**@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
你好。
有人知道C#调用COM对象的方式和C ++调用COM对象的方式有什么区别吗?无论如何要使
后者模仿前者?

我有一个COM对象,似乎不能用C ++实例化,但
可以
使用C#和VB,它让我疯狂 - 我无法解决它的错误
用它。
它似乎扔了一个例外,引用用户断点作为异常的原因,当任何C ++代码试图实例化它时。
如果我点击''继续''异常调试模式,它重新抛出
它为:
System.Runtime.InteropServices.COMException(0xC0000096):例外来自
HRESULT:0xC0000096。

但是当try..catch是圆形的时候它仍然会抛出消息框!
这个COM对象,我完全拥有它和它的加密狗插入。就像我
说,
我可以用其他语言实例化这个COM对象,我可以在C ++中使用这些方法实例化其他COM对象。

是否可能他们可能不希望你用它来使用C ++,并且可以告诉你吗?
任何想法?

干杯!
Hello.
Does anybody know if there is a difference between the way C# calls a COM
object, and the way C++ calls a COM object? And is there anyway to make
the
latter emulate the former?

I have a COM object which seemingly can''t be instantiated using C++, but
can
using C# and VB, and it''s driving me insane - I can''t work out what''s
wrong
with it.
It just seems to throw an exception, citing ''User Breakpoint'' as the cause
of the exception when any C++ code tried to instantiate it.
If I click ''continue'' to the exception when it''s in debug mode, it
rethrows
it as:
System.Runtime.InteropServices.COMException (0xC0000096): Exception from
HRESULT: 0xC0000096.

But it still throws up the message box when the try..catch is round it!
This COM object, I fully own and the dongle to it is plugged in. Like I
say,
I can instantiate this COM object in other languages and I can instantiate
other COM objects using these methods in C++.

Is it possible they could have not wanted you to use it from C++, and can
tell?
Any ideas?
Cheers!



Bonj,


这对我来说似乎不太可能,因为.NET中的机制最终使用与C ++相同的机制。你能说明你是如何在

..NET中做到的,以及你是如何用C ++做的?也许你没有正确设置

环境或公寓,这可能是你的
问题的根源。


希望这会有所帮助。

" Bonj" <博** @ discussions.microsoft.com>在消息中写道

新闻:D7 ********************************** @ microsof t.com ...
Bonj,

This seems highly unlikely to me, as the mechanism in .NET ultimately
uses the same mechanism that C++ uses. Can you show how you are doing it in
..NET and how you are doing it in C++? Perhaps you are not setting up the
environment or the apartment correctly, and this could be the source of your
problems.

Hope this helps.
"Bonj" <Bo**@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
你好。
有人知道C#调用COM对象的方式和C ++调用COM对象的方式有什么区别吗?无论如何要使
后者模仿前者?

我有一个COM对象,似乎不能用C ++实例化,但
可以
使用C#和VB,它让我疯狂 - 我无法解决它的错误
用它。
它似乎扔了一个例外,引用用户断点作为异常的原因,当任何C ++代码试图实例化它时。
如果我点击''继续''异常调试模式,它重新抛出
它为:
System.Runtime.InteropServices.COMException(0xC0000096):例外来自
HRESULT:0xC0000096。

但是当try..catch是圆形的时候它仍然会抛出消息框!
这个COM对象,我完全拥有它和它的加密狗插入。就像我
说,
我可以用其他语言实例化这个COM对象,我可以在C ++中使用这些方法实例化其他COM对象。

是否可能他们可能不希望你从C ++中使用它,并且可以告诉你吗?
任何想法?

干杯!
Hello.
Does anybody know if there is a difference between the way C# calls a COM
object, and the way C++ calls a COM object? And is there anyway to make
the
latter emulate the former?

I have a COM object which seemingly can''t be instantiated using C++, but
can
using C# and VB, and it''s driving me insane - I can''t work out what''s
wrong
with it.
It just seems to throw an exception, citing ''User Breakpoint'' as the cause
of the exception when any C++ code tried to instantiate it.
If I click ''continue'' to the exception when it''s in debug mode, it
rethrows
it as:
System.Runtime.InteropServices.COMException (0xC0000096): Exception from
HRESULT: 0xC0000096.

But it still throws up the message box when the try..catch is round it!
This COM object, I fully own and the dongle to it is plugged in. Like I
say,
I can instantiate this COM object in other languages and I can instantiate
other COM objects using these methods in C++.

Is it possible they could have not wanted you to use it from C++, and can
tell?
Any ideas?
Cheers!






如果未正确安装COM编组代码(代理/存根),则单元类型不匹配只会成为问题。此错误是与尝试使用的特权指令相关的COM错误。它通常与代理/存根dll(其中包含接口编组代码)相关,与COM对象实现的接口定义不一致。


问候


Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/< ; Og ************** @ TK2MSFTNGP11.phx.gbl>


Bonj,


这个对我来说似乎不太可能,因为.NET中的机制最终使用与C ++相同的机制。你能用你的b $ b .NET来展示你是如何做到这一点的,以及你是如何用C ++做的?也许你没有正确设置

环境或公寓,这可能是你的
问题的根源。


希望这会有所帮助。
An apartment type mismatch is only going to be a problem if the COM marshalling code (proxy/stub) is not installed properly. This error is a COM error relating to a privileged instruction attempting to be used. It is often in relation to the proxy/stub dll (that has the interface marshalling code in it) being out of step with the definition of the interface the COM object has implemented.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<Og**************@TK2MSFTNGP11.phx.gbl>

Bonj,

This seems highly unlikely to me, as the mechanism in .NET ultimately
uses the same mechanism that C++ uses. Can you show how you are doing it in
.NET and how you are doing it in C++? Perhaps you are not setting up the
environment or the apartment correctly, and this could be the source of your
problems.

Hope this helps.


这篇关于被例外困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆