The line: mdv = new MapDesignerView();creates an endless instantiation (infinite loop). See in code below:
public partial class MapDesignerView : Form
{
public MapDesignerView mdv;
public Map map;
public MapController mapController;
public MapConstructor mapConstructor;
MouseEventHandler detectMouse;
public MapDesignerView()
{
mdv = new MapDesignerView();
map = new Map(mdv);
mapController = new MapController(map);
mapConstructor = new MapConstructor(mapController);
detectMouse = new MouseEventHandler(mapController);
InitializeComponent();
}
}
As you can see I need to make an instance of the MapDesignerView class inside the mapDesignView class, to pass to another class constructor. How do I pass this form to the Map constructor in a different way so it is not endlessly instantiating?
It sounds like you're looking for this, which refers to the current instance.
If you really want to pass an instance of MapDesignerView to itself, you can do so by using a constructor with a contract like:
public MapDesignerView(MapDesignerView map)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With