Subject: about automatic execute code in design time

G

Guest

Hi,
I'm new to vb.net.
How to prevent vb.net to automatic execute code in design time?

When I open a form design view in VS2005, vs pop up an error message: "Could
not load file or assembly "xxx" or one of its dependencies....". But there's
no build error, and can run normally.The renferenced assembly(not strongly
named) do exist, but not in GAC.

I wonder there's any way to disable the error check when I open the form?
And why the result can run, but VS2005 throw error in design time.

Thanks a lot.
 
T

Tom Shelton

Hi,
I'm new to vb.net.
How to prevent vb.net to automatic execute code in design time?

When I open a form design view in VS2005, vs pop up an error message: "Could
not load file or assembly "xxx" or one of its dependencies....". But there's
no build error, and can run normally.The renferenced assembly(not strongly
named) do exist, but not in GAC.

I wonder there's any way to disable the error check when I open the form?
And why the result can run, but VS2005 throw error in design time.

Thanks a lot.

You can't do it in the constructor - but, if you move this
initialization stuff to form_load, then you can test for design mode
before you attempt to access those resources:

Public Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles Form1.Load
If Not Me.DesignMode Then
' Access Your Resources
End If
End Sub
 
G

Guest

Thanks for you answer.

I'm sorry I did say clearly.
I do initialization in form_load. But the form contains several user
control, and it seems that the control_load would be execute
automaticly(called by InitializeComponent()). How to prevent this? Remove
auto generated code in InitializeComponent() related to user controls?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top