• 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 42554 mal Letzte Änderung am %PM, %24. %643 %2015 %14:%Jun

371 Kommentare

  • Kommentar-Link NrtgBaill %AM, %08. %310 %2023 %06:%Jul gepostet von NrtgBaill

    prednisone and blood pressure can you take prednisone with tylenol how fast does prednisone work

  • Kommentar-Link OfvdDeene %AM, %07. %053 %2023 %00:%Jul gepostet von OfvdDeene

    si puo prendere augmentin gravidanza augmentin iv dosage augmentin 2-6 ani administrare

  • Kommentar-Link Nbtdovaps %AM, %06. %378 %2023 %08:%Jul gepostet von Nbtdovaps

    azithromycin drug class azithromycin urethritis can i buy azithromycin

  • Kommentar-Link Enelbiowl %AM, %06. %273 %2023 %05:%Jul gepostet von Enelbiowl

    ciprofloxacin and levofloxacin https://ciprofloxacinvol.com/ ciprofloxacin another name

  • Kommentar-Link NkriBaill %AM, %05. %462 %2023 %10:%Jul gepostet von NkriBaill

    azithromycin antibiotic azithromycin sun exposure azithromycin strep throat

  • Kommentar-Link Evfxdomma %AM, %05. %397 %2023 %08:%Jul gepostet von Evfxdomma

    can cephalexin cause c diff https://doxycyclineoyg.com/ can you take cephalexin if allergic to penicillin

  • Kommentar-Link HbtxHoarl %AM, %05. %295 %2023 %06:%Jul gepostet von HbtxHoarl

    cipro and cephalexin keflex generic cephalexin can cephalexin be taken with ibuprofen

  • Kommentar-Link OjefDeene %AM, %04. %179 %2023 %03:%Jul gepostet von OjefDeene

    ciprofloxacin for uti how fast does it work ciprofloxacin naproxen sodium drug interactions ciprofloxacin in elderly

  • Kommentar-Link Nsmhovaps %AM, %03. %249 %2023 %04:%Jul gepostet von Nsmhovaps

    amoxicillin 500 mg para que sirve can you take dayquil with amoxicillin has anyone taken amoxicillin during pregnancy

  • Kommentar-Link Emflbiowl %AM, %03. %113 %2023 %01:%Jul gepostet von Emflbiowl

    keflex if allergic to penicillin is e coli sensitive to keflex how long for keflex to work on uti

Schreibe einen Kommentar

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