Ich versuche, einen .otf
Pfad von appSettings
zu erreichen, aber es gibt null
zurück. Der Pfad funktioniert, wenn ich ihn statisch verwende.Lesen von OTF-Pfad von Konfigurationsdatei
Config File:
<add key="MetropolisBold" value="MetropolisBold.otf"/>
Code:
Dim metropolisBold As String = ConfigurationManager.AppSettings("MetropolisBold")
chart.ChartAreas(0).AxisX.LabelStyle.Font = SetFontFamily(metropolisBold)
Private Function SetFontFamily(ByVal fontFamily As String) As Font
Dim privateFonts As New Text.PrivateFontCollection()
privateFonts.AddFontFile(fontFamily)
Dim font = New Font(privateFonts.Families(0), 24, FontStyle.Regular)
Return font
End Function
Irgendwelche Tipps, warum es nicht funktioniert oder was soll ich tun?
Update:
Mein Code hat funktioniert, aber ich habe vergessen, die Werte in der rechten app.config
zu setzen. Sorry für meinen Anfängerfehler und ich schätze alle Bemühungen.
Was null zurückgibt? Der Aufruf von AppSettings oder der Aufruf von New Font? – ADyson
Die Einstellung enthält einen Dateinamen, aber 'SetFontFamily' erwartet einen Schriftartnamen. –
Die AppSettings gibt null @ADyson zurück – Kasra