0

I have three solution A, B and C. I have an enum in A like this:

using System.Runtime.Serialization;
namespace A.Entities
{
    [DataContract]
    public enum Status
    {
        [DataMember]
        Active = 0,

        [DataMember]
        Inactive = 1,
    }
}

I reference it in solution B like this:

using A.Entities;
namespace B.Entities
{
    public class User
    {
        [DataMember]
        public string UserName { get; set; }

        [DataMember]
        public Status Status { get; set; }
    }
}

In solution C, I use them like this:

using B.Entities;
using Status = A.Entities.Status;
namespace C.TestDatas
{
    public class UserTestData
    {
        public static User CreateUser()
        {
            return new User
                   {
                       Status = Status.Active,
                   }
        };
    }
}

When I invoke User method, it throw exception:

Method not found: 'Void B.Entities.User.set_Status(A.Entities.Status)'.

Why? I hope someone can help me, thanks!

7
  • Possibly related, note that you need to decorate enumerations with EnumMember, not DataMember
    – StuartLC
    Jul 7, 2015 at 7:26
  • from the code you posted, I dont see set_Status(Status s) method in B.Entities.User - The compiler is correctly complaining if that is the case
    – Krishna
    Jul 7, 2015 at 7:55
  • post the code where you are creating the user
    – Krishna
    Jul 7, 2015 at 7:55
  • DataMember is not work too. I donot have wcf invoke.
    – randy ling
    Jul 7, 2015 at 8:34
  • I dont see set_Status too , I don't know why the compiler post it.
    – randy ling
    Jul 7, 2015 at 8:36

1 Answer 1

0

I can't reproduce the problem. Your code works fine on my computer (on .NET framework 4.5)

Could you make sure that you project is configured correctly:

  1. Both A and B solutions have reference to System.Runtime.Serialization
  2. C has reference to A and B. Make sure you don't link the dll from /Bin folder, but you have the project reference
  3. Hit Clean and Rebuild buttons in Visual Studio.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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.