Re: Method '*****' not found. Warning displayed in 'Form1.cs [Design]' pane



On Sat, 26 Sep 2009 11:30:52 -0700, anthony <anthonysvalencia@xxxxxxxxx> wrote:

[...]
Warning message: Method 'System.Windows.Forms.Form.DisplayMessage' not
found.

Comment: I know that DisplayMessage is not a method of the Form
object.

But it needs to be for the Designer to know what to do with it.

The file where you're trying to add the call site to your new method is a special file: in addition to being compiled by the C# compiler to create your Form sub-class, it is parsed by the Visual Studio Designer as part of showing you the graphical representation of the object and allowing you to edit it.

If the Designer comes across something it doesn't recognize, it has no way to know what to do with it. So, while the compiles and runs okay (or at least, in the example you gave it should), when it comes time for you to try to edit the control graphically with the Designer, it emits the warning you describe, explaining to you that it found something it doesn't understand.

I am trying to get Form1 class to define a new form in
adddition to those derived from Form. I thought that was what the
following line was doing from Form1.cs:

public partial class Form1 : Form {

Well, yes...the ": Form" does indicate to the C# compiler that your new Form1 class inherits the Form class. But the C# compiler isn't what's giving the message.

Apparently, I do not know how to add additional methods to a class
which was derived from another class.

You are adding the method just fine. It's your use of the method that is causing problems.

In any event, this is what I
wish to do. Does someone know how to do this? Also, I know that this
method does not have a purpose here. It is going to be substituted
with another method, but I chose to write something smaller and
simpler to generally illustrate the issue I am having.

As Jeff says, you should not be editing the *.Designer.cs file. It is not literally possible to do what you seem to be wanting to do, while still preserving the Designer's ability to work with your class correctly. It's not clear from your question why you want to insert the method call in the *.Designer.cs file, nor for that matter why you have declared a control member in the regular *.cs file (where the Designer can't see it...not that this issue is connected to the specific question you're asking).

It's possible that you should simply call the method from your own construction, after the call to InitializeComponent(), or that you should override the OnFormLoad() or OnShown() methods and call the method in the override. Or it's possible there's some entirely different thing you should be doing. If you can describe in a clear, specific way what it is you're actually trying to accomplish, we might be able to offer useful advice along those lines.

But whatever it is you're really trying to do here, manually writing code in the *.Designer.cs file isn't the right way to do it.

Pete
.



Relevant Pages

  • Re: Delphi and the .Net platform
    ... If interested in data access then this is worth a quick read and watch the video. ... First, design and build your application as a .NET client application, then assign the portions of the application to run on the server and the client tiers late in the development process. ... For the Fx3.0 stuff you only need a CLR 2.0 compatible compiler while for Fx3.5 a more complex compiler is required. ... :) Then there are the several designers that will be necessary for IDE support of Fx3.0 and Fx3.5 not to mention the CF designer and dropping the WinForms designer. ...
    (borland.public.delphi.non-technical)
  • Re: while (1) vs. for ( ;; )
    ... >> I was surprised at how many people reported that a compiler ... >> better expression (lower defect rate, higher productivity, ... There is for some developers. ... effects of a warning message issued by a compiler, ...
    (comp.lang.c)
  • Re: Getting the lr register in a C subroutine
    ... you can't do this in ADS without assembler. ... > The compiler can place the return address whereever it wants, ... The routine I would create is a controled one and all it will do is get ... about happens here, the only problem is the warning message, that to me ...
    (comp.sys.arm)
  • Compiler Warning C4373 about virtual methods
    ... The following code will result in C4373 warning message. ... What means "bind"? ... either the base or derived class. ... Versions of the compiler prior to Visual C++ 2008 bind the function to the ...
    (microsoft.public.vc.language)
  • Re: attributes in C#
    ... but I know that when you're writing a Web service ... a Web service, you decorate it with attributes that tell the compiler, ... you'll notice that you can create new controls ... You point the Designer to a DLL full of classes and say, ...
    (microsoft.public.dotnet.languages.csharp)

Loading