Design Time Error, problems reading file
-
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
-
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
Hi, you can use Component.DesignMode to have another file path (or no file loading) while in design mode... :)
Luc Pattyn [My Articles]
-
Hi, you can use Component.DesignMode to have another file path (or no file loading) while in design mode... :)
Luc Pattyn [My Articles]