Question

scamper_cat on Fri, 06 Jul 2012 16:36:05


 I have a C# 2010 application that uses linq to sql connections. I am having problems with the visual studio.net 2010 ide opening up very slowly.
 The problem looks like I need to change part of the name for a dbml file. Here are the names I am working with;
 1. testapp.dbml,
 2. testapp.dbml.layout, and
 
 3. testapp1.designer.cs.


 I know the problem is the name called testapp1.designer.cs.

 I do not know how to change the name of this element. The visual studio.net ide will not let me change
the name from  testapp1.designer.cs to testapp.designer.cs.

 Thus can you tell me how to change the name?

 If you think something else is causing the problem, can you let me know what it is and how to solve the problem?

 


Sponsored



Replies

CoolDadTx on Sat, 07 Jul 2012 15:47:35


You don't.  The various testapp.*.cs or testapp.*.layout files are autogenerated by the IDE whenever the root file changes.  Whatever the root file is the generated files will follow.  If you want to rename your root file then you can and the generated files will be fixed up.  If you try to rename just the generated files then: a) it won't work and b) it'll potentially break stuff.

The reason you're in this situation is that you likely were messing with the files originally and caused the designer to generate the file again.  The designer wanted to use testapp.designer.cs but couldn't so it attached a 1 on the end.  You can't resolve this by any IDE magic as the files are now out of sync.  What you can do is close the IDE, edit the project file in a text editor, find the entry for testapp1.designer.cs and rename it to match the root file.  Then go to the file system and rename the testapp1.designer.cs file to match.  It is very important that the generated files match the base file otherwise you'll run into this issue again. 

Once you've made the manual changes then open the IDE back up and see if it stuck.  Even if it doesn't it shouldn't harm things.  The speed of the IDE is not related to the naming of files.  However when you open the designer it will verify the generated files are up to date and this can be time consuming if the files are missing or wrong.  But this shouldn't happen that often.  Still, opening model files has never been fast.

Michael Taylor - 7/7/2012
http://msmvps.com/blogs/p3net