Resolved 'WaitWnd.WaitWndFun' does not contain a definition for 'SetText'?

tim8w

Well-known member
Joined
Sep 8, 2020
Messages
133
Programming Experience
10+
Hi,
I am trying to add a routine 'SetText' to a class. It shows up in the solution explorer:

1611691146133.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?

I also tried making it a Property and get the same results.

Any ideas?
 
Show us the code (in code tags, not a screenshot) where you are trying to call SetText().

Also, SetText() is a method, not a variable based on that screenshot.
 
Is WaitWnd.WaitWndFun in another assembly than the code from post #3? If so, have you recompiled the other assembly successfully recently?
 
Is WaitWnd.WaitWndFun in another assembly than the code from post #3? If so, have you recompiled the other assembly successfully recently?
Yes., but the other two public functions don't give me any errors and work correctly.

C#:
WaitWnd.WaitWndFun waitForm = new WaitWnd.WaitWndFun();

waitForm.SetText("Loading");
waitForm.Show(this);

What's odd is that when I click on the context menu "Go To Definition", the listing from the metadata doesn't include my SetText() function.

C#:
#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);
    }
}
 
Which is why I think that the assembly is out of date compared to the code that you are showing in the Solution Explorer screenshot. Do a clean build of the the assembly.
 
Which is why I think that the assembly is out of date compared to the code that you are showing in the Solution Explorer screenshot. Do a clean build of the the assembly.
Clean build didn't help. I re-entered all the code again and now the metadata looks correct, but I still get the same error.

C#:
using System;
using System.Windows.Forms;

namespace WaitWnd
{
    public class WaitWndFun
    {
        public WaitWndFun();

        public void SetText(string sText);
        public void Close();
        public void Show();
        public void Show(Form parent);
    }
}

'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?
 
Is there any particular reason why you are adding a reference to the other assembly instead of adding a reference to the project that builds the other assembly?
 
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:

C#:
<HintPath>WaitWnd\bin\Debug\WaitWnd.dll</HintPath>

Was there a way to accomplish this within VisualStudio?
 
So I was right about out-of-date assemblies being referenced.

In Visual Studio, you can unload the project (as best as I can recall, it is right click, then "Unload Project" in the solution explorer), and then edit the .CSPROJ as XML's HintPath. When done editing, reload the project.

But all that does is deal with the symptom where you are referencing an assembly ala Visual Studio 2005 or 2008. If you actually referenced the project like you should do in modern versions of Visual Studio, this should have been a non-issue.
 
Back
Top Bottom