This project is read-only.

Cannot resolve type System.String.

Topics: Metadata Model
Dec 26, 2010 at 3:46 AM
Edited Dec 30, 2010 at 3:00 AM

I have a property definition from an assembly that was read by your code.

The type of the property is System.String as confirmed by TypeHelper.TypesAreEquivalent(propertyDefinition.Type, metadataHost.PlatFormType.SystemString) returning true.

But propertyDefinition.Type.ResolvedType is a dummy type definition. Reason: the assembly corresponding to the CoreAssemblySymbolicIdentity is not present in the unitCache.

My question is: can't the metadataHost just load it?

Why do I have to load it manually before anything else just to prevent something like this to happen. Unfortunately I don't understand the inner workings.

Thanks!

Jan 8, 2011 at 1:16 AM

The decision to load an assembly is a policy issue, as is the probing logic. Consequently, the metadata reader relies on the metadata host to do this.

The default host does have some logic that tries to resolve and load the assembly. This logic lives in the ProbeAssemblyReference method, which you can override.



The logic in the default host ought to suffice for most situations. Perhaps you have your own host that does not derive from the default host?

Jan 8, 2011 at 5:46 AM
Edited Jan 8, 2011 at 6:04 AM

All my metadata hosts derive from your MetadataReaderHost.

I'll have a look at ProbeAssemblyReference to see if I impaired its functionality with any other override. 

I'll try and derive from PeReader.DefaultHost (in case that's what you mean with "default host"). I actually never investigated the differences.

Thanks.

Jan 8, 2011 at 6:05 AM

I replaced MetadataReaderHost with PeReader.DefaultHost and, whatever is the difference, now there is no need to force load the core assembly. Thanks.