RE: IMetaDataEmit->DefineCustomAttribute returning E_INVALIDARG - bug?
From: Tim Kurtzman (timkur_at_microsoft.com)
Date: 08/31/04
- Next message: Ben Schwehn: "Re: How to get caller's "this"?"
- Next in thread: Brian Tyler: "Re: IMetaDataEmit->DefineCustomAttribute returning E_INVALIDARG - bug?"
- Reply: Brian Tyler: "Re: IMetaDataEmit->DefineCustomAttribute returning E_INVALIDARG - bug?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 31 Aug 2004 00:14:56 GMT
This is a bug. We'll work on fixing this in our next release.
You'll hate this workaround, but if you add enough types so that the tokens
you get exceed 0x0600FFFF, then the problem *should* go away.
If this is an unacceptable workaround, please let me know and we can
consider this fix in a service pack.
Tim
--------------------
| X-Tomcat-ID: 476697815
| References: <OMX0r0meEHA.1736@TK2MSFTNGP12.phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: timkur@microsoft.com ("Tim Kurtzman")
| Organization: Microsoft
| Date: Tue, 10 Aug 2004 18:08:10 GMT
| Subject: RE: IMetaDataEmit->DefineCustomAttribute returning E_INVALIDARG
- bug?
| X-Tomcat-NG: microsoft.public.dotnet.framework.clr
| Message-ID: <To1mDUwfEHA.3636@cpmsftngxa06.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.clr
| Lines: 68
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.clr:11469
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| This definitely sounds like a bug. I'll work on putting a repro together
| and let you know what I find.
|
| Thanks for reporting this.
|
| Tim
| --------------------
| | From: "Brian Tyler" <brianmtyler@yahoo.com>
| | Subject: IMetaDataEmit->DefineCustomAttribute returning E_INVALIDARG -
| bug?
| | Date: Wed, 4 Aug 2004 16:51:46 -0500
| | Lines: 50
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| | Message-ID: <OMX0r0meEHA.1736@TK2MSFTNGP12.phx.gbl>
| | Newsgroups: microsoft.public.dotnet.framework.clr
| | NNTP-Posting-Host: ip67.tonic.com 216.54.231.67
| | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.clr:11435
| | X-Tomcat-NG: microsoft.public.dotnet.framework.clr
| |
| | I am doing some work on a very large assembly (lots and lots and lots of
| | methods in here). I have created a new method and it gets assigned a
token
| | of 0x06000822. I then go to add a custom attribute to it, but
| | DefineCustomAttribute returns E_INVALIDARG (this is v1.1).
| |
| | Using the disassembly view in VS.NET and the SSCLI source (which
| thankfully
| | is very close), I was able to determine the following:
| |
| | DefineCustomAttribute() calls
| | PutToken(), specifically:
| |
| | IfFailGo(m_pStgdb->m_MiniMd.PutToken(TBL_CustomAttribute,
| | CustomAttributeRec::COL_Type, pRecord, tkType));}
| |
| | PutToken in turn calls
| | encodeToken() and PutCol(), specifically:
| |
| | const CCodedTokenDef *pCdTkn = &g_CodedTokens[ColDef.m_Type -
| iCodedToken];
| | cdTkn = encodeToken(RidFromToken(tk), TypeFromToken(tk),
| pCdTkn->m_pTokens,
| | pCdTkn->m_cTokens);
| | hr = PutCol(ColDef, pvRecord, cdTkn);
| |
| | Here is the kicker = encodeToken() takes 0x06000822 and returns 0x10440.
| | BUT, PutCol() looks up the size of specified column (in the ColDef
| argument)
| | and sees that it's max size is 2 bytes - which 0x10440 exceeds and thus
it
| | returns E_INAVLIDARG.
| |
| | For those that are interested, I've included the run time data of the
key
| | elements below.
| |
| | Anyone in the ROTOR group or MS able to shed light on this?
| |
| | Brian
| |
| |
| | =================================================================
| |
| | CMiniColDef ColDef.Type = 0x42
| | CMiniColDef ColDef.oCol = 0x0
| | CMiniColDef ColDef.cbCol = 0x2
| |
| | CCodedTokenDef* pCdTkn:
| | m_cTokens = 0x15
| | m_pTokens = {0x0600000, 0x0400000, 0x0100000, ...} - matches on the
| first
| | one anyway
| | m_pName = "HasCustomAttribute"
| |
| | thus in encodedToken(), ix = 0, m_cb[cTokens] = 5, rid=0x822
| |
| |
| |
|
|
- Next message: Ben Schwehn: "Re: How to get caller's "this"?"
- Next in thread: Brian Tyler: "Re: IMetaDataEmit->DefineCustomAttribute returning E_INVALIDARG - bug?"
- Reply: Brian Tyler: "Re: IMetaDataEmit->DefineCustomAttribute returning E_INVALIDARG - bug?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|