.NET Forum / Languages / Managed C++ / May 2004
Custom attributes are not consistent???
|
|
Thread rating:  |
Bret Pehrson - 13 Jan 2004 19:01 GMT I've converted a non-trivial C++ library to managed, and get the following unhelpful linker error:
Assignment.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001a5). Display.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c000108).
The help for LNK2022 is completely useless:
metadata operation failed (HRESULT) : error_message
The linker detected an error while merging metadata. The metadata errors must be resolved to link successfully.
One reason for LNK2022 is when a struct exists in multiple modules with the same name, but with conflicting definitions, and when you compile with /clr. <<
A search for "Custom attributes are not consistent" at MS turns up *NO* results, and google/google groups only returns a few -- none of which really discuss the problem or it (eventual?) solution.
In this case, I've looked over the source file, and there are no mystery structs floating around, although my searches are far from definitive as the project is composed of hundreds of inter-related files/headers.
Has *ANYONE* figured out or would MS care to elaborate on what the "Custom attributes are not consistent" error means and what the final hex number means? Apparently it has some dynamic value, as similar errors have different values.
 Signature Bret Pehrson mailto:bret@infowest.com NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl
Yan-Hong Huang[MSFT] - 14 Jan 2004 09:22 GMT Hello Bret,
Thanks for posting in the group.
Based on my understanding, the problem is: You are migrating an old C++ library project to managed C++ project. However, when you build the project, you got several error LNK2022: metadata operation failed (80131195) link error. Please let me know if I have misunderstood the problem.
I searched in our database immediately when I saw your post. Unluckily, the hits are small. And it seems that there were no similar report before. So we can't tell exactly where the problem may reside now.
In order to troubleshoot the problem, could you please provide us a small repro sample? We will look into it and reply with detailed information here. You can reach me by removing online from my email address here.
I understand that C++ library is not trivial. Perhaps it is hard for you to isolate the problem or create a repro sample. If so, I suggest you contact our PSS (product support service) to have one support engineer specially help you on it. If you need help on contacting PSS, please feel free to post here and I will post back with detailed information.
If you have any more concerns on it, please feel free to post here. Thanks very much and look forward to your response.
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.
Bret Pehrson - 14 Jan 2004 15:54 GMT Hmmm...
(I'm presuming that you work for/at Microsoft, or have internal contact w/ MS.)
Could you contact the compiler group and have them document the metadata "Custom attributes are not consistent" error?
Thanks
> Hello Bret, > [quoted text clipped - 29 lines] > Get Secure! ¨C www.microsoft.com/security > This posting is provided "AS IS" with no warranties, and confers no rights.
 Signature Bret Pehrson mailto:bret@infowest.com NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl
Ronald Laeremans [MSFT] - 14 Jan 2004 15:59 GMT 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). Usually this is a source error where 2 translation units define a type in a different way.
Ronald Laeremans Visual C++ team
> Hmmm... > [quoted text clipped - 39 lines] > > Get Secure! ?C www.microsoft.com/security > > This posting is provided "AS IS" with no warranties, and confers no rights. Bret Pehrson - 15 Jan 2004 00:12 GMT Ronald -- thanks for the reply. (Please note, none of my comments are meant as a personal attack on you.)
> In the Whidbey release the linker will give better diagnostics. I still stand by my previous post where I say it will be at least the 4th release of the product before it is truly usable in a commercial environment.
> 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). Usually this is a source error where 2 translation > units define a type in a different way. Thanks for defining the mystery error. I was *finally* able to find the source of the problem and resolve it using the technique you describe -- thanks. My comments follow for the purpose of actually documenting the procedure:
First, ILDASM is a mixed-mode application meaning that it has a GUI-mode and console-mode interface.
When running in GUI mode, you *CANNOT* process .obj files (the only files that are documented are .exe and .dll). This means that you must use the tool from the command line (with the appropriate vars set through vsvars32.bat or by running "Visual Studio .NET 2003 Command Prompt" from the VS.NET start menu tools group).
When processing .obj files from the command line, YOU MUST REDIRECT THE OUTPUT TO A FILE or else you will get no results - BUG! BUG! Additionally, you must use the /text option to force output to the console. So, it boils down to:
ildasm your_source_file.obj /text /out=output.txt
The file output.txt is then created -- open it up and then search for the token in question (the last hex number of the "Custom attributes are not consistent" error. (NOTE: the output token identifiers *DO NOT* prefix hex numbers w/ the traditional 0x -- so take this into account when searching for the token.) This will locate the custom attribute of the token that is causing the error. Once you know the token, it should be relatively easy to locate the actual source of the problem.
So, presuming the following errors:
Assignment.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001a5).
The steps would be:
ildasm Assignment.obj /text /out=assignment.txt
Search assignment.txt for "0c0001a5". It should find some custom attribute, look up a few lines and locate the offending type. Armed with that, you can go back to your source files and determine why the type (class/struct) is being defined differently in the different source files.
NOTE TO MICROSOFT: Fix this stupid diagnostic! At the *BARE MINIMUM*, the offending TYPE and ATTRIBUTE should be displayed *BY NAME* -- hex tokens in diagnostics went out w/ Lattice C compilers and powdered wigs, they have *ABSOLUTELY NO BUSINESS IN A 7TH-PLUS GENERATION PRODUCT*
> Ronald Laeremans > Visual C++ team [quoted text clipped - 55 lines] > > mailto:bret@infowest.com > > NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>>
 Signature Bret Pehrson mailto:bret@infowest.com NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl
