Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ionite34 opened this issue Jul 20, 2024 · 0 comments · May be fixed by #1959

Comments

@ionite34
Copy link

ionite34 commented Jul 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant