Greetings,
When I try to run this code i get most time a exception in the part
Catch exc As Exception
It is a IOException
The Process can not access the file D:\views\pledlm_view\applications\ktr\source\KTR Client\KTR Client\bin\Release\KTR Client.exe.config because another process is using it.
Background:
1. The app = not MutliThreating
2. I use the routine to add a new value in to the App.config
For easier understanding i posted the whole class as zip to the thread
VB Code:
Private Function LoadConfigSource() As String Dim dllPath As String = System.Reflection.Assembly.GetExecutingAssembly.Location Dim filename As String #If DEBUG Then '--> if debug app.config file is not in bin folder Dim strTemp As String = Path.GetDirectoryName(dllPath) strTemp = strTemp.Substring(1, strTemp.Length - 1) strTemp = strTemp.Substring(1, strTemp.LastIndexOf("\bin\")) filename = strTemp & "app.config" #Else '--> get the name of the calling assembly (in the testcase TestConfigProvider) and built the path of the config file in release mode filename = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location) & "\" & System.Reflection.Assembly.GetEntryAssembly.GetName.Name.ToString & ".exe.config" #End If configSource = New XmlDocument Dim cstream As Stream Try cstream = File.OpenRead(filename) configSource.Load(cstream) Catch ex As FileNotFoundException Throw ex Catch exc As Exception Throw exc Finally If Not cstream Is Nothing Then cstream.Close() End Try Return filename End Function
Thanks for any help




Reply With Quote