C# Error 'No overload for method 'getData' takes '1' arguments - c#

I am getting the following error:
Error 49 No overload for method 'getData' takes '1' arguments
With this method on the 5th line.
[WebMethod]
public string getVerzekerde(int bsn)
{
ZDFKoppeling koppeling = new ZDFKoppeling();
return koppeling.getData(bsn);
}
The getData method looks like this:
public string getData(int bsn)
{
using (new SessionScope())
{
ZorgVerzekerde verzekerde = PolisModule.GetVerzekerde(bsn);
return "Verzekerde " + verzekerde.Naam;
}
}
I realy don't understand what is going wrong here.. The description of this error on the msdn site didn't help me.. http://msdn.microsoft.com/en-us/library/d9s6x486%28VS.80%29.aspx
Someone who has a solution?

Yeah; somehow you're compiling against a different version of that class. Do a clean build, and double check your references.

Put an error in the GetData() method, then do a full build and confirm that the compiler find the errors. You may be editing the wrong file if you have more then one copy of the source code on your machine, and this will show you if you are.
Also try renaming the ZDFKoppeling class without updating getVerzekerde() and check you get a compiler error. If not you are not picking up the changed class for some reason.
If the above does not give a compiler error, try a rebook, as a process my have the dll locked, and also try a complete rebuild.
These problems normally turn out to be very simple once you have tracked them down. But get take forever to track down.
If another programmer works in the same office, ask for his/her help, as often a 2nd set of eye on the machine can find it quickly.
(I am assuming that GetData() is defined in the ZDFKoppeling class, not some other calss)

This generally indicates that it's not referencing the method you thought it was, but instead a different one. You can generally find out what method that is in Visual Studio by right clicking the method call and selecting "Go to definition". This should help work out why it's calling the one it is and not the one you expect.

Where is the getData method defined? Is it in another assembly? Have you tried rebuilding?
It doesn't look like anything's wrong with your the code.

Related

Public Form1 The Modifier 'public' is not valid for this item need some advice

Hey What Am I doing wrong here Ill give you my code I need some advice..
My problem is "Public Form1 The Modifier 'public' is not valid for this item"
I would post my code but its to long because this site tells me that the body is limited to 30,000 characters so mine was 66,517 characters so I will just post a simple line of code mabe you can help me out with this I have no other way to give you all my code its to long there is a pastebin link to my code below
public form1()
{
// this gives me a error when I compile it tells me this
The Modifier 'public' is not valid for this item
}
void splashstart()
{
// this also gives me the issue as the same as the other one
}
here is my errors from the console
{
Severity Code Description Project File Line Suppression
State
Error CS0106 The modifier 'public' is not valid for this item
EMUVoodoo C:\Users\man\Desktop\EMUVoodoo\embed a exe inside of the
form\WindowsApplication1\emuvoodoo.cs 296 Active
Error CS1001 Identifier expected EMUVoodoo
C:\Users\man\Desktop\EMUVoodoo\embed a exe inside of the
form\WindowsApplication1\emuvoodoo.cs 296 Active
Error CS0106 The modifier 'public' is not valid for this item
EMUVoodoo C:\Users\man\Desktop\EMUVoodoo\embed a exe inside of the
form\WindowsApplication1\emuvoodoo.cs 329 Active
Error CS0161 '()': not all code paths return a value EMUVoodoo
C:\Users\man\Desktop\EMUVoodoo\embed a exe inside of the
form\WindowsApplication1\emuvoodoo.cs 296 Active
}
I thought that I would at least paste my code here at pastebin site so you all can read it to help me out further I know no other way to give you my code your site has a limit to how many code characters you can paste mine was 66,517 so yeah please help me out on this thanks.... here is the code paste at pastebin
Here's a link! And a reference-style link to my code to take a look at.
As said in comments, you have placed public constructor to the OpenExe method. That is just wrong construct and that is the reason why your code does not compile.
Move that constructor out of the OpenExe, as well as 'SplashStart'.
Note that you already have another public default constructor, delete that one first.
You might also want to call that constructor from the other one, as this one is showing your splashscreen and doing some initalization.
public Form1(ApplicationControl appControl, MenuStrip, ...) :this()
{
// your other initialization code
}
And another piece of advice, if you allow, do some serious refactoring here.
A method (or constructor) should not have more then seven parameters.
Consider to extract some objects, grouping similar elements, like ToolStripMenuItem, for example.
Also, creating a separate thread in the form constructor and putting constructor body to sleep might not be the best practice as well.
Create your form, just don't show it. You can, for example, show splashscreen, initialize a timer. Once 5 seconds is over, hide splashscreen, show your main form.
Also, t.Abort(); is not recommended as well.
Good luck. Hope this helps you a bit.