Yan-Hong Huang[MSFT] - 16 Jan 2004 08:20 GMT Hello Bret,
Thanks very much for your feedback and sharing your experience in how to isolate the problem in the community. I am glad that Ronald's suggestion help resolve the problem.
We will redirect your feedback to the product team. 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.
If there is any any other feedback on our product, you can go to http://register.microsoft.com/mswish/suggestion.asp?&SD=GN&LN=EN-US&gssnb=1 to submit it.
For the usage of ildsam.exe, we can see it from MSDN: Option Description /output:filename Creates an output file with the specified filename, rather than displaying the results in a dialog box. /text Displays the results to the console window, rather than in a dialog box or as an output file. /? Displays the command syntax and options for the tool.
So the command string that you used is correct.
Thanks again for participating the community.
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.
Bret Pehrson - 16 Jan 2004 21:16 GMT > So the command string that you used is correct. Right, but my point was that if you omit the /output=filename flag, you get *NO* output (other than the header) to the console. That is a bug.
Thanks for the follow-up. I'll be glad to see these fixes in your product, although I'd *much* rather have a service pack rather than wait for the next point release.
> Hello Bret, > [quoted text clipped - 28 lines] > Get Secure! ¨C www.microsoft.com/security > This posting is provided "AS IS" with no warranties, and confers no rights.
 Signature Bret Pehrson mailto:bret@infowest.com NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl
Yan-Hong Huang[MSFT] - 19 Jan 2004 01:19 GMT Hi Bret,
>Right, but my point was that if you omit the /output=filename flag, you get >*NO* output (other than the header) to the console. That is a bug. Got it. I will repro it on my side and report to product group.
Thanks very much for participating the community. If there is any we can do for you, please feel free to post new messages in the group.
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.
James Laird - 21 May 2004 19:57 GMT My partner and I encountered this problem as well, and while ILDAS worked, it didn't get us much closer to finding the solution--it looke like the types that were causing the problem came from libc!
In the end, we discovered that some of our managed C++ project included *.c files. Setting these files to be unmanaged (in Fil Properties) fixed the problem
- James Lair
Ronald Laeremans [MSFT] - 19 Jan 2004 04:07 GMT Hi Bret,
I agree that the linker error you get in the VC 7.1 release is very far from ideal. You are seeing some growing pains of fitting a separate compilation model language like C++ into the CLR environment. We knew this issue going into the release of VC 7.1, but the code base we had worked with compiling to IJW internally and from the early adopters we got most feedback from didn't have a large number of occurrences of this issue, so we traded improving this off for other priority fixes. Subsequent experience both internally and externally has shown it to be quite prevalent though. We have been working on getting a KB out on this. I'll check on the status of that.
I am also sorry for my _very_ terse explanation on how to use ildasm and I am glad you still were able to figure it out. We'll make sure your comments on ildasm get to the author of that tool.
Ronald
> Ronald -- thanks for the reply. (Please note, none of my comments are meant as > a personal attack on you.) [quoted text clipped - 114 lines] > > > mailto:bret@infowest.com > > > NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>> Bret Pehrson - 19 Jan 2004 18:09 GMT Ronald -- thanks for the response & comments. I (as well as others) appreciate the insight that you provide on the reasons for the issues, as well as a commitment to clarify/resolve/fix the issue.
I've got to tell you, I'm *very* impressed w/ the response that I've been getting to my issues from Microsoft. I've been out of the newsgroup community for the past couple of years, but before I left, typical MS response to just about any issue was: "That is a known issue and will be fixed in a future release. <end>". It is readily apparent that you all have made a concerted commitment to better handle issues, questions, and comments through the newsgroups, and it is greatly appreciated.
Bret
> Hi Bret, > [quoted text clipped - 173 lines] > > mailto:bret@infowest.com > > NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>>
 Signature Bret Pehrson mailto:bret@infowest.com NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl
