Results 1 to 3 of 3

Thread: [2005] Where is my problem

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395

    Question [2005] Where is my problem

    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:
    1. Private Function LoadConfigSource() As String
    2.  
    3.         Dim dllPath As String = System.Reflection.Assembly.GetExecutingAssembly.Location
    4.         Dim filename As String
    5.  
    6. #If DEBUG Then
    7.         '--> if debug app.config file is not in bin folder
    8.         Dim strTemp As String = Path.GetDirectoryName(dllPath)
    9.         strTemp = strTemp.Substring(1, strTemp.Length - 1)
    10.         strTemp = strTemp.Substring(1, strTemp.LastIndexOf("\bin\"))
    11.         filename = strTemp & "app.config"
    12. #Else
    13.         '--> get the name of the calling assembly (in the testcase TestConfigProvider) and built the path of the config file in release mode
    14.         filename = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location) & "\" & System.Reflection.Assembly.GetEntryAssembly.GetName.Name.ToString & ".exe.config"
    15. #End If
    16.         configSource = New XmlDocument
    17.  
    18.         Dim cstream As Stream
    19.  
    20.         Try
    21.             cstream = File.OpenRead(filename)
    22.             configSource.Load(cstream)
    23.  
    24.         Catch ex As FileNotFoundException
    25.             Throw ex
    26.         Catch exc As Exception
    27.             Throw exc
    28.         Finally
    29.             If Not cstream Is Nothing Then cstream.Close()
    30.         End Try
    31.  
    32.         Return filename
    33.  
    34.     End Function

    Thanks for any help
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width