Results 1 to 5 of 5

Thread: System.io.filenotfoundexception

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Location
    chennai
    Posts
    90

    System.io.filenotfoundexception

    Code
    Module Module1
    Sub Main(ByVal CmdArgs() As String)

    Dim ArgNum As Integer
    For ArgNum = 0 To UBound(CmdArgs)
    Console.WriteLine("Argument " & ArgNum.ToString() & ": " & CmdArgs(ArgNum).ToString())
    Next ArgNum
    End Sub
    End Module

    This is the err i got when i tried to run a console application in vb.net with the above code

    An unhandled exception of type 'System.io.filenotfoundexception' occured in unknown module

    Pls help me..
    akalya

  2. #2
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872
    did you declare "console"? which kind of object is this?

    You try to writeline to "console" when console isn't declared or iitialised you'd get this kind of error.
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Location
    chennai
    Posts
    90
    I am using a console application only. the problem is with the statement

    Function Main(ByVal CmdArgs() As String) As Integer

    where it displays the err...

    No accessible, parameterless 'Sub main()' was found in the application.. this is the exact err.. when i bypass and run, it raises the exception 'filenotfound'.. pls give me a soln..
    akalya

  4. #4
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872
    your project doesn't find a startup object. You need to have a startup-form or a sub main (in a module). a function main doesn't work. If you wrote your sub main, change the startup proprty of your project (do not know where to find it, cause i do not have VB.NET installed on the computer that i'm working on)
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    In a console application you should have a Sub New (This is a requirement) that is not taking any arguments as the main procedure. Then call the procedure to get your arguments.

    Code:
    Module Module1 
        Sub Main()
            MySub(MyArray)
        End sub
        Sub MySub(ByVal CmdArgs() As String) 
            Dim ArgNum As Integer 
            For ArgNum = 0 To UBound(CmdArgs) 
                Console.WriteLine("Argument " & ArgNum.ToString() & ": " & CmdArgs(ArgNum).ToString()) 
            Next ArgNum 
        End Sub 
    End Module

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