异常加载C#StringCollection设置

时间:2012-05-20 02:10:37

标签: c#

在C#应用中,客户端出现以下错误

The property 'PlayLists' could not be created from it's default value. Error message: Could not load file or assembly '0 bytes loaded from System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. An attempt was made to load a program with an incorrect format.

PlayLists是StringCollection类型的设置

“设置”中的默认值为

<?xml version="1.0" encoding="utf-16"?>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <string>test</string>
</ArrayOfString>

我得到的堆栈跟踪是

  at System.Configuration.SettingsPropertyValue.Deserialize()
  at System.Configuration.SettingsPropertyValue.get_PropertyValue()
  at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName)
  at System.Configuration.SettingsBase.get_Item(String propertyName)
  at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName)
  at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName)
  at Sync.Properties.Settings.get_PlayLists() 
  at Sync.FormMain.selectLastSycLists()
  at Sync.FormMain..ctor()
  at Sync.Program.Main() 

我的代码中启动所有这些的方法看起来像这样。

    private void selectLastSycLists()
    {
        // Accessing PlayLists caused it
        foreach(String settingsPList in Properties.Settings.Default.PlayLists)
        {               
         ...
        }
    }

我不太确定是什么导致这种情况, 任何建议都会很棒

0 个答案:

没有答案