Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

IMetaDataImport::FindTypeRef fails to return TypeRef token for known Type from a reference assembly

$
0
0

I am writing and IL re-writing profiler for .NET assemblies.

I have the following code snippet and applying it to the EntityFramework.dll assembly function.

   

//Enumerate all reference assemblies for current assembly				

hResult = pMDAImport->EnumAssemblyRefs( &assemblyEnum, assemblyRefs, numElements( assemblyRefs ), &assemblyRefsCount );

// Walk through all referenced assemblies to find System.Data.IDbCommand token

// for( unsigned assemblyRefIdx = 0; (unmatchedTypes > 0) && (assemblyRefIdx < assemblyRefsCount); assemblyRefIdx++ ) { assemblyRef = assemblyRefs[ assemblyRefIdx ]; WCHAR tempAssName[50]; ULONG szAssNameRet = 0; hResult = pMDAImport->GetAssemblyRefProps(assemblyRef, NULL, 0, tempAssName, numElements(tempAssName), &szAssNameRet, NULL, NULL, 0, NULL); if (hResult == S_OK) { if( CLogger::isLevelEnabled( LL_Debug ) ) CLogger::Log( LL_Debug, "Searching for dependent types in assemblyRef(%08X) (%d/%d) - %S\n", assemblyRef, assemblyRefIdx + 1, assemblyRefsCount, tempAssName); } hResult = m_pMDImport->FindTypeRef( assemblyRef, L"System.Data.IDbCommand", &typeRef ); if( (m_idbCommandTypeToken == mdTokenNil) && SUCCEEDED( m_pMDImport->FindTypeRef( assemblyRef, L"System.Data.IDbCommand", &typeRef ) ) ) { m_idbCommandTypeToken = typeRef; }

The logging confirms it sees System.data as one of the referenced assemblies which should contain the TypeRef forSystem.Data.IDbCommand

014.04.22.15.33.50.951  [00002B0C]  DEBUG    Searching for dependent types in assemblyRef(23000003) (3/13) - System.Data

Can you tell me why the FindTypeRef fails and how to get around this ?

Regards

Sanjay

The hResult error is

CLDB_E_RECORD_NOTFOUND

0x80131130

Record not found on lookup.


Sanjay Mehta



Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>