Yan-Hong Huang[MSFT] - 20 Jan 2004 03:10 GMT Hi Bret,
Thanks very much for your positive feedback. Ronald and I are all glad to know that you are satisfied with the service here. We are here to support you at your convenience.
Thanks again for participating the community.
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.
Edward Diener - 20 Jan 2004 17:20 GMT > Ronald -- thanks for the response & comments. I (as well as others) > appreciate the insight that you provide on the reasons for the [quoted text clipped - 8 lines] > handle issues, questions, and comments through the newsgroups, and it > is greatly appreciated. The response from MS in these NGs is in inverse proportion to the service packs put out for VS Studio .NET, which so far has been 0 . While I too appreciate the response to reported problems and bugs by MS, I don't appreciate at all the fact that MS seems to think that end users must persevere with these problems and onerous workarounds for years at a time until they come up with a new release, and no doubt new bugs. I would much rather see service packs which actually fixed some of the problems which are reported and acknowledge, making it easier to program without having to memorize all the bugs to be a successful MC++ or C# programmer.
> Bret > [quoted text clipped - 147 lines] >>> NOSPAM - Include this key in all e-mail correspondence >>> <<38952rglkwdsl Ronald Laeremans [MSFT] - 22 Jan 2004 00:41 GMT This specific issue would not be a service pack level fix. It requires a quite substantive change. And it strictly isn't a bug rather than a (very useful) feature that is missing. One of the problems with service packs is the level of expectation that many customers have on them is significantly higher than what we can realistically do in a service pack. The timing of them is of course another issue.
Ronald
> > Ronald -- thanks for the response & comments. I (as well as others) > > appreciate the insight that you provide on the reasons for the [quoted text clipped - 170 lines] > >>> NOSPAM - Include this key in all e-mail correspondence > >>> <<38952rglkwdsl Edward Diener - 22 Jan 2004 02:33 GMT > This specific issue would not be a service pack level fix. It > requires a quite substantive change. And it strictly isn't a bug [quoted text clipped - 3 lines] > realistically do in a service pack. The timing of them is of course > another issue. You're excuses for not putting out a service pack are too transparent for anyone of intelligence, and certainly doesn't fool this one. Nor will I waste time trying to argue against your feeble spin.
If MS doesn't want to put out service packs anymore for Visual Studio, that is their business, but it is not a proper way to support current customers who must use your product, to consistently tell them that a bug has been fixed for the next release of Visual Studio while they are looking for reasonable solutions on this release. Your help, and that of other employees of MS, in finding workarounds and solutions to current bugs is appreciated on these NGs, but MS's new policy of not fixing bugs for the current release can not endear your company to its customers.
> Ronald > [quoted text clipped - 174 lines] >>>>> NOSPAM - Include this key in all e-mail correspondence >>>>> <<38952rglkwdsl Ronald Laeremans [MSFT] - 22 Jan 2004 23:37 GMT Hi Edward,
Our policy on service packs has not changed over the last decade. The only time Visual C++ has ever done what you are asking for is with the VC 4.x subscription releases that contained not just critical bug fixes, but also non critical bug fixes new features or 'issue fixes' that we were able to do in a limited timeframe.
All other times the SP policy for VC and other components of Visual Studio has been fixing critical bugs in the product.
As for VS 2002, I feel very strongly that we made the right call by focusing on the VS 2003 release instead of on the SP for VS 2002 so that we could deliver at least 2 orders of magnitude more improvements (both bug fixes, addressing larger issues and doing new features) on a short timeline and make that product available at a trivial cost (of $29 for the upgrade offer).
Ronald
> > This specific issue would not be a service pack level fix. It > > requires a quite substantive change. And it strictly isn't a bug [quoted text clipped - 195 lines] > >>>>> NOSPAM - Include this key in all e-mail correspondence > >>>>> <<38952rglkwdsl Edward Diener - 23 Jan 2004 12:51 GMT > Hi Edward, > [quoted text clipped - 13 lines] > features) on a short timeline and make that product available at a > trivial cost (of $29 for the upgrade offer). Microsoft put out five service packs for VS6 and you have put out none for VS .NET. Based on that it is very hard to believe that MS's policy on service packs has not changed over the last decade. There is an obvious critical bug with MC++ which is very well documented by MS, said to be fixed with Whidbey, regarding mixed mode MC++ and assembly startup. There are other serious bugs, especially with MC++ ( I reported one personal showstopper recently for which I still have not gotten back a solution ), and there are other bugs as this thread shows. What MS deems to be critical is your own choice but I interpret MS's inability to get out needed service packs for VS .NET as the usual monetary situation, meaning that you want to be paid for fixing bugs in your own product via a new release and a new revenue stream. Also I am sure that service packs for VS6 fixed many problems which may not have been critical but which were highly irritating, burdensome, and time consuming for programmers not only to encounter and verify but to find a workaround for.
You can justify your company's policy regarding service packs for VS .NET however if you like, but it is just that to me; a justification from a company employee and not a fair technical assessment of the need to update your product to make it easier for others to use it. I am sure I am not the only programmer using VS .NET who feels that MS should put out service packs for the product, just like they did for VS6, to fix problems and let programmers get on with their work. Being told that a particular problem is fixed for the next release is nice, but that does not help people working with the current release who are producing critical software.
> Ronald > [quoted text clipped - 200 lines] >>>>>>> NOSPAM - Include this key in all e-mail correspondence >>>>>>> <<38952rglkwdsl
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|