5

I'm facing really strange error while debugging my program. I have a data contract where I added new properties but one of them cause the following exception:

Method not found: 'Void Measurement.set_ContactId(Int32)'.

The data contract looks following:

[DataContract]
public class Measurement
{
    [DataMember]
    public int FactId { get; set; }

    [DataMember]
    public int ContactId { get; set; }
.....

I don't really understand what can be a problem since, as I said, I added some other properties but there was no problem with them.

UPD: The exception is happening on the service side when I try to assign a value to ContactId:

foreach (Measurement m in result.Where(m => m.FactId == factId)){
    m.ContactId = contactId;
  .....
8
  • Do you have a set_ContactId(Int32) method in your Measurement class?
    – Bob.
    Oct 5, 2012 at 12:12
  • 2
    Why would I need that there? There is already a setter for ContactId declared. Plus, if I try to add it, I get an error: Method with the same signature is already declared.
    – Azimuth
    Oct 5, 2012 at 12:16
  • 1
    Do a clean rebuild and update your service references
    – Erix
    Oct 5, 2012 at 12:24
  • @Adil, did you read my question? I do in fact use public int FactId...
    – Azimuth
    Oct 5, 2012 at 12:25
  • He suggested to change from property to variable - just remove {get;set;}
    – Renatas M.
    Oct 5, 2012 at 12:27

3 Answers 3

16

The problem was with some older version of the DLL which was stored in .NET's cache. I made a search on the whole disk for the DLL and deleted all found files (some were in use by the .NET so I had to use Unlocker). After rebuilding the project it worked fine.

2

If this Measurement class is part of your WCF service, then you have it on both side of your service (client side and server side). Do both side have the same version (where ContactId has a setter)?

3
  • Yes, both client and the server sides have the same version of Measurement. Plus, the exception is happening on the server side when I try to assign a value to ContactId
    – Azimuth
    Oct 5, 2012 at 12:19
  • What is your WCF protocol? TCP, soap...? Oct 5, 2012 at 12:23
  • 3
    This should be a comment, not an answer. Oct 5, 2012 at 12:25
0

If the method cones from a Nuget package, update or reinstall the package

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.