I have created a windows form application.
Few days ago I started making it look better by changing icons and images.
But the changes do not appear on my form. (imagelist and program logo .ico)
I have built/cleaned my application several times.
Is there something else I should clean?
Please make sure that in the solution's properties the project is actually marked for build. You can - for every project in the solution - check a box saying whether the project should actually be built or not.
Make sure you are compiling to Debug and not Release
Make sure you have the same platform (x86, x64, Any CPU) than before.
If still problems:
Clean solution
Delete bin and obj folders.
Rebuild
Also, its a good practice to have images and icons in resources. If you don't you can give it a try.
Update
Are you sure the app is compiling? You might have said to run even with errors and checked to not ask you again. Go to View menu -> Error list and see if there is any compiling error.
Any resources ( image files for example) must be added to the project and marked as copy to output folder ( always ) there is the option to copy if newer but since this is dependant on time stamps the first choice is more reliable.
Without this associated resource files will not end up in your build output folder.
Related
Hello there, Stackoverflow.
Recently, when I've been programming in Visual Studio 2010, I've been getting the problem with VS locking the bin/Debug/(ProjectName).exe file when trying to build and gives me the error below after trying to build the project 10 times:
Unable to copy file "obj\x86\Debug\TileEngine.exe" to "bin\x86\Debug\TileEngine.exe". The process cannot access the file 'bin\x86\Debug\TileEngine.exe' becuase it is being used by another process.
The problem appears when I edit the source and then try to Debug.
I've checked using different programs, and the only program using the file is Visual Studio.
If I wait for about 10 minutes before trying to build, it seems to work properly, but when trying different things, it isn't good needing to wait 10 minutes before trying something.
I've tried different solutions both on this site as well as everywhere I can find on Google.
Some solutions I've found, but haven't worked for me
Solution 1 - Using a pre-build script
In some different questions here on Stackoverflow, I've found one solution being that you go into Project Properties > Build Events and then in the Pre-build event command line add:
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
This made it possible for me to build the project one more time than I usually could, but when editing the code again, and then building, the same error appeared.
Note: Trying to build a release instead of a debug build seems to break the pre-build script and it exits with the code '1', which seems to make VS unable to build properly. Removing the pre-build script makes it work like "normal" again, still with the same error though.
Solution 2 - Running Visual Studio as Administrator
This is another solution I've found, but havent worked either for me, so I assume that Visual Studio already have all the permissions required and running as Administrator doesn't actually make any difference.
Solution 3 - Changing the AssemblyVersion
In this question, Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug, I found another solution that included changing the AssemblyVersion, in the Properties\AssemblyInfo.cs file, to "2.0.0.0".
This, however, haven't made any difference whatsoever for me.
Solution 4 - Closing UserControl designers before building
According to some different answers here and there on the Internet, Visual Studio apparently uses the built project executable to render the UserControl designer(?). In my case, this is probably not it, though, since I use XNA mostly and it doesn't use the UserControl designer.
Solution 5 - Cleaning up resources when application quits
This might be a solution that I have failed to implement properly. I'm just thinking though, that if this is the solution, how come I haven't been required to do it before. I assume XNA unloads everything that gets loaded through the Content pipeline, therefore this solution wouldn't' make any real sense.
If there is anyone that is able to spread some light on this issue, it would be really awesome, as it is stopping me from programming anything really, because I don't like waiting for 10 minutes because I've made a 2 second change all the time.
I've run into this problem a few times myself.
Mine might not be from the same cause as yours, but I'll tell you what went wrong with me and how I fixed it, hopefully it'll be helpful to you.
Basically, my program never fully exited properly, even when it appeared to. It would continue to run, and thus continue to lock down the file.
A quick dirty fix I used initially (and a way to prove if this is the case) is:
Open Task Manager (Ctrl-Alt-Del)
Click Processes tab
Look for your program's name (TileEngine.exe)
Note: There will probably be name_vshost.exe (TileEngine_vshost.exe) That's a VisualStudio thing, ignore that, it's not relevant.
If you find it, it means your program hasn't actual exited fully.
If it's there, click on it and press "End Process"
So if it's there, then for some reason, your program didn't shut down, like mine did.
Often, this is from a thread being launched and forgotten, or an Async task that never completes, or something like that.
Make sure in your OnExiting(..) void function that you kill all running threads.
If your program is still running despite best attempts to close all threads and other blockers, you can use the very dirty bad method:
In OnExiting(...) run the code "System.Diagnostics.Process.GetCurrentProcess().Kill();" - this will taskmanager-style forceshutdown the current process... this is only as an emergency I-can't-make-it-work-any-other-way method.
I think I found the solution myself.
In the Project Properties, "Enable the Visual Studio hosting process" wasn't checked. Checking it seems to have fixed the problems, at least for now.
Got reminded of it from mcmonkey4eva's post. So thanks for that =)
And thanks for the other replied I've got. Stackoverflow is awesome!
Have you checked if any files are being blocked by your firewall? When I switched to the full version of Avast I find I have to disable the File System Shield It loves to remove my executable files when I try to run my visual studio projects.
I had problems when upgrading to VS2012 Professional. (SDK, .Net, Visual C++ Redistributable package)
ENSURE ALL OF THESE ARE COMPATIBLE WITH THE CURRENT VERSION OF VS YOU ARE USING
What I did, was I ended up uninstalling EVERYTHING that was associated with both Visual Studio downloads. If you are able to remove and save your project files elsewhere and then bring them back. Go through all your program files to see if there is anything hidden in the wrong folder and check your C drive.
Which meant downloading and reinstalling (fresh):
I think if you clean out your program files, it should be ok. I wouldn't recommend going into your register unless you are very sure of what you are doing. IF you have already made changes to the register then we'll have a look at that and other options (if this doesn't solve your problem).
Try removing the readonly check from your solution by unchecking at the folder level.
I ran into this problem and in my case was due to having bin included in the solution; as soon as I excluded the bin folder from my solution the problem went away.
Nothing helped, not prebuild commands, neither designers closing, but I figured out a way that helped me, just changing from debug to release and vice-versa releases locked files and you can delete them without closing the IDE.
I regularly get this problem if I switch from Debug to Release and then immediately F5 to compile. Crazy as it sounds, waiting for, say, one minute after switching between modes will prevent this.
If it's locked, the only solution is to close Visual Studio and re-open.
I solved this problem organizing my resources on solution. I noticed this error when I put some images on my application at the same solution folder.
So,
I'd removed all images and resources from app, save without it.
Moved the images to outside Solution folder.
Open the solution and add this images again, using "Import" button at controls.
If you will try this, remember to do with Application Icon, on Project Settings.
Now, everything is working fine for me.
I hope it helps.
You need to disable Windows Indexer as it locks up the file
Follow this Guide how to disable
In my case the problem seem to be caused by the remote debugger. It starts on local machine when you compile with "x64" option. Try to change the project setting (properties/buid) until you reach the final version.
Change Build Platform target from x86 to Any CPU.
This question is NOT answered at the link above...
I had some problems with TFS where visual studio builds on the local machine no problem, but when I try to build on the server I get build errors. The errors are not relevant to this question.
The issue I have is that in order to fix the errors I had to manually edit some of the files on my local machine, and since they were manually edited, TFS doesn't detect the change so it wont let me upload my change set to the server which would have fixed the problems there.
My first, and main question is:
How can I force TFS to copy all my local files to the server. Sort of like the reverse of the whole:
Goto View / Other Windows / Source Control Explorer / Right click on the relevant project / Advanced / Get specific version / Check "Overwrite all files..." / Press ok.
Which (arguably, cause it doesn't always get everything in my experience) gets a full file set from the server to the local machine.
I am so tired of TFS uploading partial file sets and then when the solution is removed locally, and then re downloaded from the server, I have to pull in the missing files and references from some backup. If it was uploaded fully, and correctly at the start, I would probably have less of these problems. So this is my main question. How do I force TFS to upload all my files regardless if they have changed or not according to it.
To explain further a problem I am having in particular with nuget package manager. I disabled the option "Allow NuGet to download missing packages during build". So locally I got actual build errors. Yes that's right, Build errors. like this...
Project XXX: Package restore is disabled by default. To give consent,
open the Visual Studio Options dialog, click on Package Manager node
and check 'Allow NuGet to download missing packages during build.' You
can also give consent by setting the environment variable
'EnableNuGetPackageRestore' to 'true'.
Which now forces me to re-enable this option to get rid of the errors. I am annoyed at this because such errors should be presented as warnings so as not to prevent a build. This is seriously disappointing and as a result I have a very poor opinion of NuGet.
Anyways enough ranting, I re-enabled this, not like I had a choice. But the version where this was disabled went up to the server. Now I get this error on the server. I tried re-enabling it and doing a check in, but TFS wont let me. (Warning...No pending changes). Of course not, its just a silly check box. What could possibly have changed. But now I get an error on the server that I cannot fix all because someone at NuGet didn't put some taught into properly designing their warnings (as opposed to preventing a build by causing errors).
So, once again, how can I force TFS to take all my files, changed or unchanged, verbatim, to the server. This way, when I fix a problem locally, it "should" fix it also on the server. Or at least, when I next download it, I am assured to have the whole file set.
Apologies if this sounds like I am being negative, but I am at this for 5 solid days and it has completely stopped development costing me and the company a lot of money. Any help would be very much appreciated.
There is no way to tell TFS to take everything in my file system. What you need to do is a multistep process. First Check Out the entire directory, this will not overwrite your manual changes but will allow you to check back in and have it detect those changes. Second, if any new files were created you need to add at the root directory and get all new adds. Lastly check in all of your changes. It really should be that simple.
If you are using TFS 2012, then Local Workspaces would be a good solution for you.
Just to be clear - Local Workspaces does not mean that your developers are working locally. All code is still under Source Control in exactly the same way with Server Workspaces.
Local Workspaces are new to TFS 2012 and would resolve your issue. The main advantage for you is that files are no longer marked read-only. This allows you to be able to edit them from anywhere (notepad, any other IDE, Visual Studio) without first doing a checkout. Visual Studio will then automatically detect that the file has changed and list it in the Pending Changes window.
Good article comparing the different types of workspaces: http://blogs.msdn.com/b/willy-peter_schaub/archive/2011/11/30/team-foundation-server-trying-to-understand-server-versus-local-workspaces.aspx
I like to use the Source Control Explorer window, then right click on a folder and choose Compare. You can choose to see what is different in the target folder, or what is a new file. The files that are different appear in red. You can then right click on them and check out and check in files, or use control-click to select more than one file at time.
Yes i know before the flames start to arise, this is not conventional....but working in unity I encounter this problem quite often. Literally dealing with it now as i updated to unity 5.5 and it fubared a lot of stuff in my current project. After the resolutions from unity, my project is completely out of sync... and for whatever reason vis stu refuses to monitor these changes... It is rather annoying to be sure, but not to worry as I have resolved it successfully every time over the iterations by doing the following:
create a backup folder in a separate location and copy the entire thing over.
It doesn't matter where you back up to as long as its in a unique separate folder. Be sure to copy FOLDERS not individual FILES as some files may be hidden.
do a full get of the latest version (according to TFS).
This can take some time and is why you back it up in a separate location. Be sure to KEEP VS OPEN AT THIS POINT!!!
overwrite ALL the files you "got" with the backup that you made in step 1.
The local work-space will monitor the changes to the files as you overwrite them with the backed up copy into your local space, and mark them as having pending changes accordingly if the new one has any difference.
update your pending changes to the TFS server in source control explorer. Any change detected during the overwrite will be added to the included changes section.
Voila you have forced your files, work, and will onto the TFS server!
I'll give you 2 versions of my problem to describe it, first the short version.
When I try to build my application it does that perfectly and my app works but when I try to rebuild it, that fails and gives an error message saying that 2 files are missing (bin/debug/MusicPlayer.exe and bin/debug/MusicPlayer.pdb). When I then try to build normally, it fails to with the same error.
Now the longer version:
The way this happened was quite out of nowhere, I program on 2 different locations (both in Visual Studio 2010 sp1) but to always have the recent version in the right place I copy the entire solution folder to a usb stick, this folder I copy over again on the other PC and use it to continue were I left off, I've done this many times without problem. Yesterday however, I got an exception while testing the app. But instead of showing this in my code, it was complaining that it could not find the program.cs file (it was there, but apparently it had a different checksum (md5) and it asked me to use this one. After a while I found what part of my code caused the exception and fixed it. Since then I haven't got that error anymore. But when I later tried to rebuild instead of build, it gave me the error described in the short version. I have tried to fix it, but apparently I was not very successful.
Basically, what I think it does is delete the files in the debug folder that need rebuilding and then gives me the error of missing files (the files that it deleted) and thus failing to rebuild succesfully because these deleted files the normal build option won't work to.
(What I then do is re-copy them from my usb to make the normal build work).
Don't know if it's important, but I program in C# and I'm still learning.
Also when I copied it to my usb I believe I had no errors and the app was working fine (except the part I fixed later, which I could not test at that location). And when I build the entire solution it gives some warning ==> "Assembly 'bun/debug/MusicPlayer.exe' is incorrectly specified as file" and this for 5 files.
Does anyone know how to fix this rebuild problem and if necessary the warnings?
Thanks in advance
(and sorry for my bad English)
OK it seems like you might be confusing yourself with your directory structure here. If you want to add Content or Resources (Images, Text Files, etc.) you should place them in a folder within your project (not called bin or obj). All your build files will go here. Instead place the Content in another folder and Right Click -> Properties and Set the build action to "Content" or "Resource" and set the Copy to Output Directory (bin folder) to "Do not Copy" or "Copy if newer."
The project is failing because you have the built executable "MusicPlayer.exe" in your project. So Visual Studio is trying to build an executable file in adding to the project. Restructure your directories or remove "MusicPlayer.exe" ever time your build your project.
Do you have any anti-virus software running? They can go way too aggressive on removable drives. You are actually continuously deleting and creating a runnable program on usb stick by recompiling.
Just a guess tho...
Sounds to me like you have a pre- or post-build event with a hardcoded path in it. Fix that using variables and it should be ok.
This is happening to me very often. When I am working in Visual Studio 2010 and say I make a code change, then build... Both my existing breakpoints become disabled / and or cannot be set and I also cannot set new breakpoints. Does anyone have a solution for this? It is very annoying. So far the only way I have been able to get around this is to restart Visual Studio which can take 5 to 8 minutes to reindex everything or to try rebuilding individual projects in my solution. My solution consists of several DLLs which make up the entire program.
Check that you have the dependencies set correctly in your projects. I know my breakpoints will become disabled if the code is "out of date". If you don't have the dependencies set up right, then when the updated code is rebuilt it will not rebuild all of the related code which will then leave those modules "out of date".
Since this is VS 2010, the dependencies are on the project not on the solution (you can add solution dependencies, but project dependencies will carry over into a new solution so it is the better way to go when possible).
This issue is caused when you having your Configuration Manager settings set to Release rather than Debug.
In Visual Studios select Build from the menu, then Configuration Manager.
In the next dialog select your project, then locate the drop down menu near the top left corner titled "Active solution configuration:" Make sure it is set to Debug.
That should fix the problem.
As it turns out the post.build file contained numerous conditions for whether or not it should copy several DLLs to a target directory... Since I didn't have time to pick through the xml for these actions I just used a bash script to copy the files after building. No need to get complicated... Otherwise, the formal solution involves setting conditions for allowing the DLLs to be overwritten/copied after compile or not.
I find the Visual Studio post.build file concept a little excessive since in the end it will make little difference whether a dll is overwritten with a freshly compiled version, yet, if you make code changes, compile, and it doesn't copy to the target directory you end up running your app with an out of date DLL and you are not testing with the recent code change..! Others have even implemented the post.build file complete with xml and goto statements...! Leave it to Microsoft to complicate the build & debug process...
Alternatively, if your code is under version control start afresh by checking out the head revision, do another clean and rebuild and start debugging again.
This for whatever reason enabled me to insert breakpoints in my VS 2010 C# project once again, whereas no amount of fannying around with properties, configurations etc got rid of my phantom breakpoint problem.
The best solution I found for this was to quit my Windows job and get another job as a Mac Developer where we use Xcode.! What a huge difference.! I sure haven't seen that breakpoints problem again.!
After converting my project into VS2010, everything looks fine ( gui, etc..), but i can't build it because of this error. When i double click on the error it leads me to the resource file but doesn't show me where the problem is.
Object reference not set to an instance of an object. -Resources.resx
My project works fine on VS2008, was built on .net 2.0 , does any one know how to fix this ?
Thanks
In my case this happened after copying a form from one project to another.
It seems VS lost the reference to one of the local resource images.
Re-adding the image fixed the issue.
Well, something got messed up, but without bashing your head around it too much:
Use row headers to select all rows in the resources file.
Copy the selected content to Notepad.
Delete the resources file in Visual Studio.
Create a new resources file with the exact name.
Copy/paste the content from Notepad back to the resources file.
That should do the trick. This only works with string resources. If you have other types of resources, I am afraid that simple copy/paste will not be as simple. Either way, I think that recreating the resources file is the easiest solution.
Principle: "Don't know, don't care. Just make it work" :)
I had the same issue when copying a windows form from one project to another. After some research I found that it was due to the version of the .Net Framework.
Make sure that the project where the resx file sits is the correct version. If you copied it from Project A to Project B, make sure that the .Net version of Project B is the SAME as Project A.
See http://www.codeease.com/object-reference-not-set-to-an-instance-of-an-object-in-resx-resource-file.html
Hope it helps you
I was moving project from XP 32 bit machine to 64 bit Win 7 machine. The project was Framework 2.0
In my case easy fix. In the resx file change all the Version=4.0.0.0 to Version=2.0.0.0
I got this problem when I worked from a network resource, even though I had write/read access too it. When I moved the files to a local folder, it started to work.
Something that often worked for me was modifying the resource files like this:
1. Go to the resource in design view and copy all the string entries.
2. Delete all the entries from the design view and save.
3. Go to the code view and remove the data entries/nodes (they were not removed on my machine, even though I removed them from the design view).
4. Rebuild the project.
5. Go to the design view and paste the entries you previously copied and save.
6. Rebuild and it should work.
Unfortunately my answer won't really help you, but is consistent with the ones above.
The errors (seemingly) spontaneously went away.
Here's some other info that might help... (I had two of these errors)
My scenario was I initially developed on VSexpress2010, 32bit XP. Recently upgraded to Win7 64bit. (clean install, bring all my code back in now...)
It seems this error is usually thrown by trying to reference some null object (I've lost the reference). So I tried this even though my code was working previously... No luck, but after I removed the new 'fix' code, the error for that object was gone. Just played around with the file.
I came across this page too http://www.codeease.com/object-reference-not-set-to-an-instance-of-an-object-in-resx-resource-file.html .
I searched my remaining resx, but had "Version=2.0.0.0". Anyway, after the search, I debugged and it's gone.
Short answer: It's like magnets, how the F##k do they work? Just play around with your file, and keep debugging... hopefully eventually it'll work.
recreate the resource file copy/pasting (assuming it's text)
make some edits in your file. save. remove the edits. save again.
search around the file.
chances are it's not your code, and some mystery VSbug.
Good luck.
+1 #Boris's answer because it really is a case of
"Don't know, don't care. Just make it work" :)
In my case I convert my project from framwork 4.0 to 2.0 and also copy a Form .cs file and Designer file after that I am getting same error.
But as I delete the .resx
The error gone.
Please try to delete .resx may it help you!
Problem occurred after an unspecified crash of VS-2010 which apparently corrupted the project.
The RESX file was not changed at all (as determined from a backup copy of the project). There seemed to be invalid references in the VSPROJ file. I was not sure how to correct them by direct edits.
As per "Rohan" in 2012. I removed a background image from a form and the problem went away.
In my case, the problem arose when I copied the project to a new location. The problem was solved when I copied all the resx files from the original project, after verifying that the project compiled fine, and pasting them into the folder of the project that had issues. Clearly, a corruption issue that seems to be common when copying projects to new locations.