none
The type or namespace name could not be found?

    Question

  • New to MSRS and can't for the life of me figure out why I get this error in one situation but not the other? Forgive me if this has already been discussed but my forum searches turned up dry.

    The errors
    Error    6    The type or namespace name 'MySpecialClass' could not be found (are you missing a using directive or an assembly reference?)  .........cs

    dssproxy exited with code 20.

    I have a simple service, in fact it's the template service with HttpGet and one custom Message (Called MyMessage) added to the main port.

    If I put the DataMember type definitions in a different project, reference that project from the service project it comples and runs fine.

    If I move the DataMember type definition into the same project as shown below it will not build??

     

    It's not namespace related as I moved the class into the service project but kept it within the external namespace (ABogusLibrary) and it still gave me the error.

    This works:

    No DataMember Type Definitions in Service Project:

    Code Snippet

    namespace Robotics.JausTestInterface

    {

    public class MyMessage :

    Update<MyMessageData, PortSet<DefaultUpdateResponseType, Fault>>

    {

    }

     

    [DataContract]

    public class MyMessageData

    {

    [DataMember]

    public AnExternalClass MessageX { get; set; }

    [DataMember]

    public MySpecialClass MessageY { get; set; }

    }

    }

     

     

    Type definitions in A seperate library:

    Code Snippet

    namespace ABogusLibrary

    {

    public class AnExternalClass

    {

    }

    public class MySpecialClass

    {

    }

    }

     

     

    If I move the MySpecialClass out of the library (delete its definition) and into the Service Project I get the build errors?

    This fails:

    Code Snippet

    namespace Robotics.JausTestInterface

    {

    public class MyMessage :

    Update<MyMessageData, PortSet<DefaultUpdateResponseType, Fault>>

    {

    }

     

    [DataContract]

    public class MyMessageData

    {

    [DataMember]

    public AnExternalClass MessageX { get; set; }

    [DataMember]

    public MySpecialClass MessageY { get; set; }

    }

     

    public class MySpecialClass

    {

    }

    }

     

     


    I can't figure out what is going on or why this would be the case?
    Friday, July 11, 2008 5:48 PM

Answers

  • George

    Sorry, wasn't clear in the previous post.

    No. I still see the problem (or the lack of an expected error anyhow).

    I can still move the class to a different assembly, remove the DataContract attribute, and it will compile and execute without any errors. Note that I have not created a new project from scratch when I tested this. I simply opened the solution again after installing CTP2, corrected any issues (I believe it was simply removing/adding back a reference), and hit Rebuild Solution.



    Thursday, July 31, 2008 4:12 PM

All replies

  • every type, including your MySpecial class must be DataContract annotated and have a valid Contract class in its namespace for us to serialize it.

     

     

    thanx

    g

    Friday, July 11, 2008 8:11 PM
  • You are correct. I was just going to post a follow up to this when I saw your response...

     

    So this now works..

    Code Snippet

    namespace Robotics.JausTestInterface

    {

    public class MyMessage :

    Update<MyMessageData, PortSet<DefaultUpdateResponseType, Fault>>

    {

    }

     

    [DataContract]

    public class MyMessageData

    {

    [DataMember]

    public AnExternalClass MessageX { get; set; }

    [DataMember]

    public MySpecialClass MessageY { get; set; }

    }

     

    [DataContract] //This attribute fixes it.

    public class MySpecialClass

    {

    }

    }

     

     

     

    However, Can you please explain -

    If it needs to be serailizable why can I leave the attribute OFF of the class when it is in a different assembly/project?
    Friday, July 11, 2008 8:48 PM
  • Anyone?

    I don't understand why I need the DataContract attribute when the MySpecial class is in the same project/assembly as the service definition but I do not need the attribute when MySpecialClass is in a different project/assembly.

    What am I missing?


    Tuesday, July 15, 2008 12:58 PM
  • There was an inconsistency in how data contract where handled. This is fixed in the July CTP. DssProxy now requires all

    data contracts to have the DataContract attribute.


    Andreas

    Monday, July 21, 2008 10:46 PM
  • So should I now expect a compile error for the class that is missing the DataContract attribute and is defined in the seperate assembly?

    I have the July CTP installed and I rebuilt the applicaiton that I demoed the issue in and it still compiles and runs just fine with out the attribute added??


    Wednesday, July 23, 2008 3:28 PM
  • Bryan, does this now work with CTP2?

     

    Friday, July 25, 2008 5:29 PM
  • George

    Sorry, wasn't clear in the previous post.

    No. I still see the problem (or the lack of an expected error anyhow).

    I can still move the class to a different assembly, remove the DataContract attribute, and it will compile and execute without any errors. Note that I have not created a new project from scratch when I tested this. I simply opened the solution again after installing CTP2, corrected any issues (I believe it was simply removing/adding back a reference), and hit Rebuild Solution.



    Thursday, July 31, 2008 4:12 PM