2

In a project I'm working on, I've moved all the winforms' resource files (with strings only) to a resource dll, which also has a static class that loads all the resource file strings to memory at project start, and each form gets its strings from it.

I have one winform with a couple of user controls, that also access that dll for their strings. When I try to open that form in design view I get the following error for each user control:

"The variable 'control_name' is either undeclared or was never assigned"

I can still run the project without any problem.

I've tried to call the dll from both the user controls' constructors and Load events but neither of the cases worked.

Dor Cohen
  • 16,769
  • 23
  • 93
  • 161
Guy
  • 325
  • 1
  • 3
  • 18

2 Answers2

2

As I've mentioned in an earlier comment, I managed to solve the problem. Instead of accessing the resource dll from within the usercontrol, I changed each of the controls' functions to public and called those functions from the winform

Guy
  • 325
  • 1
  • 3
  • 18
0

First try the easy solution:
do Build->Rebuild Solution. Close Visual Studio, re-open. It can happen if the user control threw an exception during design time construction. It only cleared up after Visual Studio restart. (Visual Studio 2008 w/SP1)

If this fails so you probably has a reference to a variable, such as Button1, that was never declared or assigned. If it was not assigned, you will get a warning, not an error.

To correct this error: Declare or assign the variable specified in the error message.

http://msdn.microsoft.com/en-us/library/4008y84t.aspx

Dor Cohen
  • 16,769
  • 23
  • 93
  • 161
  • I've build and rebuild the solution for god knowns how many times but to no avail. When I remark the dll function calls in the user controls I do manage to open the winform in design view. Could this have anything to do with the class being static? – Guy Apr 16 '12 at 08:34
  • @Guy Can you attach the user control? – Dor Cohen Apr 16 '12 at 08:36
  • Problem solved. The functions that access the resource dll are now called from the winform instead from within the usercontrols. – Guy Apr 16 '12 at 09:10