Skip to content

Cannot convert an object of type #38

@danielcshn

Description

@danielcshn

Use this structure in other projects and I had no problems, now I have the following error:

My config.ini

[Game]
GameSelect=DE

My code:

Dim setLang As String
Dim ini As New IniFile()
ini.Load("config.ini")
setLang = ini.Sections("Game").Keys("GameSelect").Value

Last line error:

System.InvalidCastException: 'Cannot convert an object of type' System.Collections.Generic.List1 [MadMilkman.Ini.IniSection]' to type 'System.Collections.Generic.IEnumerable`1 [MadMilkman.Ini.IniItem] '.'

My code works with:

Dim setLang As String
Dim ini As New IniFile()
ini.Load("config.ini")
setLang = ini.Sections(0).Keys(0).Value

VisualStudio 2019 Version 16.11.0
.NET Frameworks 3.5
MadMilkman.Ini 1.0.6

Tests:
.NET Frameworks 2.0 > NO
.NET Frameworks 3.0 > NO
.NET Frameworks 3.5 > NO
.NET Frameworks 4 > OK
.NET Frameworks 4.5 > OK
.NET Frameworks 4.6 > OK
.NET Frameworks 4.7 > OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions