Mahobo Mahobo - 3 years ago 225
C# Question

Solved: Error CS1674 trying to open second form

I'm sure, this is a total newbie question, but I'm hanging for hours now...

My main form should have a method that opens a second form with a textbox. Just to have a kind of messagebox with scrollbar. I know there are lots of examples out there, but they are all too extensive for my needs. So here is my code so far:

private void ShowBox (string info)
if (info != "")
using (var form = new Message())
// work to do

public partial class Message : Form
public Message()
say.Text = "OK";

Message is my 2nd form. I receive CS1674 (type used in a using statement must be implicitly convertible to 'System.IDisposable') error on the using line.
I already took this as reference Opening and closing form2 from form1 C# but I don't see the difference to my code.
What am I doing wrong?

I called my 2nd form Message, what is identical with a structure in
. Renaming Message solved the problem. Thanks for that hint.

Answer Source

Message probably resolves as System.Windows.Forms.Message which is a structure.

Ctrl+Click on your usage of new Message() will jump to the declaration.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download