locked
strange form behavior RRS feed

  • Question

  • My program works correctly in the IDE and from the published directory, but not if I move it to Documents in my folder.

    The program seems to run correctly in all aspects, but will not display the main form from any other location it's run from.

    What's going on here?

    I can attach all my code if you want, but i am looking for answers to where to start to search for this problem. Can you help?


    Paul Abell

    Tuesday, July 14, 2020 1:03 PM

All replies

  • Usually when a app works in the bin\debug folder and not when copied to another folder there is a hard coded path in the code or another reason, an exception is thrown (and this may not be in your case) from code in form load event, never use form load, use form shown event instead.

    • Check for hard coded paths
    • Move form load code to form shown code and optionally wrap code in a try/catch with a message box or log the exception to a log file.

    Example in regards to not hard coding paths, this will always point to the executable folder.

    Dim fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SomeFile.txt")


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, July 14, 2020 2:25 PM
  • Hi

    Are you talking about moving the entire project folder?


    Regards Les, Livingston, Scotland

    Tuesday, July 14, 2020 2:48 PM
  • Hi pgabell,

    How is the question going?

    >>but not if I move it to Documents in my folder.

    Please provide more details or some related code about the sentence.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 17, 2020 7:33 AM