How did the code execution get inside this 'if' statement?

Look at the following code:
public static string GetCleanURL(string baseURL, string url)
{
string cleanUrl = url.ToLower();
if (cleanUrl.StartsWith("http://"))
{//It already starts with http:// It is already in the correct form return it.
return cleanUrl;
}
The 'url' value passed in is "123.123.123.123:1234/myurl/withstuff.xml". In the 'if' statement, the value for 'cleanUrl' is "123.123.123.123:1234/myurl/withstuff.xml". But for some reason, the code execution goes inside of the if block and 'return cleanUrl;' gets executed.
Here is a screenshot of the current value for 'cleanUrl':
When I plug cleanUrl.StartsWith("http://") into the 'Immediate Window' of my debugger, it returns false. Which is what I would expect. However, the execution is somehow going into the if block as though it had returned true.
Can anybody please explain how this is possible?
SOLVED !!!
I appreciate those of you who helped me out on this one.
I needed to Clean and Rebuild my project and Close and Reopen Visual Studio 2013 about 4 times before the code base and debug stuff was actually in sync. It now appears to be working correctly.
Not sure why it ever got that way, or why I needed to do Clean/Rebuild several times before things synced up. But it is working now.
So, friends, if ever you find your code is just acting crazy and not doing what it should do. Just realize that anybody in their right mind would never become a programmer. Then do a clean / rebuild a few times and pray that the oddity goes away never to return.
Thanks for all your help on this one.
I LOVE fighting with the development tools...
No, StartWith isn't buggy, and works as expected.
Try the minimal code below. Reduce your code to the minimum amount to reprouce the problem. Does this happen everytime?
Does it happen with more than one candidate string? Or only that string?
Something else is going on sorry, the following writes Doesn't start
static void Main(string[] args)
{
string cleanUrl = "123.123.123.123:1234/SomeFile.xml";
if (cleanUrl.StartsWith("http://"))
Console.WriteLine("Starts");
else
Console.WriteLine("Doesn't start");
Console.ReadLine();
}

what does object.start() mean?

Sorry i am new to C#. I have a program, where there is a class CatchFS. The main function in the class , has the code
CatchFS fs = new CatchFS(args);
fs.Start();
Can someone tell me what it means. I hv heard of thread.start() but object.start() is new to me . Am i even thinking right ?
Thanks a lot, Yes it is derived from a class called FileSysetm.cs. The start does this : public void Start ()
{
Console.WriteLine("start");
Create ();
if (MultiThreaded) {
mfh_fuse_loop_mt (fusep);
}
else {
mfh_fuse_loop (fusep);
}
}
Now im trying to do a fusemount. The program starts and it hangs. there is some call that was not returned and i couldnt figure out which one. I tried using debug option of monodevelop, but no use, it runs only in my main function and I get thread started and thats it !!
I think the file FileSystem.cs is from library Mono.fuse.dll. Thanks for all your time. I hv been looking at this question for 2 whole days, and I dont seem to figureout much as to why the code wont proceed.Im expecting my azure cloud storage to be mounted in this fusemount point. My aim is after running this code I should be able to do an ls on the mountpoint to get list of contents of the cloud storage. I am also suspecting the mountpoint. Thanks a lot for providing me all your inputs.
There is no object.Start method. Start must be a method of the CatchFS class or some base class from which CatchFS derives.
If possible, consult the documentation for the library CatchFS comes from. That should hopefully explain what CatchFS.Start does.
If the documentation is sparse or nonexistent but you do have the source code, you can also simply take a look at the CatchFS.Start method yourself and try to figure out what its intended behavior is.
If there's no documentation and you have no source code, you're dealing with a black box. If you can contact the developer who wrote CatchFS, ask him/her what Start does.
One final option would be to download .NET Reflector and use that to disassemble the compiled assembly from which CatchFS is loaded. Treat this as a last resort, as code revealed by Reflector is typically less readable than the original source.
Start is a method on the CatchFS class (or one of its parent classes) - you'll have to read the documentation or source for that class to find out what it actually means.
According to the MSDN Docs for Object, there is no Start method. This must either be a method of CatchFS or one of it's base classes.

code to identify the number

I got one problem while doing one TAPI application based project in C#. I'm using ITAPI3.dll
My problem is.. i'm not getting incoming call information. To get the incoming call information, i'm using the get_callinfo function, but it is showing empty message.
Did you try a different modem?
TAPI is very hardware dependent
This might be a useful MSDN starting point:
http://msdn.microsoft.com/en-us/library/ms726262%28VS.85%29.aspx
(if you didn't already have that url)
I'm just experiencing the same problem. When i debug, a openfiledialog opens asking me to open a file. i'm no sure what it is right now, will get back when i find something. So i just skips the line of code, what causes it to be empty.
I found what was causing the problem for me :
get_callInfo has 3 constructors : one returning object, one returning int and one returning string. For some reason, the one returning object is failing. So i tried the string constructor. This gave me all the information i need. I'll give an overview of all attributes you can choose from :
e.Call.get_CallInfo(CALLINFO_STRING.CIS_CALLEDIDNUMBER);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_CALLEDIDNAME);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_CALLEDPARTYFRIENDLYNAME);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_CALLERIDNAME);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_CALLERIDNUMBER);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_CALLINGPARTYID);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_COMMENT);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_CONNECTEDIDNAME);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_CONNECTEDIDNUMBER);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_DISPLAYABLEADDRESS);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_REDIRECTINGIDNAME);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_REDIRECTINGIDNUMBER);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_REDIRECTIONIDNAME);
e.Call.get_CallInfo(CALLINFO_STRING.CIS_REDIRECTIONIDNUMBER);
hope this still helps

