.NETGURU
IMetaDataEmit->DefineCustomAttribute returning E_INVALIDARG - bug?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.clr.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Brian Tyler
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

Reply to this message...
 
    
Tim Kurtzman (VIP)
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" <Click here to reveal e-mail address>
| 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: <Click here to reveal e-mail address>
| 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
|
|
|

Reply to this message...
 
    
Tim Kurtzman (VIP)
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: <Click here to reveal e-mail address>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: Click here to reveal e-mail address ("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: <Click here to reveal e-mail address>
| 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" <Click here to reveal e-mail address>
| | 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: <Click here to reveal e-mail address>
| | 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
| |
| |
| |
|
|

Reply to this message...
 
    
Brian Tyler
No - that is not unacceptable. But it will be fixed in 2.0?

Thanks for looking into it.

Brian

""Tim Kurtzman"" <Click here to reveal e-mail address> wrote in message
news:KSivU%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Tim Kurtzman (VIP)
Yep, it will be fixed in 2.0.

As an alternative to adding a bunch of types, you can get the metadata to
"expand" all of its tables before trying to write the custom attributes on
types whose RID values are greater than 0x8000. That would involve
creating 65k types, or 65k methods, or 65k worth of strings/blobs/etc.
Basically, you'll need the metadata to use 4 bytes to represent any token
instead of just 2.

Thanks for reporting this, and sorry for the inconvience we've caused you.

Tim

--------------------
| From: "Brian Tyler" <Click here to reveal e-mail address>
| References: <Click here to reveal e-mail address>
<Click here to reveal e-mail address>
<KSivU#Click here to reveal e-mail address>
| Subject: Re: IMetaDataEmit->DefineCustomAttribute returning E_INVALIDARG
- bug?
| Date: Wed, 1 Sep 2004 08:54:45 -0500
| Lines: 129
| 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: <#Click here to reveal e-mail address>
| Newsgroups: microsoft.public.dotnet.framework.clr
| NNTP-Posting-Host: ip67.tonic.com 216.54.231.67
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA06.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.clr:11765
| X-Tomcat-NG: microsoft.public.dotnet.framework.clr
|
| No - that is not unacceptable. But it will be fixed in 2.0?
|
| Thanks for looking into it.
|
| Brian
|
| ""Tim Kurtzman"" <Click here to reveal e-mail address> wrote in message
| news:KSivU%Click here to reveal e-mail address...
| > 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: <Click here to reveal e-mail address>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain
| > | Content-Transfer-Encoding: 7bit
| > | From: Click here to reveal e-mail address ("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: <Click here to reveal e-mail address>
| > | 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" <Click here to reveal e-mail address>
| > | | 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: <Click here to reveal e-mail address>
| > | | 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
| > | |
| > | |
| > | |
| > |
| > |
| >
|
|
|

Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification