Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Design Time Error, problems reading file

Design Time Error, problems reading file

Scheduled Pinned Locked Moved C#
helpvisual-studiocsharpwinformsdesign
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Patricker
    wrote on last edited by
    #1

    I have a UserControl. When I instantiate it the UserControl reads in an image that it uses, it draws it underneath the cursor. If I programmatically add the UserControl to a form and then run the program it works perfect. However if I try to do this via design time support I get an error screen instead of a design time screen, the error is: "One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes." The reason for the error is that it can't find my image file, because instead of looking for it in my programs folder it looks for it in the Visual Studio IDE Folder. "Could not find file 'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\images\tileselect.png'. " Is the exact error I get. My original idea was to just remove design time rendering of the control, since it works just fine when I run it, but I couldn't figure out how to make it so that a control is not rendered when you use it in design time. Though design-time support is preferred. Any help on this would be great. I am actually using a combination XNA/Windows Forms but from what I can tell that should have no bearing on the issue. Source Code At Problem: tileSelect = Texture2D.FromFile(GraphicsDevice, "images/tileselect.png"); If I remove this line, and the line that draws the sprite, it will work fine in Design time, it even calls the On_Paint event and runs the XNA code to clear the screen, not shown. Is there maybe some way I could rewrite my path so that it would look in my programs directory... No idea, thats why I posted here :) Thanks in advance. --Peter

    L 1 Reply Last reply
    0
    • P Patricker

      I have a UserControl. When I instantiate it the UserControl reads in an image that it uses, it draws it underneath the cursor. If I programmatically add the UserControl to a form and then run the program it works perfect. However if I try to do this via design time support I get an error screen instead of a design time screen, the error is: "One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes." The reason for the error is that it can't find my image file, because instead of looking for it in my programs folder it looks for it in the Visual Studio IDE Folder. "Could not find file 'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\images\tileselect.png'. " Is the exact error I get. My original idea was to just remove design time rendering of the control, since it works just fine when I run it, but I couldn't figure out how to make it so that a control is not rendered when you use it in design time. Though design-time support is preferred. Any help on this would be great. I am actually using a combination XNA/Windows Forms but from what I can tell that should have no bearing on the issue. Source Code At Problem: tileSelect = Texture2D.FromFile(GraphicsDevice, "images/tileselect.png"); If I remove this line, and the line that draws the sprite, it will work fine in Design time, it even calls the On_Paint event and runs the XNA code to clear the screen, not shown. Is there maybe some way I could rewrite my path so that it would look in my programs directory... No idea, thats why I posted here :) Thanks in advance. --Peter

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, you can use Component.DesignMode to have another file path (or no file loading) while in design mode... :)

      Luc Pattyn [My Articles]

      P 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, you can use Component.DesignMode to have another file path (or no file loading) while in design mode... :)

        Luc Pattyn [My Articles]

        P Offline
        P Offline
        Patricker
        wrote on last edited by
        #3

        Worked Great, thanks. --Peter

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups