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

371 Kommentare

  • Kommentar-Link Etjcdomma %AM, %19. %465 %2023 %10:%Jul gepostet von Etjcdomma

    buy azithromycin https://azithromycinikm.com/ azithromycin and adderall

  • Kommentar-Link HbgdHoarl %AM, %19. %349 %2023 %07:%Jul gepostet von HbgdHoarl

    can i take ibuprofen and cephalexin together https://cephalexinuop.com/ whats cephalexin used for

  • Kommentar-Link OvrcDeene %AM, %18. %103 %2023 %01:%Jul gepostet von OvrcDeene

    can a child take prednisone and benadryl together can you take tums with prednisone can prednisone give you a headache

  • Kommentar-Link OvrcDeene %AM, %18. %100 %2023 %01:%Jul gepostet von OvrcDeene

    can a child take prednisone and benadryl together can you take tums with prednisone can prednisone give you a headache

  • Kommentar-Link Nnolovaps %AM, %15. %142 %2023 %02:%Jul gepostet von Nnolovaps

    doxycycline mono 100mg for chlamydia throwing up from doxycycline can you drink alcohol on doxycycline

  • Kommentar-Link Egmbbiowl %PM, %14. %008 %2023 %23:%Jul gepostet von Egmbbiowl

    cipro and augmentin how to treat augmentin side effects augmentin duo strep throat

  • Kommentar-Link NtvbBaill %AM, %14. %111 %2023 %01:%Jul gepostet von NtvbBaill

    fish flox forte ciprofloxacin ciprofloxacin opht ciprofloxacin i.v.dose

  • Kommentar-Link Etjcdomma %AM, %14. %090 %2023 %01:%Jul gepostet von Etjcdomma

    doxycycline vs azithromycin for pneumonia azithromycin 500 mg dose azithromycin with prednisone

  • Kommentar-Link Etjcdomma %AM, %14. %088 %2023 %01:%Jul gepostet von Etjcdomma

    doxycycline vs azithromycin for pneumonia azithromycin 500 mg dose azithromycin with prednisone

  • Kommentar-Link HbgdHoarl %PM, %13. %973 %2023 %22:%Jul gepostet von HbgdHoarl

    is cephalexin good for uti para q sirve cephalexin 500 ?que es la cephalexin 500 mg y para que sirve

Schreibe einen Kommentar

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