• Webseitenerstellung und -hosting
  • .NET Anwendungsentwicklung
  • softwaregesteuerte Prozessoptimierung
  • .NET

    Programmierung

  • WebseitenErstellung

    undHosting

  • softwaregesteuerte

    Prozessoptimierung

  • Konzeption

    und Beratung

%PM, %23. %690 %2012 %15:%Nov

WPF Anwendungspfad ermitteln

geschrieben von
Artikel bewerten
(0 Stimmen)
Eine globale Settings.xml datei (wie früher) für eine WPF Anwendung global bereitstellen. In dieser wird der Connectionstring zur Datenbank für alle beteiligten Assemblies bereitgestellt. Die Ablage in den App/Web.Config kommt aus diversen Gründen nicht in Frage da die Konfig...
- zur Laufzeit nicht verändert werden kann (Anwendungseinstellungen)
- beim compilieren überschrieben wird
- bei WPF die Config lokal zwischengespeichert wird
also die Datei einmalig erstellen und in der Assembly einfach den Anwedungspfad auslesen.
so etwa?
AppDomain.CurrentDomain.BaseDirectory System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) System.Reflection.Assembly.GetExecutingAssembly().Location Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) System.Reflection.Assembly.GetExecutingAssembly().CodeBase System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess(). MainModule.FileName
leider kriegt man hier nur die lokalen temporären Pfade der Assemblies!
Mit Updatelocation kriegt man den Urpsrungspfad:
System.Deployment.Application.ApplicationDeployment.
CurrentDeployment.UpdateLocation.ToString
Leider scheint Micrsosoft auch Auszubildende auf die Menschheit loszulassen, anders kann ich mir den Rückgabestring nicht zu erklären:
http:\wpfserver\apppath
also häng ich noch folgendes ran:
.Replace("\", "/").Replace("http:/", "http://")
und damit wird dann per linq to xml der Eintrag gelesen
Dim uriXML As Uri = New Uri(strdir & "/Settings.xml")
 Dim konf As XDocument = XDocument.Load(uriXML.ToString)
Connectionsstring = (From ef In konf.Descendants("EF_Connectionstring")).FirstOrDefault.Value 
:
Gelesen 41950 mal Letzte Änderung am %PM, %24. %643 %2015 %14:%Jun

371 Kommentare

  • Kommentar-Link microgaming %PM, %04. %958 %2023 %22:%Aug gepostet von microgaming

    It's really a great and helpful piece of info. I'm satisfied that
    you shared this helpful info with us. Please stay us up to date like
    this. Thank you for sharing.

  • Kommentar-Link Egmbbiowl %AM, %03. %174 %2023 %03:%Aug gepostet von Egmbbiowl

    augmentin 875 patient comments augmentin 875-125 side effects is augmentin ok for dogs

  • Kommentar-Link Etjcdomma %AM, %02. %280 %2023 %05:%Aug gepostet von Etjcdomma

    amoxicillin and azithromycin together azithromycin after expiration date can i take mucinex dm with azithromycin

  • Kommentar-Link HbgdHoarl %AM, %02. %163 %2023 %02:%Aug gepostet von HbgdHoarl

    cephalexin urinary tract infection does cephalexin increase blood sugar is cephalexin good for sinus infection

  • Kommentar-Link NtvbBaill %PM, %01. %945 %2023 %21:%Aug gepostet von NtvbBaill

    can i take atorvastatin with ciprofloxacin ciprofloxacin treat strep throat trade name for ciprofloxacin

  • Kommentar-Link OvrcDeene %PM, %31. %957 %2023 %21:%Jul gepostet von OvrcDeene

    prednisone and covid treatment 2022 does prednisone cause gas prednisone and drinking

  • Kommentar-Link Nnolovaps %AM, %31. %218 %2023 %04:%Jul gepostet von Nnolovaps

    will doxycycline treat bronchitis can you take omeprazole with doxycycline does doxycycline give you diarrhea

  • Kommentar-Link Egmbbiowl %AM, %31. %092 %2023 %01:%Jul gepostet von Egmbbiowl

    augmentin increased appetite augmentin prospect 7-12 ani augmentin da 1 gr prezzo

  • Kommentar-Link Etjcdomma %AM, %30. %221 %2023 %04:%Jul gepostet von Etjcdomma

    azithromycin have penicillin https://azithromycinikm.com/ azithromycin 250 mg price walmart

  • Kommentar-Link Etjcdomma %AM, %30. %220 %2023 %04:%Jul gepostet von Etjcdomma

    azithromycin have penicillin https://azithromycinikm.com/ azithromycin 250 mg price walmart

Schreibe einen Kommentar

Bitte achten Sie darauf, alle Felder mit Stern * zu füllen. HTML-Code ist nicht erlaubt.