How can this code throw a NullReferenceException?

I must be going out of my mind, because my unit tests are failing because the following code is throwing a null ref exception:
int pid = 0;
if (parentCategory != null)
{
Console.WriteLine(parentCategory.Id);
pid = parentCategory.Id;
}
The line that's throwing it is:
pid = parentCategory.Id;
The console.writeline is just to debug in the NUnit GUI, but that outputs a valid int.
Edit: It's single-threaded so it can't be assigned to null from some other thread, and the fact the the Console.WriteLine successfully prints out the value shows that it shouldn't throw.
Edit: Relevant snippets of the Category class:
public class Category
{
private readonly int id;
public Category(Category parent, int id)
{
Parent = parent;
parent.PerformIfNotNull(() => parent.subcategories.AddIfNew(this));
Name = string.Empty;
this.id = id;
}
public int Id
{
get { return id; }
}
}
Well if anyone wants to look at the full code, it's on Google Code at http://code.google.com/p/chefbook/source/checkout
I think I'm going to try rebooting the computer... I've seen pretty weird things fixed by a reboot. Will update after reboot.
Update: Mystery solved. Looks like NUnit shows the error line as the last successfully executed statement... Copy/pasted test into new console app and ran in VS showed that it was the line after the if statement block (not shown) that contained a null ref. Thanks for all the ideas everyone. +1 to everyone that answered.
Based on all the info so far, I think either "the line that's throwing is" is wrong (what makes you think that), or possibly your 'sources' are out of sync with your built assemblies.
This looks impossible, so some 'taken for granted assumption' is wrong, and it's probably the assumption that "the source code you're looking at matches the process you're debugging".
When things look right on the surface then it's likely something you would dismiss. Are you 350% positive that your DLL/PDB matches your source code thus giving you the right line?
Try manually deleting your assemblies and run whatever it is you're running. Does it fail as it should?
Try cleaning out your solution and recompiling. Copy the assemblies to wherever and run it again. Does it work this time? Null ref at the same spot?
Debug the surrounding lines for values you expect. parentCategory, etc. should match what you think.
Modify the code by throwing an exception. Do the stack trace lines match exactly the lines in your code?
I've had some extremely mind-boggling experiences just like this because one of my assumptions was wrong. Typical is a stale assembly. Question all assumptions.
What doesn't make sense, though, is that the OP states that the console.writeline outputs a valid int and it calls the same property as the line where he states the error is being thrown.
A stacktrace would be helpful, or being able to look at the actual unit test.
Yes, could we see the code of the category class .. in particular the Id property? Assuming the Id property is an int (and not a nullable int), the get method must be accessing a NULL object.
Id could be a nullable int type (int?) with no value, however I feel that the property Id must be doing more than just returning an int, and something inside that is null.
EDIT Your edit reveals this is more than peculiar, could you supply us with a stack trace?
I'm not an expert on C#, and am not sure if it makes a difference, but are you debugging in Debug mode, or Release mode? If you're in release mode, the line that your IDE is pointing to and the line the problem is actually on may be different (I know this is the case in C++ when using Visual Studio)
I'd have to agree with Brian... Maybe you're using outdated .pdbs and the code you're seen on debug mode does not comply with the code actually being debugged.
Try cleaning the project, and rebuilding it in debug mode.
Looks like NUnit shows the error line as the last successfully executed statement... Copy/pasted test into new console app and ran in VS showed that it was the line after the if statement block (not shown) that contained a null ref. Thanks for all the ideas everyone. +1 to everyone that answered.

Categories