I searched a while and found no solution or do I just not see the little error?
I wrote a program with Visual C# and have
Form1.cs
Program.cs
Server.cs
Server.cs
namespace WindowsApplication1 {
class testServer {
public Form1 form1;
form1.send("data");
Program.cs
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace WindowsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Form1.cs
namespace WindowsApplication1
{
public partial class Form1 : System.Windows.Forms.Form
{
public Form1()
{
InitializeComponent();
}
private testServer Server;
private void startServer_Click(object sender, System.EventArgs e)
{
Server = new Server(data);
Server.form1 = this;
}
Everything works but in Server.cs I get a nullexception with form1.send("data");
It seems form1 is really null but why?
Where did I forget something?
You have to create an instance of Form1, try