Reputation: 814
NOTE: This seems to be a fairly common error in MonoDevelop.
I am working on updating a C# Mono application I wrote. I'm having trouble with some dialogs, used by the application.
For example, in the following code:
public partial class Generic : Gtk.Dialog
{
public Generic (string text, string title = "Error Notice", string label = "<b>Error Details</b>", int height = 150)
{
this.Build ();
textview1.Buffer.Text = text;
this.Title = "Application - " + title;
label1.LabelProp = label;
this.DefaultHeight = height;
this.Resize(375, this.DefaultHeight);
}
protected void OnButtonOkClicked (object sender, System.EventArgs e)
{
this.Destroy();
}
}
I get these errors:
Error CS1061: Type `Namespace.Generic' does not contain a definition for `Build' and no extension method `Build' of type `Namespace.Generic' could be found (are you missing a using directive or an assembly reference?) (CS1061) (Namespace)
Error CS0103: The name `textview1' does not exist in the current context (CS0103) (Namespace)
As well as another one for label1. The thing is that textview1 does exist. So why MonoDevelop is telling me it doesn't I don't know.
I think this.Build
is inherited from Gtk.Dialog. Correct?
These were working earlier, but now, even after remaking the dialogs from scratch and just reentering the old code for the functionality it still doesn't work.
My old compiles still work, so while I don't know for sure, that would seem to indicate that GTK# is working fine...
Any help is appreciated. Thanks.
Upvotes: 0
Views: 3870
Reputation: 29
I had the same problem. It was because of destruction of project settings.
To resolve this problem, try open .csproj file and add into <ItemGroup>
<Compile Include="gtk-gui\yourUIGeneretedFimename.cs" />
yourUIGeneretedFimename.cs should be in folder where is placed your gui.stetic file. gui.stetic is a file with xml that describes ui.
Upvotes: 0
Reputation: 11
I had what seems to be the same issue ( I know this question is old ). The error I had was: "cs0103". I fixed this simply by rebuilding the solution.
Upvotes: 1
Reputation: 21
I got the same error, it happened when i renamed the Gtk.Window type class. The file in yourproj/gtk-gui also gets renamed, but the definition of the class inside the file dont. Just rename inside and be sure there's a definition for Build inside of the file -> Monodevelop sometimes drop off some code when you rename things.
Upvotes: 0
Reputation: 814
The errors were in the auto generated classes, for some reason they weren't being updated with changes to the GUI. I noticed that they didn't contain any references to the objects referred to in my code. I deleted the auto generated classes, and recreated the dialogs to fix the problem.
Upvotes: 2