Debugging Code-First Servers

Code-First server don't differ much from the classic RODL-based servers. Still there is one major difference between RODL and Code-First: latter allows to create an entity definition (service, structure, etc.) that will be correct from the compiler point of view but won't be correct from the Remoting SDK infrastructure point of view.

The first kind of such errors is to include non-supported data types into the published interface. For example take a look at this service definition:

[Service] 
public abstract class SampleService : RemObjects.SDK.Server.Service 
{ 
    [ServiceMethod] 
    public abstract string DoSomething(float value); 
} 

The server app containing such service definition will be compiled without any errors. But on server app startup a System.NotSupportedException will be thrown.

Its message will clearly point at the failure reason. F.e. in this case it will be

Cannot publish method SampleService.DoSomething

Argument type not supported: System.Single

The second kind of such errors is way more complex. What happens when a service contains several methods with the same published name?

[Service] 
public abstract class SampleService : RemObjects.SDK.Server.Service 
{ 
    [ServiceMethod] 
    public abstract string DoSomething(string value); 
 
    [ServiceMethod(Name="DoSomething")] 
    public abstract string DoSomethingDifferent(string value); 
}

There is no bug for the compiler and all data types used are valid.

The RemObjects.SDK.Exceptions.RodlValidationException exception will be thrown at runtime. It contains Details property which holds all the RODL errors. Still depending on the IDE debugger settings it might be not that easy to look at the exception details without changing the code or adding a handler to the ApplicationServerException event of the ApplicationServer class instance.

To simplify RODL validation errors detection the server writes down the generated RODL next to the service executable. Then this RODL can be opened using the Service Builder and investigated. Service Builder has a very useful Validate feature that will immediately show all suspicious places in the generated RODL.