3 Replies - 188 Views - Last Post: 25 May 2017 - 11:46 AM

private: System::Void.ctor() Keeps Adding Itself (what does it do?)

Posted 24 May 2017 - 03:25 PM

Hey all!
I've run into a very very very annoying and strange problem here in Visual Studio 2015:

this bit of code keeps adding itself to my project, I have had it added into my printer.h file several times now and I can't figure out how to get rid of it without throwing more compiler errors. If I simply comment it out I get an error saying that something is missing (don't have the exact message but I can get it if this comes back again). I tried googling it, and couldn't find anyone who could give me a good answer about what to do to get rid of it.

private: System::Void.ctor()
{
this->InitializeComponent();
}

I keep having to delete my entire .h and .cpp files because of it and I'm starting to get flustered.

Everytime this gets added I'm being told that "." isn't the right syntax... but I don't understand how it can be the wrong syntax, since it's the compiler that keeps adding it in?!?!

This a triple self-inflicted problem. Problem 1: Using C++/CLI. Problem 2: Using WinForms with C++/CLI. Problem 3: Using the WinForm Designer which is known to be buggy, specially if you try to inherit from anything other than Form or UserControl.

I'm not sure, but it almost sounds like you are editing the compiler generated files. The same ones that has a comment at the top that says you should not edit them because they can be regenerated.