开发者

How to force SilverLight to generate code in the Generated code folder?

开发者 https://www.devze.com 2023-01-31 07:03 出处:网络
This question is related to another question that I posted on SO earlier How to set up RIA services with Silverlight 4.0 and without EF.

This question is related to another question that I posted on SO earlier How to set up RIA services with Silverlight 4.0 and without EF.

To cut a long story short, we had in fact tried to implement the solution in the way outlined by Michael Maddox. However, when we first tried his solution within our setup up it didn't work for some unknown reason.

Now I've just given it another go and I've managed to get it working within our current solution setup but I am not entirely sure how and that's why I am posting this issue on SO. So here are the steps that I undertook:

I created a new blank SL project and implemented it following Michael's instructions and found that it worked.

Then, I tried to adapt the solution to my existing SL application but I couldn't get access to the remote method (shown below) from the SL application through "VanillaDomainContext" although "VanillaDomainService" would come up in Intellisense after referencing the method as a linked file.

System.ServiceModel.DomainServices.Hosting.EnableClientAccess()]
public class VanillaDomainService :
                System.ServiceModel.DomainServices.Server.DomainService
{
    public int ReturnInteger100()
    {
        return 200;
    }
}

After double checking things I decided to add a new SL application within our exisiting solution and I had no problem getting access to the remote method, using "VanillaDomainContext" from the newly created SL application.

Finally, I decided to give it another go in my already existing SL application and low and behold, this time I was able to use "VanillaDomainContext".

So, really my question is what happened there? My guess is that the "VanillaDomainContext" was not getting autogenerated, which I had in fact confirmed by looking at the generated code, before I had created the new SL application within my existing solution. Can you someone please shed some light on this issue on what I did wrong? There seems to be a bit too much "magic" going on here even though I'm a ne开发者_如何学Gowbie at Silverlight.

TIA,

David


I've had similar experiences with the voodoo of RIA services. I would double check that the silverlight project is connected to the RIA services project through the project properties. This is under the Silverlight tab and is called WCF RIA Services link. Beyond that, I've found that running a clean on both the Silverlight and RIA services project and then doing a rebuild seemed to help. And if that didn't work, I would show all files on the project, delete the Generated_Code folder and then rebuild it. That usually fixed everything back to normal.


You can refresh the RIA services via your services.web folder.
Right click on your Services Web folder and reselect the RIA service.
Then save and refresh the solution.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号