p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Visual Basic 2010 Programmer's Reference (http://p2p.wrox.com/forumdisplay.php?f=551)
-   -   User Control Constant Error Correction (http://p2p.wrox.com/showthread.php?t=86433)

Idontnodou January 23rd, 2012 10:42 PM

User Control Constant Error Correction
 
Anyone:

I have a project that I am designing a User Control to use within. I started a Windows Forms Project, then I am laying out the User Control in-project. I don't want to compile the user control as a DLL, I want to keep it as a part of my final form project.

The problem I have is: Every time I run the project, an Exception Error pops up which says "Type 'ApplicationName.ControlOnFormName' is not defined. If I select the top suggestion... It changes the Form Designer code as follows:


Me.ControlOnFormName = New ProjectName.UserControlName()

Me.ControlOnFormName = New Global.ProjectName.UserControlName()


Now... The application will run fine, over and over, until I close the Form Designer. The Form Designer, upon closing, sets the code back to the top line. (No Global)

(Which is the never-ending loop: I correct - It runs fine - I close the Designer - It errors...) Now... The .exe file always runs if I build after the correction... : : stumped : :

Why does this happen??? And... is there a better way to keep a User Control within the project without having to reference a dll????

Ken C
Madison WI

Rod Stephens January 24th, 2012 10:31 AM

Pretty weird. What is the name of the control class? All I can think of right now is that it might be a reserved word. It adds Global to differentiate it from something else but then the designer isn't smart enough to preserve that change (which seems likely because it's an error correction change).

If that's what's happening, you should be able to get around it by changing the name of the class.

Idontnodou January 24th, 2012 09:31 PM

Rod:

I appreciate your reply... I am at odds with this problem, as it is the third project that this error has occurred where I attempt to include a User Control. It has to be something I do as a habit that is 'BAD'.

(Background: I am just now switching from Classic VB to .NET... I am 49 years young - and hate the fact that yet another thing in my life is being called 'Classic'. Feeling old...)

I realize you are busy... I stripped down the project to a bare minimum and removed the unnecessary files. It is the start of s simple label printing project I am using to learn the ways of .NET....

I uploaded it temporarily to this location.

http://www.aloftware.com/UserCtlError.zip

I would really like an answer to this... It is driving me nuts!

Thanks in advance, if you can look in to it,

Ken

Idontnodou January 24th, 2012 10:08 PM

note.... If you ignore the error upon opening the form (Click to ignore), you can then then see the issue by: switching to the form design from anything else... The designer code automatically corrects, which makes the project not run until you use the suggested 'fix' to add the GLOBAL piece to the control 'Load NEW' line........ (If that makes any sense!!)


All times are GMT -4. The time now is 02:15 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.