none
Domain Context reference not auto generating

    Question

  • I have followed the tutorial in this video http://www.silverlight.net/learn/advanced-techniques/wcf-ria-services/using-wcf-ria-services#Exercise1 and the context reference that is supposed to be auto generated when you compile doesnt show up. I made sure I followed it to the letter. 

    1) I right clicked on model folder added a new entity model.

    2) I then compiled it before moving on.

    3) Then I added a Domain Service and made sure Enable Clietn Access was selected and Generate associated classed was selected after choosing my tables to expose.

    4) After compiling again, I showed hidden files in the silverlight app to see the generated context file that is need to access the service and it isn't there and hasn't been generated. I've tried refreshing, restarting the enviroment, re-doing steps multiple times and clean rebuilding. Still doesn't show up

    Does anyone know how this could happen and how to force it to generate that code?

    Thanks

    Monday, January 30, 2012 12:44 AM

Answers

  • I tried removing and re adding both  project references to each other. I'm fairly convinced nwo that my RIA services is broken somehow. When I get home tonight, I'll reinstall it. :( thanks for trying guys. I hope this fixes it.

    Tuesday, January 31, 2012 2:46 PM
  • I finally fixed it guys. Apparently there may be a bug with the autogenerate scripting. After uninstalling I went back and it still didn't work but I decided to start a brand new project and this time it worked. I had the project named the default stuff so I had to build another one with the correct name of the project and it stopped working again. I was furious so I added the domain service two more times, which neither one generated a meta file on the server even though I had it checked and the context generated. Weird, but at least it's working. Thanks guys.

    Wednesday, February 01, 2012 12:52 AM

All replies

  • Hi,

    Try following step:

    1. Delete folder: Bin, Generate_Code, and obj from client project
    2. Delete folder: Bin, and obj from server project
    3. Rebuild the solution
    4. Make sure model at the last update you have made
    5. Make sure DomainService also has been update
    6. RUN the project

    Hope this can help

    Monday, January 30, 2012 1:09 AM
  • I was so hoping that would work. But no dice. I deleted them several times hopeing that at some point it would trigger the service context to be auto generated. Never happened. Is there any way I can manually do this? I don't care about the extra work at this point, I just want it to work so I can move on in my project.

    Monday, January 30, 2012 4:33 PM
  • I also just tried a brand new project, and followed those steps connecting to the same database. No autogenerated code. IS there something that I can do?

    Monday, January 30, 2012 4:44 PM
  • It's strange,

    Could you please try to start Visual Studio As Administrator?

    1. Right Click Microsoft Visual Studio Icon on your deskTop
    2. Right Click Again Microsoft Visual Studio at the new menu, and choose "Run As Administrator"
    3. Start your project

    I do have some of my Project that I have to open this way. Hope this can help

    Monday, January 30, 2012 6:55 PM
  • I did that with no luck. There has to be a way to manually create this code?

    Monday, January 30, 2012 7:07 PM
  • Hi,

    Is it possible to send me your project? Please send it to j.siahaan@live.com, if possible.

    Monday, January 30, 2012 10:51 PM
  • Sending it after the .zip file finishes uploading.

    Monday, January 30, 2012 10:54 PM
  • Email Sent, I really appreciate all your help.

    Monday, January 30, 2012 11:02 PM
  • Hi,

    I have test your with modification as follows:

    1. Remove (delete) folder Libs from Client project using Visual Studio Solution Explorer
    2. Set Startup projet to B-MovieCCG.Web

    It work fine

    Tuesday, January 31, 2012 9:37 AM
  • So the class auto generated?

    Tuesday, January 31, 2012 9:43 AM
  • I think if thats all you had to do to fix it and mine(trying the same thing)  still didn't auto generate the class. I think I need to reinstall something. There's no way my stuff is working as designed.

    Tuesday, January 31, 2012 9:53 AM
  • Hi,

    Is this the code below that you mean? If yes, you need to recreate BMServices.cs Using Visual Studio Solution Explorer:

    1. Delete BMServices.cs
    2. Add Domain Services name BMServices.cs, and Check "Generated associated classes for metadata"

    You will have BMServices.cs and BMService.metadata.cs

    Here the metadata claseses:

    namespace B_MovieCCG.Web.Models
    {
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.ComponentModel.DataAnnotations;
        using System.Linq;
        using System.ServiceModel.DomainServices.Hosting;
        using System.ServiceModel.DomainServices.Server;
    
    
        // The MetadataTypeAttribute identifies AcountInfoMetadata as the class
        // that carries additional metadata for the AcountInfo class.
        [MetadataTypeAttribute(typeof(AcountInfo.AcountInfoMetadata))]
        public partial class AcountInfo
        {
    
            // This class allows you to attach custom attributes to properties
            // of the AcountInfo class.
            //
            // For example, the following marks the Xyz property as a
            // required property and specifies the format for valid values:
            //    [Required]
            //    [RegularExpression("[A-Z][A-Za-z0-9]*")]
            //    [StringLength(32)]
            //    public string Xyz { get; set; }
            internal sealed class AcountInfoMetadata
            {
    
                // Metadata classes are not meant to be instantiated.
                private AcountInfoMetadata()
                {
                }
    
                public int AccountID { get; set; }
    
                public Nullable<bool> Confirmed { get; set; }
    
                public Nullable<int> Credits { get; set; }
    
                public string Email { get; set; }
    
                public Nullable<int> Funding { get; set; }
            }
        }
    
        // The MetadataTypeAttribute identifies ArtworkMetadata as the class
        // that carries additional metadata for the Artwork class.
        [MetadataTypeAttribute(typeof(Artwork.ArtworkMetadata))]
        public partial class Artwork
        {
    
            // This class allows you to attach custom attributes to properties
            // of the Artwork class.
            //
            // For example, the following marks the Xyz property as a
            // required property and specifies the format for valid values:
            //    [Required]
            //    [RegularExpression("[A-Z][A-Za-z0-9]*")]
            //    [StringLength(32)]
            //    public string Xyz { get; set; }
            internal sealed class ArtworkMetadata
            {
    
                // Metadata classes are not meant to be instantiated.
                private ArtworkMetadata()
                {
                }
    
                public int ArtistID { get; set; }
    
                public int ID { get; set; }
    
                public byte[] Picture { get; set; }
    
                public Nullable<int> Type { get; set; }
            }
        }
    
        // The MetadataTypeAttribute identifies CardRepositoryMetadata as the class
        // that carries additional metadata for the CardRepository class.
        [MetadataTypeAttribute(typeof(CardRepository.CardRepositoryMetadata))]
        public partial class CardRepository
        {
    
            // This class allows you to attach custom attributes to properties
            // of the CardRepository class.
            //
            // For example, the following marks the Xyz property as a
            // required property and specifies the format for valid values:
            //    [Required]
            //    [RegularExpression("[A-Z][A-Za-z0-9]*")]
            //    [StringLength(32)]
            //    public string Xyz { get; set; }
            internal sealed class CardRepositoryMetadata
            {
    
                // Metadata classes are not meant to be instantiated.
                private CardRepositoryMetadata()
                {
                }
    
                public Nullable<int> ArtID { get; set; }
    
                public Nullable<int> Attack { get; set; }
    
                public Nullable<int> BorderID { get; set; }
    
                public int CardRarity { get; set; }
    
                public string CardSet { get; set; }
    
                public int CardType { get; set; }
    
                public Nullable<int> Health { get; set; }
    
                public string Name { get; set; }
    
                public int OtherCost { get; set; }
    
                public int SetNumber { get; set; }
    
                public string Theme { get; set; }
    
                public int ThemeCost { get; set; }
    
                public int UniqueID { get; set; }
            }
        }
    
        // The MetadataTypeAttribute identifies DeckMetadata as the class
        // that carries additional metadata for the Deck class.
        [MetadataTypeAttribute(typeof(Deck.DeckMetadata))]
        public partial class Deck
        {
    
            // This class allows you to attach custom attributes to properties
            // of the Deck class.
            //
            // For example, the following marks the Xyz property as a
            // required property and specifies the format for valid values:
            //    [Required]
            //    [RegularExpression("[A-Z][A-Za-z0-9]*")]
            //    [StringLength(32)]
            //    public string Xyz { get; set; }
            internal sealed class DeckMetadata
            {
    
                // Metadata classes are not meant to be instantiated.
                private DeckMetadata()
                {
                }
    
                public string CardCode { get; set; }
    
                public string DeckName { get; set; }
    
                public int OwnerAccountID { get; set; }
            }
        }
    }
    
    Tuesday, January 31, 2012 10:01 AM
  • I'm so sorry I mis led you. No thats not the class I'm talking about. I'm talking about the client side referebce context that allows me to address the domain. That particular class didn't generate before I gave you the solution because I was trying different stuff to get my code to work. I have that class in my solution now.

    Tuesday, January 31, 2012 10:18 AM
  • Is that mean the problem has been solved?

    Tuesday, January 31, 2012 10:22 AM
  • Unfortunately no. I'm so sorry this problem is still here. 

    Tuesday, January 31, 2012 10:24 AM
  • Is there a possiblity that I turned something off somehow?

    Tuesday, January 31, 2012 10:26 AM
  • I am missing the Clientside Context reference for the Domain service. That is what isn't generating.

    Tuesday, January 31, 2012 10:55 AM
  • You may need to uninstall RIA Services and then install it again. However, you can try resetting the RIA Link first in your project since I haven't seen anyone mention that in this thread.

    In the client side project, open the properties of the project. Change the RIA Services Link property to nothing, close and reopen the properties screen, and then reselect the server side project for the link. See if that gets it working. Also, check the output window to see if there are any errors during the build from RIA.

    Tuesday, January 31, 2012 11:51 AM
  • That sounds interesting. I'll try it a bit when My wife is doen watching her show...lol. I do know it does generate the website reference, just not the domain service reference.

    Tuesday, January 31, 2012 1:35 PM
  • I tried removing and re adding both  project references to each other. I'm fairly convinced nwo that my RIA services is broken somehow. When I get home tonight, I'll reinstall it. :( thanks for trying guys. I hope this fixes it.

    Tuesday, January 31, 2012 2:46 PM
  • I finally fixed it guys. Apparently there may be a bug with the autogenerate scripting. After uninstalling I went back and it still didn't work but I decided to start a brand new project and this time it worked. I had the project named the default stuff so I had to build another one with the correct name of the project and it stopped working again. I was furious so I added the domain service two more times, which neither one generated a meta file on the server even though I had it checked and the context generated. Weird, but at least it's working. Thanks guys.

    Wednesday, February 01, 2012 12:52 AM