What is the fastest/easiest way to do this? I don't want to recreate an application and I'm constantly needing to do this (Having hard time settling on a good name for my projects). What I've been doing it changing the name in the solution explorer and than closing the app. Than from there changing the name of the folders that the app is in, however when I go to reopen the solution has issues opening the MVC Project (still points to the previous name of the app & folder name). What am I not changing to prevent this and what could I be doing better?
Addition to above answers. Do not forget to rename the Assembly name.
Right Click at the project go to properties. In application tab, change the Assembly name and Default namespace. This is useful when you scaffold something in a project.
When I added new .edmx file, it would get old project name even though, I changed all the file names following above answers. Later found out, I had not changed the assembly name.
If you keep your name consistent throughout everything, the easiest would probably be a global textfile search-and-replace outside of Visual Studio, using a regular text editor. This will get your solution and project files, the things that regular refactoring will miss.
Something like Notepad++, or something similar would work well. You can do just your solution and project files, and other non-codefiles, from there - then a global search-and-replace of your code files from inside Visual Studio.
You'd have to manually rename the solution and project files and directories.
I find doing it with a text editor is safer than trying to do it all in Visual Studio, because you won't miss any of the funky little things like AssemblyInfo values, default namespaces, webservice references, things like that.
For starters, I would just keep the name of the app the same until you are ready for deployment.
To address your problem, you can right click the Solution in the Solution Explorer window and rename it to whatever you want it to be. Then whatever sub-folders you need to rename can be done similarly. You will also need to go to any file within the solution and next to the namespace, you will want to highlight the old project/folder name and refactor. This will allow you to change all references through out the entire project.
You will still need to reopen the solution next time as the location that the project is pointed to has changed and thus Visual Studio doesn't know where to look.
Related
I have a MVC5 project that is currently set on the "Release Configuration" and it works 100%. However, as soon as I switch the project configuration from Release to Debug, then everything goes wrong... even if I switch it back to Release mode, everything is still broken. Only way I can get the project working again is to restore from a backup.
Here are what is happening.
Firstly, when running the project, I get the following error:
BC30451: 'ViewData' is not declared. It may be inaccessible due to its
protection level.
If I open any view in the project with Visual Studio 2013, I can see that all sorts of things are marked as errors like ViewData, Html, Url, etc.
When referring to #Html or #ViewData in the view, it normally refers to the .Html and .ViewData properties of the view's base class (WebViewPage). However, if I start typing "#Html." in any of the views, I can see in the autocomplete that it is referring to the System.Web.Webpages.Html namespace instead of the WebViewPage.Html property. It is as-if the view isn't inheriting from the System.Web.Mvc.WebViewPage class.
Any guidance as to where I can start looking to get this fixed or why this is happening?
Edit:
So since nobody responded, I went through the long way. I created a brand new MVC5 project, added all the packages via Nuget and then simply copied all my files over from the old project to the new one and now it works.
Does anybody have any idea what the heck could be causing this? I don't want to go through all this trouble again in the future if the project again suddenly decides to stop working.
Ok, I think I've found part of the cause here. Thing is, since the original code is valid (it compiles correctly and intellisense picks it up) and the code used to work and then all of a sudden, one day after compiling, it just stops working.
Anyway, in the view, when specifying the ModelType, if you don't use the full name, this error can occur or occurs eventually.
For example, using:
#ModelType Models.SomeNamespace.SomeClass
will cause the error (even though the Root Namespace for the project is "MyProject") and it can be fixed by simply specifying the full namespace and class name.
#ModelType MyProject.Models.SomeNamespace.SomeClass
It's possible that a debug assembly is locked. Can close Visual Studio, search and delete for all bin folders in the solution directory. Then open and rebuild.
The other options is to go into the MVC project properties and compare the two build configurations. Are you targeting a different .NET framework between Release and Debug? 32 bit vs 64 bit? etc?
Looks like some MVC assemblies are corrupted.
Have you checked your referenced assemblies for some errors?
Try also cleaning all the .NET internal cache. More in this stackoverflow topic: Could not load file or assembly ... The parameter is incorrect
In my case imported ViewModel class name was incorrect, correcting it fixed the issue.
I'm having some kind of problem with my project that me and my friend is working on. When I try to open the project that I've been working on it gives me an error message saying that "one or more lines were too long and have been truncated" and thus I can't see my code or GUI. When my friend opens the project on his computer (The project is on dropbox so it's the same file) there's no problem at all. I've googled but couldn't find anything. I just did a repair of RAD Studio but no luck. We have 2 forms and a unit that we use, the unit and the mainform isn't working for me but the second form is no problem.
Thanks!
Make a copy of your project directory.
Search your harddisk for XXXX.pas and XXXX.dfm
Hopefully there will be some temperary files that match - like "mylostform.dfm.~1307~" . copy the newest to your project directory, and rename them to "mylostform.dfm" and "mylostform.pas".
Kind regards,
Geir Bratlie
From the comments, you have Dropbox, and the Restore functionality is available, but using it would cost you a week's worth of work.
If I was in that situation, here's what I would do:
Copy the current file to somewhere else (My Documents, for example).
Use Dropbox Restore to get the old version that works.
Make a copy of this, because you're going to be modifying it
Ensure that you can open it in the IDE.
Use Beyond Compare to open the two files side-by-side. (If you don't have this, you really should!)
If they're completely different from each other, you have a serious problem. If not, you'll see the changes you've made. Start copying changes one at a time, and after each change, save and try to open it in the IDE.
At some point, you won't be able to. That's where your problem lies. Now you can fix it!
In the MVC4 templates, many many (...many!) assemblies are added to a project, even for the "empty" template.
Which ones are really necessary, and what does each one actually do - I cannot find a list anywhere? I only want to reference the ones I need.
I created an "empty" project and started removing them one by one, but it gets tedious (and breaks) very quickly because of the associated web.config changes, etc.
Can't find anything official, but did manage to get a barebones project to run by using this answer.
Would still like to know what all the DLLs are for in the various templates.
If you are using ReSharper you can right-click the References folder and select either "Remove Unused References" or the safer option "Optimize References". The latter option gives you a report of which assemblies are and aren't used.
Be careful then using this in a mature solution where dependencies are injected as you might not have any direct code references to an assembly at compile time. But they could be required at runtime.
Sorry, I haven't answered your question directly, but hopefully I have shown you how to find out for yourself.
I have started using MonoDevelop for F# on a Mac. It's pretty cool, except for the fact that it crashes quite a lot. One thing that is bothering me is that I can't change the order of the F# source files in a project. Is this possible? It will make organising projects a bit of a nightmare if it isn't.
Yes, you can reorder files. There is a special tab for doing that in project options (under the build tab).
Unfortunatelly, this cannot be done using the file browser (because MonoDevelop automatically sorts files by file name and there is no way to disable it).
Assuming you're using MonoDevelop 4.x and a recent version of F# Binding, you can drag and drop to move files into a correct order (no shortcut key supported yet).
Here is the original issue and the pull request if you're interested in (big thanks to Dave Thomas for implementing this).
As a last resort, you can open fsproj files in a text editor and rearrange xml nodes corresponding to source files.
I have to stay away from my MacBook and will use Windows for a while. I missed Textmate's folder view when editing my rails projects. Is there an editor on Windows with the folder view? I know there is the E text editor. But I'll save a few bucks if there is a free (cheaper) alternative, as I won't stay in Windows for long ...
Go with gVim, and when editing a file you can type :edit. to pull up the working directory, and navigate from there. Also you get geek cred for rolling VI!
Have a look at Komodo Edit. Some people are already using it for Rails development.
Netbeans is full scale open-source ruby/rails-editor with a folder-view.
Programmer's Notepad is a very lightweigt open source text-editor, it has a "project"-view (but you have to define the project yourself).
The Zeus Lite programmer's editor has a folders view (i.e. View, Navigator menu) feature and it is also free.
Best one I just found.. "programmers notepad".. It's got different coloring for different languages. (though i always turn that off) and it allows you to map keys..
It also has a hand tree view where you can have "magic folders" that show all the files in a given folder. It is very sleek..
One irk.. to make it so you can have two projects open at the same time, you need to go to options and set the exe to allow multiple instances... I'd have rather seen that as default, but it's easy to fix.
Oh and it's free.
Not that you asked, but bluefish seems to be quite good on linux. Has a similar feel. It's a fast little editor.
emacs has speedbar, diredit mode, other option.
This is speedbar: