Skip to content

IPluginInterface.GetPluginConfig causes FileReadException when the last saved config type was not defined by the calling assembly #1951

@ionite34

Description

@ionite34
19:02:36.641 | ERR | [WindowSystem] Error during Draw(): ConfigWindow
	Dalamud.Storage.FileReadException: Failed to read file
	 ---> Newtonsoft.Json.JsonSerializationException: Error resolving type specified in JSON 'SamplePlugin.Configuration, SamplePlugin'. Path '$type', line 2, position 53.
	 ---> System.IO.FileLoadException: Could not load file or assembly 'SamplePlugin, Culture=neutral, PublicKeyToken=null'. Operation is not supported. (0x80131515)
	File name: 'SamplePlugin, Culture=neutral, PublicKeyToken=null'
	 ---> System.NotSupportedException: Resolving to a collectible assembly is not supported.
	   at System.Reflection.RuntimeAssembly.<InternalLoad>g____PInvoke|49_0(NativeAssemblyNameParts* __pAssemblyNameParts_native, ObjectHandleOnStack __requestingAssembly_native, StackCrawlMarkHandle __stackMark_native, Int32 __throwOnFileNotFound_native, ObjectHandleOnStack __assemblyLoadContext_native, ObjectHandleOnStack __retAssembly_native)
	   at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound)
	   at System.Reflection.Assembly.LoadWithPartialName(String partialName)
	   at Newtonsoft.Json.Serialization.DefaultSerializationBinder.GetTypeFromTypeNameKey(StructMultiKey`2 typeNameKey)
	   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
	   at Newtonsoft.Json.Serialization.DefaultSerializationBinder.GetTypeByName(StructMultiKey`2 typeNameKey)
	   at Newtonsoft.Json.Serialization.DefaultSerializationBinder.BindToType(String assemblyName, String typeName)
	   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolveTypeName(JsonReader reader, Type& objectType, JsonContract& contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, String qualifiedTypeName)
	...

Since SavePluginConfig gets the type from the actual instance passed to it, can GetPluginConfig have an overload with generic type or Type argument? Since otherwise it seems impossible for library code to call GetPluginConfig on behalf of another assembly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions