Error:
Data room Charging System (VB. during the process, there is an exception capture processing in the sqlhelper class of the D Layer. if an exception is caught, you want to use MessageBox. the show () exception description is displayed, but "MessageBox not declared" is displayed during compilation ". It may be inaccessible due to its protection level ." Error:
View help. msdn explains that a statement references a programming element, but the compiler cannot find the element with the exact name.
Judgment:
The compiler cannot identify the problem, but MessageBox can be used in the form application, and MessageBox. show () is. net, so it may be because the project of the form application implicitly references a function library that contains MessageBox. show () assembly, and the class library project does not reference this assembly.
Solution:
According to the judgment, I checked the reference of the UI Layer and found that there were a lot more references than the reference of the D Layer. After trying, I got the conclusion: If the reference is in the D Layer (only representative of the Class Library Project) to use the MessageBox () method, you must reference the namespace system. windows. forms. The specific operation is as follows (I use visualstudio2013, and other versions should not be significantly different ):
1,Right-clickProject to reference system. Windows. Forms → add → reference
2. Select the "Framework" under the Assembly and check system. Windows. forms to confirm.
3. Reference System. Windows. Forms in the file header of the class:
Imports system. Windows. Forms