Search code examples
wcf-ria-servicest4

Generation of .svc-files on IIS fails when using custom RIAServices.T4 code generation


I have a Silverlight application that uses a custom DomainContextGenerator and a custom EntityGenerator:

[DomainServiceClientCodeGenerator("MainCodeGenerator", "C#")]
public class HrCodeGenerator : CSharpClientCodeGenerator
{
    protected override EntityGenerator EntityGenerator
    {
        get { return new HrEntityGenerator(); }
    }

    protected override DomainContextGenerator DomainContextGenerator
    {
        get { return new HrDomainContextGenerator(); }
    }
}

This class and the referenced generators are contained in a class library referenced by the Host-project of the Silverlight application.

When starting the application in VisualStudio 2012 everything works fine and when I open http://localhost:12345/My-Namespace-MyService.svc in a browser I can see the landing page of the service. When deploying the application to the IIS however the on-the-fly-generation of the .svc-files fails and when opening http://dev.example.com/My-Namespace-MyService.svc I just receive a HTTP 404.

After removing the HrCodeGenerator-class from the project (removing the DomainServiceClientCodeGeneratorAttribute won't do the trick), everything works fine.

Do you have any hint on why it behaves that way and what I can do to prevent that from happening?


Solution

  • I finally solved the issue.

    The classes responsible for the client code generation were located in the same library as the services itself. I moved these classes to the web-application project that gets deployed to the server.

    I still don't understand how code that gets executed at compile time only and only affects the client side of the application can possibly influence the runtime behavior of the server side of the application. I also don't understand why moving the components to another project fixed the problem.

    But as a colleague of mine states: "Sometimes engineering is indistinguishable from magic..."