I realize this solution is probably considered crude, but when nothing else
works, including the use of a separate thread, it can be useful.
At the end of the Constructor, start a timer, with the increment setting at
200 (you can probably shorten that if this works for you) . In the tick
event of the timer, Stop the timer on the first line of code. Then test
whether the code is processing in design time with me.designtime. If not,
the code is processing in runtime, you can get the file and process it in the
timer event handler.
Note: You can add a messagebox while you're testing this to show that the
code after "If me.designmode = false then" is not running in design time. As
another poster on this thread pointed out me.designmode is always false in
the Constructor. In the timer, however, it is set according to the current
mode.
www.charlesfarriersoftware.com
"Z D" wrote:
Hello,
I've created a winform user control that, at some point in the default
constructor, looks for a specifc file.
When I try to load the user control to my winform's form during design time
it gives an error saying that the file doesn't exist.
Obviously the file doesnt exist yet because its only created at runtime!!
So, why is the design-time environment (VS.NET 2003) trying to compile my
app when I load the user control onto the winform?
Anyways - if I comment out references to this file in the control then I can
add it with no problems to the winform.
My question is: How do I disable this functionality so that Visual Studio
doesnt try to "be too smart" during design time?
Thanks!
-ZD