InvalidKeyException, trouble with simple Addressables use case (lots of pictures!)

Hi folks, hoping someone can point me in the right direction because I’ve been searching for a solution for hours for what should be a simple Addressables use case.

I’ve installed the latest Addressables 1.8.3:

I’ve created an Addressables Group called “CORE”, set it as default. I’ve added a single file to it, an XML document called symbiote.xml and changed the Addressable Name to “coreXML”:

The Addressable Group has the usual configuration, and I have built the Addressables in the Addressables GUI using the default build scripts. I’ve also cleared the cache and re-built just to be sure:

I have a simple LoadAssetAsync request, using type XmlDocument and passing in assetName (a string, representing the key I want to use, in this case “coreXML”:

// Core function that imports XML data, should only run if it has not been imported yet!
    internal static void ImportXMLData( string assetName )
    {
        string hereParams = here + "ImportXMLData(assetName: " + assetName.ToString() + "): ";
        ReportingAPI.RecordNotice( hereParams + "Fired!" );

        // Validation...
        if( string.IsNullOrWhiteSpace( assetName ) )
        {
            ReportingAPI.RecordError( hereParams + "assetName was null or blank!" );
            return;
        }
        else if( dataHasBeenImported )
        {
            // Data was already imported! Why are you trying again?
            ReportingAPI.RecordError( hereParams + "dataHasBeenImported is already TRUE, why are you trying again?" );
            return;
        }

        Addressables.LoadAssetAsync<XmlDocument>( assetName ).Completed += Event_DatafileLoaded;

    }

But no matter what I try, I always get a InvalidKeyException and a failure in the asset load:

Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[System.Xml.XmlDocument], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=coreXML, Type=System.Xml.XmlDocument UnityEngine.AddressableAssets.Addressables:LoadAssetAsync(Object) DataImporterAPI:ImportXMLData(String) (at Assets/Symbiote/Core/Code/DataImporterAPI.cs:57) BootAPI:Event_AddressablesInitialized(AsyncOperationHandle) (at Assets/Symbiote/Core/Code/BootAPI.cs:99) DelegateList`1:Invoke(AsyncOperationHandle) (at Library/PackageCache/com.unity.addressables@1.8.3/Runtime/ResourceManager/Util/DelegateList.cs:69) UnityEngine.AddressableAssets.Initialization.<>c__DisplayClass14_0:<LoadContentCatalogInternal>b__0(AsyncOperationHandle`1) DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.8.3/Runtime/ResourceManager/Util/DelegateList.cs:69) UnityEngine.ResourceManagement.ChainOperation`2:OnWrappedCompleted(AsyncOperationHandle`1) DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.8.3/Runtime/ResourceManager/Util/DelegateList.cs:69) UnityEngine.ResourceManagement.ResourceManager:Update(Single) MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@1.8.3/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:19)
What am I missing here? Why does the key “coreXML” fail? Is there any way of seeing what keys Addressables is aware of at runtime?

I’ve also tried create an AssetReference and passing in “coreXML” as the key, then using the AssetReference to pass in as a key but I get the same issue: “coreXML” fails to be found as a key.

Any help would be super appreciated :slight_smile:

Is XmlDocument a system type? I don’t think Unity supports that. So I think what you want to do is Addressables.LoadAssetAsync<TextAsset> then parse the textAsset.text.

1 Like

This was absolutely it. THANK YOU ProtoTerminator. Appreciate you taking the time to help.