91

What are the .datasource files that are automatically generated by "Create Service Reference" in Visual Studio? The comment in the file is this:

This file is automatically generated by Visual Studio .Net. It is used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.

However, it sounds like these files are optional, so I'm wondering what they are used for. I'm also wondering if it is truly safe to delete them, since they often cause path length problems on XP.

http://www.eggheadcafe.com/conversation.aspx?messageid=34104031&threadid=34104026

Can anyone point me to some official MS documentation on these files?

David d C e Freitas
  • 7,146
  • 4
  • 54
  • 66
Andy White
  • 81,400
  • 46
  • 171
  • 205

4 Answers4

39

As far as I remember, they are just generated so that you can use the data contracts used in the service as object data sources for data binding against UI controls.

tomasr
  • 13,413
  • 3
  • 35
  • 30
  • 16
    So can you DISABLE their auto-generation? If so, how? – Auri Rahimzadeh Jul 05 '13 at 21:08
  • 2
    @AuriRahimzadeh When you add service reference there is an option like "Reuse types in referenced assemblies". That way prevents auto generation of these objects in client. (Of course you should have a reference for that DataContract dll and version of the dlls should be the same in service project and client project) – sotn Jan 27 '16 at 08:22
  • So it creates a zillion files I don't need to encourage poor design. – xr280xr Jun 09 '20 at 21:14
19

The .datasource files are optional, but they can be used in your client app to easily bind a data contract to a ui control. Here is an article explaining how to use them:

http://msdn.microsoft.com/en-us/library/ee373840.aspx

Chris Schroll
  • 191
  • 1
  • 4
14

I was able to delete them from one of our projects. Project built fine, and loaded stuff from the database fine, so I'm assuming it was safe. I would like to hear someone who knows more about them weigh in on this element of the subject though.

Adam Nofsinger
  • 3,634
  • 2
  • 32
  • 42
  • I had the same experience. Deleted without issue after being told that the file names were too long. – JacobIRR Jan 07 '21 at 21:51
2

Expand your Reference.svcmap from visual studio.

Update reference.

And delete yellow warning datasources.

elfekz
  • 1,328
  • 10
  • 25