unresolved token!!!

B

Bret Pehrson

Ok, here is a real *nice* one... Fortunately, I didn't waste too much time on
this one, but a real piece of crap to say the least:

Try out this piece of code (managed C++):

//begin code
class ManagedCPPException
{
};

__gc class ClassManagedCPP
{
void DoException()
{
throw new ManagedCPPException();
}
};
//end code

Compile, and you get this WONDERFUL error:

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

Ok... very informative. Ah, I'll just look it up in the online help
(searching...)

[help]
unresolved token 'token'

Similar to an undefined external error, except that the reference is via
metadata.

To resolve:

Define the missing function or data, or
Include the object file or library in which the missing function or data is
already defined.
[end help]

Oh, boy, even more informative. Now tell me something I *don't* know....

Was finally able to whittle down my code, little by little until I figured out
the error.

I need to prefix the exception class w/ __gc, such as:

__gc class ManagedCPPException

Then everything comiles and links as expected.

Two suggestions to Microsoft:

1) Fix the stupid linker to output better (read: more informative) error
messages, and stop already w/ the hex and mangled crap in the message.

2) Fire your documentation staff. Your online help files for compiler and
linker errors really blows chunks.

For crap sakes, I spent 2 grand for VS.NET, and $100 says the MS response to
this message is "this issue will be addressed in an upcoming release (whidbey)"
-- nice, I'm going to have to plop down another 2 g's for that...
 
Y

Yan-Hong Huang[MSFT]

Hello Bret,

As I understand, now the question is: The error message of linker in VS.NET
2003 is not so informative.

This is a known issue of VS.NET linker. In the Whidbey release the linker
will give better diagnostics. For now the way to diagnose this is using
ildasm to dump the metadata of the .obj files to text and then search for
the tokens (the hex numbers mentioned in the error messages, 0A000012 in
your case) So you can find which type can't be found or defined in a
different way.

For more information on this topic, please refer to this issue thread:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=400C1D56
..1468D275%40infowest.com&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%
26oe%3DUTF-8%26q%3DRonald%2B--%2Bthanks%2Bfor%2Bthe%2Bresponse%2B%2526%2Bcom
ments

Thanks very much for your feedback, Bret. We are looking at continual
improvement, and it's this kind of feedback that let's us know what things
you're trying to do, that we haven't yet exposed for you.

Keep the information coming.

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.
 
B

Bret Pehrson

For now the way to diagnose this is using ildasm to dump the metadata
of the .obj files to text and then search for the tokens

Yes, I did that in this case, but it gave absolutely no contextual information,
so I had to resort to dog-boning to find the source of the problem.

How is the clown at Microsoft who shoved VS.NET and VS.NET 2003 out the door
*long* before they were ready?

I think that I'm going to start telling my clients that when my software
doesn't work that I'm following the Microsoft release model...
 
Y

Yan-Hong Huang[MSFT]

Hi Bret,

I tested you sample code on VS.NET 2002 and VS.NET 2003 just now. However,
I didn't get any linker error when building the code. My project type is
.NET VC++ console application.

Could you create a sample for me to repro it? You can email me by removing
online from my email address here. I will test it on my side.

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.
 
B

Bret Pehrson

Yanhong -- yes, I wasn't able to create the problem w/ a new fresh project (w/
copied code).

I should still have the original project, I'll zip it up and e-mail it to you.

Thanks for looking into this, I'll be very interested to see what you find.
 
Y

Yan-Hong Huang[MSFT]

Hi Bret,

I got your email already. When I checked it, I found some interesting
parts. I have replied email to you and asked for detailed steps when you
created that project. It seems in that project, you chose a wrong project
type.

Thanks very much.

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.
 
Y

Yan-Hong Huang[MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top