'WaitWnd.WaitWndFun' does not contain a definition for 'SetText' and no extension method 'SetText' accepting

Alvord, Timothy 276 Reputation points
2021-01-27T04:55:43.593+00:00

Hi,
I am trying to add a routine 'SetText' to a class. It shows up in the solution explorer:

60834-image.png

But if I try and access that variable I get the error:

'WaitWnd.WaitWndFun' does not contain a definition for 'SetText' and no extension method 'SetText' accepting a first argument of type 'WaitWnd.WaitWndFun' could be found (are you missing a using directive or an assembly reference?

Here's the code that's trying to call it:

WaitWnd.WaitWndFun waitForm = new WaitWnd.WaitWndFun();  
  
waitForm.SetText("Loading");  
waitForm.Show(this);  

and here's the metadata for the class:

#region Assembly WaitWnd.dll, v1.0.0.0  
// C:\Users\a3055389\Desktop\WaitforWnd_Sources\WaitWnd\bin\Debug\WaitWnd.dll  
#endregion  
  
using System;  
using System.Windows.Forms;  
  
namespace WaitWnd  
{  
    public class WaitWndFun  
    {  
        public WaitWndFun();  
  
        public void Close();  
        public void Show();  
        public void Show(Form parent);  
    }  
}  
  

Any ideas?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,100 questions
0 comments No comments
{count} votes

Accepted answer
  1. Alvord, Timothy 276 Reputation points
    2021-01-28T04:43:07.073+00:00

    Finally figure it out. Not sure if there's an easier way to fix it, but I'll explain what happened and how I ended up getting it to work. So the one project/class that was giving me problems "WaitWnd,WaitWndFun" was taken from another solution I had build elsewhere and added to the solution I was currently working on. It looks like even though the entire project was copied into the new solution space on my computer, the locations of where the DLL were is still hard-coded into the ".csproj" file and no amount of Clean builds, re-builds or anything else changed the location in the ".csproj" file. I only happened onto the solution when I looked at the ".csproj" file in a text editor and noticed that it was getting the location of where to look for the DLL from the old solution's directory. So I changed the path to the new project, and reloaded the solution, re-compiled and everything worked fine. Here is the location within the ".csproj" file I modified:

            <HintPath>WaitWnd\bin\Debug\WaitWnd.dll</HintPath>
    

    Was there a way to accomplish this within VisualStudio?

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,626 Reputation points
    2021-01-28T03:23:40.353+00:00

    Hi AlvordTimothy-4979,
    Based on your code which in the metadata for the class, the 'member function' must declare a body because it is not marked abstract, extern, or partial.
    The code is as follows:

    namespace WaitWnd  
    {  
        public class WaitWndFun  
        {  
            public WaitWndFun() { }  
      
            public void Close() { }  
            public void Show() { }  
            public void Show(Form parent) { }  
            public void SetText(String s) { }  
        }  
    }  
    

    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.