@@ -505,15 +505,23 @@ public bool SetStringList(
505505 SettingsScope scope = SettingsScope . SettingsAutoScope
506506 )
507507 {
508- return NativeMethods . BNSettingsSetStringList (
509- this . handle ,
510- null == view ? IntPtr . Zero : view . DangerousGetHandle ( ) ,
511- null == function ? IntPtr . Zero : function . DangerousGetHandle ( ) ,
512- scope ,
513- key ,
514- value ,
515- ( ulong ) value . Length
516- ) ;
508+ // BN expects the value list as a UTF-8 char** block. .NET cannot marshal a
509+ // string[] element as UTF-8 via [MarshalAs], so build the block by hand; the
510+ // core copies it, so freeing after the call (allocator dispose) is safe.
511+ using ( ScopedAllocator allocator = new ScopedAllocator ( ) )
512+ {
513+ IntPtr valueBlock = allocator . AllocUtf8StringArray ( value ) ;
514+
515+ return NativeMethods . BNSettingsSetStringList (
516+ this . handle ,
517+ null == view ? IntPtr . Zero : view . DangerousGetHandle ( ) ,
518+ null == function ? IntPtr . Zero : function . DangerousGetHandle ( ) ,
519+ scope ,
520+ key ,
521+ valueBlock ,
522+ ( ulong ) value . Length
523+ ) ;
524+ }
517525 }
518526
519527 public bool SetJson (
@@ -619,9 +627,16 @@ public bool UpdateUInt64Property(string key , string property , ulong value)
619627 /// </summary>
620628 public bool UpdateStringListProperty ( string key , string property , string [ ] value )
621629 {
622- return NativeMethods . BNSettingsUpdateStringListProperty (
623- this . handle , key , property , value , ( ulong ) value . Length
624- ) ;
630+ // Build the value list as a UTF-8 char** block (string[] cannot be UTF-8
631+ // marshaled by attribute); the core copies it, so free after the call.
632+ using ( ScopedAllocator allocator = new ScopedAllocator ( ) )
633+ {
634+ IntPtr valueBlock = allocator . AllocUtf8StringArray ( value ) ;
635+
636+ return NativeMethods . BNSettingsUpdateStringListProperty (
637+ this . handle , key , property , valueBlock , ( ulong ) value . Length
638+ ) ;
639+ }
625640 }
626641
627642 /// <summary>
0 commit comments