WebRequest Exception
-
Also ich muss zugeben ich bin nicht ganz so fit in NET, hatte mich die Jahre lieber an Cpp festgebissen.
Nun stehe ich vor einen ziemlich merkwürdigen Problem und ich bin mit dem Framework auf Kriegsfuß. Habe eine ConfigLoader Klasse gebaut ganz simpel über den ConfigurationManager also auf application level, die Funktioniert auch wunderbar aber leider führt jetzt jeder Aufruf von WebRequest zu einer Exception weil er wie ich vermute die connectionStrings benötigt und krampfhaft versucht sie über die application config zu finden stat über machine ebene.
Log Output:
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll 'NetWorkBurst.exe': Loaded 'C:\Windows\System32\version.dll', Cannot find or open the PDB file An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll Additional information: Configuration system failed to initialize
Callstack:
System.Configuration.dll!System.Configuration.ConfigurationManager.GetSection(string sectionName) + 0xa3 bytes System.dll!System.Configuration.PrivilegedConfigurationManager.GetSection(string sectionName) + 0x2b bytes System.dll!System.Net.Configuration.WebRequestModulesSectionInternal.GetSection() + 0x8b bytes System.dll!System.Net.WebRequest.PrefixList.get() + 0xa8 bytes System.dll!System.Net.WebRequest.Create(System.Uri requestUri, bool useUriBase) + 0x4f bytes > NetWorkBurst.exe!NetWorkBurst.Classes.NetworkLayer.RunAsynchRequest() Line 48 + 0x12 bytes C# NetWorkBurst.exe!NetWorkBurst.Forms.MainForm.btnStart_Click(object sender, System.EventArgs e) Line 65 + 0x12 bytes C#
-
So einen ähnlichen Fehler hatte wir bei uns auch vor kurzem, als unser Admin kurzerhand bei einem WebService
<connectionStrings> <add name="ConnectionString" connectionString="Data Source=..."/> </connectionStrings>
aus der 'web.config' gelöscht hat, weil er meinte der wird ja eh' nicht benutzt -)
Kannst du denn mal einen Dummy-Eintrag dafür in der app.config einfügen und schauen, was dann passiert?
-
ja hab ich probiert am Fehler ändert sich leider nichts
-
hab es hinbekommen, da war anscheinend ein Fehler in der config der sich ganz einfach lösen lies indem ich einfach NET die arbeit machen lies
übrigens stand sogar im _innerException hätte es nur lesen müssen.System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath) as Configuration; NetConfig customNetSection = new NetConfig(); GeneralConfig customGeneralSection = new GeneralConfig(); customNetSection.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToApplication; customGeneralSection.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToApplication; config.Sections.Add("NetConfig", customNetSection); config.Sections.Add("GeneralConfig", customGeneralSection); config.Save(saveMode, true);