473,320 Members | 1,857 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,320 software developers and data experts.

Catch in unmamaged code won't link

Try this one on for size:

// Managed C++ Project/code
#pragma unmanaged
struct S
{
};

void Func()
{
try
{
}
catch (S * s)
{
}
}
#pragma managed
When compiled, produces the following:

LINK : error LNK2020: unresolved token (0A000013) ??_7type_info@@6B@
Poking around in the generated .obj file w/ ildasm for token 0A000013 reveals
the following:

// MemberRef #9
// -------------------------------------------------------
// Member: (0a000013) __CxxUnregisterExceptionObject:
// CallCnvntn: [DEFAULT]
// ReturnType: CMOD_OPT System.Runtime.CompilerServices.CallConvCdecl Void
// 2 Arguments
// Argument #1: Ptr Void
// Argument #2: I4
// CustomAttribute #1 (0c000013)
// -------------------------------------------------------
// CustomAttribute Type: 0a00000c
// CustomAttributeName: Microsoft.VisualC.DecoratedNameAttribute :: instance
void .ctor(class System.String)
// Length: 51
// Value : 01 00 2e 3f 5f 5f 43 78 78 55 6e 72 65 67 69 73 >
..?__CxxUnregis<
// : 74 65 72 45 78 63 65 70 74 69 6f 6e 4f 62
6a 65 >terExceptionObje<
// : 63 74 40 40 24 24 4a 30 59 41 58 50 41 58
48 40 >ct@@$$J0YAXPAXH@<
// : 5a 00
00 >Z <
// ctor args: ("?__CxxUnregisterExceptionObject@@$$J0YAXPAXH@ Z")
//
Obviously, __CxxUnregisterExceptionObject isn't something that I've defined,
but is a core component that appears to be missing. Yes, C++ exceptions are
enabled for the project...
Anyone seen this, and how they resolved it?


--
Bret Pehrson
mailto:br**@infowest.com
NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>>
Nov 17 '05 #1
3 1501
Ok, this is purely bogus.

I ended up scrapping that project, creating a new one, pasting in the *exact
same code*, and it now builds fine.

I probably spent an hour pouring over the project configuration settings,
comparing the old w/ the new, and found virtually no differences.

Come on MS -- stop wasting my time w/ your crappy product that I paid for.

Bret Pehrson wrote:

Try this one on for size:

// Managed C++ Project/code
#pragma unmanaged
struct S
{
};

void Func()
{
try
{
}
catch (S * s)
{
}
}
#pragma managed

When compiled, produces the following:

LINK : error LNK2020: unresolved token (0A000013) ??_7type_info@@6B@

Poking around in the generated .obj file w/ ildasm for token 0A000013 reveals
the following:

// MemberRef #9
// -------------------------------------------------------
// Member: (0a000013) __CxxUnregisterExceptionObject:
// CallCnvntn: [DEFAULT]
// ReturnType: CMOD_OPT System.Runtime.CompilerServices.CallConvCdecl Void
// 2 Arguments
// Argument #1: Ptr Void
// Argument #2: I4
// CustomAttribute #1 (0c000013)
// -------------------------------------------------------
// CustomAttribute Type: 0a00000c
// CustomAttributeName: Microsoft.VisualC.DecoratedNameAttribute :: instance
void .ctor(class System.String)
// Length: 51
// Value : 01 00 2e 3f 5f 5f 43 78 78 55 6e 72 65 67 69 73 >
.?__CxxUnregis<
// : 74 65 72 45 78 63 65 70 74 69 6f 6e 4f 62
6a 65 >terExceptionObje<
// : 63 74 40 40 24 24 4a 30 59 41 58 50 41 58
48 40 >ct@@$$J0YAXPAXH@<
// : 5a 00
00 >Z <
// ctor args: ("?__CxxUnregisterExceptionObject@@$$J0YAXPAXH@ Z")
//

Obviously, __CxxUnregisterExceptionObject isn't something that I've defined,
but is a core component that appears to be missing. Yes, C++ exceptions are
enabled for the project...

Anyone seen this, and how they resolved it?

--
Bret Pehrson
mailto:br**@infowest.com
NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>>


--
Bret Pehrson
mailto:br**@infowest.com
NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>>
Nov 17 '05 #2
Hi Bret,

I posted reply in your former post on this issue. As you mentioned, I can't
reproduce the problem on my side. The same code can be built without any
error on both VS.NET 2002 and VS.NET 2003.

Have you installed any VS.NET add-in? I think you can use the tool WinDiff
in C:\Program Files\Microsoft Visual Studio .NET\Common7\Tools\Bin (for
vs.net 2002, if vs.net 2003, then change to Microsoft Visual Studio .NET
2003\...) to tell the difference in two project to see if you can find
anything special there.

Thanks.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #3
Hi Bret,

Thanks for your update.

From the repro sample, I think we get the root cause of why you met this
problem. The reason is that the project type is not correct. It is not
related to the project name.

For the code we are using, we need to create .NET console application
instead of a class library or a DLL project. You could test the same code
in a Visual C++.NET .NET console application. It should be working fine.

If there is anything unclear, please feel free to let me know.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #4

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

Similar topics

1
by: Marcin Wieczorek | last post by:
I'm trying to write a managed DLL that will wrap communications between managed and unmanaged c++. All of the unmanaged code is lined to a static lib. That lib contains tons of stuff like STL...
10
by: Gary.Hu | last post by:
I was trying to catch the Arithmetic exception, unsuccessfully. try{ int a = 0, b = 9; b = b / a; }catch(...){ cout << "arithmetic exception was catched!" << endl; } After ran the program,...
6
by: Erik Cruz | last post by:
Hi. I have read several articles recommending avoid to raise exceptions when possible, since exceptions are expensive to the system. Removing code from Try... Catch blocks can help performance?...
8
by: Z D | last post by:
Hi, I was wondering what's the point of "finally" is in a try..catch..finally block? Isn't it the same to put the code that would be in the "finally" section right after the try/catch block?...
4
by: lauch2 | last post by:
In a default MFC - dialog based application (VC6.0 or VC7.1), the following try-catch code does not be catched in Release mode, but it is OK for Debug mode. Any compiler/link option is required to...
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
5
by: PasalicZaharije | last post by:
Hallo, few days ago I see ctor like this: Ctor() try : v1(0) { // some code } catch(...) { // some code }
3
by: Martin | last post by:
Hi. I need to identify the type of the exception in the universal handler (catch (...)) for debugging purposes. Point is that I write a testing console application, which must call some...
8
by: Luke Davis | last post by:
I'm new so bear with me. Is there a way for the catch to fix a problem then start the try over again? For example, I have this console application sync a remote database and it takes hours. ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.