icsharpcode / SharpDevelop

#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
2.08k stars 771 forks source link

Opening form with SharpGL's OpenGLControl on it in design view shows a Serialisation / Deserialisation error #702

Open ghost opened 9 years ago

ghost commented 9 years ago

I checked out a copy of the SharpGL git repo and tried opening the SimpleDrawingSample example project's form in the design view using SharpDevelop 5.1 build 5135

I get the following error on screen: Failed to load designer. Check the source code for syntax errors and check if all references are available.

ICSharpCode.FormsDesigner.FormsDesignerLoadException: System.ComponentModel.Design.Serialization.CodeDomSerializerException: Could not find type '?'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.

System.ComponentModel.Design.Serialization.CodeDomSerializerException: The variable 'openGLControl1' is either undeclared or was never assigned. at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)

at ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadDesigner() at ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadAndDisplayDesigner() at ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadInternal(OpenedFile file, Stream stream) at ICSharpCode.SharpDevelop.Workbench.AbstractViewContentHandlingLoadErrors.Load(OpenedFile file, Stream stream)

I've also report this as a bug on the sharpGL project page.

mrward commented 9 years ago

If you build the sample first then you can open the forms designer.

ghost commented 9 years ago

Okay, tried again after building the sample, this time I'm getting:

Failed to load designer. Check the source code for syntax errors and check if all references are available.

ICSharpCode.FormsDesigner.FormsDesignerLoadException: System.ComponentModel.Design.Serialization.CodeDomSerializerException: Could not find type 'SharpGL.OpenGLControl'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.

System.ComponentModel.Design.Serialization.CodeDomSerializerException: The variable 'openGLControl1' is either undeclared or was never assigned. at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)

at ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadDesigner() at ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadAndDisplayDesigner() at ICSharpCode.FormsDesigner.FormsDesignerViewContent.LoadInternal(OpenedFile file, Stream stream) at ICSharpCode.SharpDevelop.Workbench.AbstractViewContentHandlingLoadErrors.Load(OpenedFile file, Stream stream)

Slightly different as it's looking for a named type: SharpGL.OpenGLControl instead of the '?' it was looking for previously. The actual sample runs fine, I'm just unable to open the form in design view.

mrward commented 9 years ago

Unable to reproduce. With SharpDevelop 5.1 RC installed, I opened Samples.sln, went to WinForms Samples - SimpleDrawingSample and opened the FormSimpleSample.cs file into the forms designer. See the error because the SharpGL assembly is not built. Closed the FormSimpleSample.cs file, built the FormSimpleSample project, then re-opened the FormSimpleSample.cs file into the designer and it opened without any error.

ghost commented 9 years ago

Thanks for looking into this. Is there a later build than 5135 I can install? I checked the nightly page and there wasn't a 5.1 build artefact there.

mrward commented 9 years ago

The build server should now have a 5.1.0.5143 version.

SharpDevelop 5.1.5134 is the RC which is what I have installed. I do not believe there have been any changes to the forms designer between that release and the current commit on the master branch.

ghost commented 9 years ago

Still getting the error with the nightly.

I've got a checked out version of SharpDevelop at the latest git revision running in my installed version of SharpDevelop, and within that I've got the sample SharpGL code open.

I'm still getting the same error being shown so I'm trying to track down exactly where it's getting thrown (in the version of SharpDevelop open in the debugger) to see what's going on.

'FormsDesignerLoadException' is getting thrown from FormsDesigner.DesignerViewContent.LoadAndDisplayDesigner: 541 when LoadDesigner() (line 534) fails in the try block.

I'm seeing the error 100% of the time so if there's anything in particular you'd like me to check that might help please let me know

mrward commented 9 years ago

With a debug build of SharpDevelop the TypeResolutionService will try to find the SharpGL.OpenGLControl type. In the console window I see the following as it loads the SharpGL.dll to find the type.

DEBUG- 1 TypeResolutionService: Looking for SharpGL.OpenGLControl
DEBUG- Loading assembly sharpgl\source\SharpGL\Core\SharpGL\bin\Debug\SharpGL.dll (hash sharpgl.dll635765672437040000)
DEBUG- Loading assembly sharpgl\source\SharpGL\Core\SharpGL.SceneGraph\bin\Debug\SharpGL.SceneGraph.dll (hash sharpgl.scenegraph.dll635765672447320000)
DEBUG- Loading assembly sharpgl\source\SharpGL\Core\SharpGL.WinForms\bin\Debug\SharpGL.WinForms.dll (hash sharpgl.winforms.dll635765672452610000)

If you debug the TypeResolutionService you may be able to see what is going on.

ghost commented 9 years ago

Thanks, will tackle that tomorrow.

A couple of other observations: 1) While testing earlier I created a new WinForms project, used NuGet to pull in SharpGL and tried to add add an OpenGLControl to the main form. Instead of putting a control on the form and adding code to the designer.cs file nothing appeared to happen. Unfortunately no messages were displayed to help work out what went wrong.

2) I then added an OpenGLControl directly to the designer.cs file (not the recommended way I know). I added: private SharpGL.OpenGLControl glControl = null; just beneath the creation of the components container. Going to the design view worked at this point, the minimal application compiled and when run a small empty form was displayed.

Next I called the OpenGLControl constructor just inside InitializeComponent(): glControl = new OpenGLControl(); At this point going to the design view started failing. The application still compiled and when run a small empty form was still displayed as before.

Now this is where things get a bit weird, I deleted the call to the OpenGLControl's constructor that I'd just added. As expected the design view showed, however no small form was displayed, the entire design pane was the default grey of a form but there was no titlebar, no window decorations and no borders. The application still compiled and when run the normal small form was displayed.

How does the same code produce two different results like that? The only difference was I'd added a line of code, built the project, removed that same line (so that I was back to where I started) and then rebuilt again. Something very strange is going on!