Home > .NET > Strange errors in generated file DataServiceImplementation.cs in LightSwitch

Strange errors in generated file DataServiceImplementation.cs in LightSwitch

Over the past week or so I have been playing with LightSwitch and have been very impressed with what I have found.

That being said, while I know this problem was my fault for being lazy, I have come across my first batch of strange code generation errors. While simple to solve I assume I am probably not the only person to make this mistake so thought I would share my findings.

As part of learning about LightSwitch, I have been going through and following a number of tutorials on the various aspects.

Currently I am looking at using RIA services as a data source and have been following the Creating a Simple LightSwitch RIA Service (using POCO) tutorial from LightSwitch Help Website.

Rather than download the code sample, I was rewriting the code step by step. However once I added my data source to the LightSwitch application and tried to compile I received these errors in DataServiceImplementation.cs within the ServerGenerated project.

Error	1	) expected
Error	2	Invalid expression term ')'
Error	3	; expected
Error	4	; expected
Error	5	A new expression requires (), [], or {} after type
Error	6	; expected


Of course I thought generation errors probably mean I have done something wrong. I looked over the code I had written and it all roughly matched what was provided in the tutorial. I then downloaded the tutorial source and saw that it compiled and worked correctly.

Puzzled I took a closer look at my code and decided to clean it up as I had been lazy and just dumped everything in the same file while I was working. Upon doing so I noticed that when I created the CustomerRecord model class, I accidentaly created it as a nested class of the domain service class.


public class DomainService
    public class CustomerRecord

instead of

public class DomainService

public class CustomerRecord

After refactoring this class into its own file as I should have done in the first place, and updating the data source the solution copiled correctly.

With any luck this will help someone else that makes the same stupid mistake as me.

Categories: .NET Tags:
  1. September 2, 2011 at 12:10 pm

    I wrote that article. Thank you for linking to my site. Yeah I made the same mistake when I was developing the article 🙂

  2. October 15, 2011 at 7:52 pm

    Excellent post. Fixed my problem. I thought I had some problem with LS in the geneterated code. It was putting a + in place of a period on the domain service class. You could fix in the code but every time you build the project the generated code would get overlayed and put things back with the wrong syntax.

    That’s what I get for cutting and pasting code.


  3. June 21, 2012 at 4:15 am

    Fixed my problem as well. I thought it was strange. I was trying to convert the ‘+’ signs in the Dataserviceimpelmentation file to ‘.’ but every compile kept bringing them back. I’ve seen that + convention before to mean a nested class, so your article made perfect sense! Thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: