0

In Visual Studio Express 2013, I'm making a custom control called "AddressVerifier", which has a custom button called "CustomButton". Every time I modify the form, even just moving a label, it modifies the AddressVerifier.Designer.vb file, which creates a compile error as shown. If I select either of the first two fixes, it compiles fine and all is well until I modify the form again, then it removes the fix for the next compile.

I'm virtually CERTAIN this is a bug, but is there a workaround?

enter image description here

PaulOTron2000
  • 1,115
  • 1
  • 13
  • 20
  • 1
    Don't post images of your code. That makes it harder on us to help you, meaning you're less likely to get a good answer. – Joel Coehoorn Oct 11 '17 at 21:06
  • Every time you make changes to the form, the entire designer file is written out again (the post says it is the AddressVerifier designer, but that looks more like a form *using* the control). The lost reference is likely due to how the `CustomButton` project is included and/or the namespace – Ňɏssa Pøngjǣrdenlarp Oct 11 '17 at 21:06
  • Joel, I posted an image of code WITH offered fixes. That's why only an image would do. Plutonix, what's odd to me is that when I select either offered fix, it works, but it adds the problem back when I modify the form. The problem seems to be the forms designer keeps modifying code to create a compile error. AddressVerifier is a form to be used as a custom control, but it contains CustomButton. So essentially it's a custom control in a custom control. – PaulOTron2000 Oct 11 '17 at 21:10
  • The first option (change to Global...) seems to indicate the 2 things reside in different namespaces – Ňɏssa Pøngjǣrdenlarp Oct 11 '17 at 21:20

1 Answers1

1

This may be due to a name clash. It appears that you may have a type and a namespace both called AddressVerifier. The IDE is using the name of the namespace in the code but then the compiler is interpreting it as the type. The solution is to not use the same name for two things in the same context.

EDIT: The suggestion to add the Global qualifier is to force the compiler to interpret the name as the namespace rather than the type. It reverts when the design code file is regenerated because the IDE doesn't scan every possible type and namespace for name clashes, but rather just assumes that you have named things such that they won't happen. It could be considered a limitation but not a bug in the IDE.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
  • That was totally it. My namespace and class were both the same. Changed the class name to AddressVerifyClass and boom, all gone. I bet my failure to see this seems pretty lame but here's a confession: I may be the most "faking my way through .NET" programmer you'll ever encounter. I was a VB6 programmer years ago (And I was pretty good) but changed careers before .net and now I do pretty much everything by example, just making software for my own business. – PaulOTron2000 Oct 11 '17 at 23:47
  • I think the best way to avoid this type of issue is to always name your projects, and thus your root namespaces, with a "business name". For instance, if I was creating a project called AddressVerifier then the actual project name and root namespace would be `Wunnell.AddressVerifier`. I'd still recommend avoiding using the same name for two different things in the same context though. I'd also suggest putting some more thought into your names here and coming up with two different names that are maximally descriptive because `AddressVerifyClass` is rather dodgy. – jmcilhinney Oct 11 '17 at 23:57