cool hit counter Using MessageBox in the class library_Intefrankly

Using MessageBox in the class library

Copyright: This is an original post by the blogger and may not be reproduced without the blogger's permission.


Net version), there is an exception catch in the SqlHelper class of the D layer, and after catching the exception, I want to pop up the exception description using MessageBox. It may be inaccessible due to its level of protection. "Error.

Check the help, MSDN gives the following explanation. statement references a programming element, but the compiler cannot find an element with that exact name


The compiler does not recognize it, but MessageBox is available in the form application, and MessageBox.Show() is a common library function in .Net, so the reason may be that the form application project implicitly references one of the function library assemblies that contains MessageBox.Show(), and the class library project does not reference that assembly.


After looking at the references in the UI layer based on the judgement, it is true that there are so many more references than in the D layer, and after some experimentation, I got the conclusion that if you use the MessageBox() method in the D layer (which is just a representative of a project of the class library type), you need to refer to the namespace System.Windows.Forms. This is done as follows (I'm using VIsualStudio 2013, other versions shouldn't be too different)

1、 right click Windows.Forms project → Add → Reference

2, select the program set under the "framework", in front of the System.

3. Reference System.Windows.Forms in the file header of the class.

Imports System.Windows.Forms

Tips: Actually, we all know that you can also use Msgbox directly, but what is the difference between the two? Then ask the doozies.

1、Ive been using hotswapping for a long time to know what the principle is inside
2、Celebrity fans playing blockchain too TFBOYS fans launch TFBC
3、Traveling frog small snail delivery letter can not receive This approach is recommended
4、Is it reliable Dubai launches 50 selfdriving taxis
5、Is the market turning Its not time for mindless coin holding

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送