VS2010 Compile Error - visual-studio-2010

Apologies. I am sure I should know where to look to deal with this but I do not:
The error below has appeared in my solution. I am not aware of why.
The item
"obj\Release\ScruffyDuck.AirportDesignEditor.MainForm.resources" was
specified more than once in the "Resources" parameter. Duplicate
items are not supported by the "Resources" parameter. Airport Design
Editor
Perhaps someone would be kind enough to put me out of my misery and tell me where to look.
Thanks

OK I found it. I have no idea how it happened. However it might be useful for the future. MainForm has a number of files containing different parts of the class. The main part has all the designer code and so on. Somehow a .resx file got created on one of the partial class files along with an InitializeComponent() method. Removing the extra .resx file got as far as reporting the duplicate method and removing that allowed the solution to compile again. It seems that though the file names are different (the error was in MainForm.EventHandlers) the two resx files are treated as the same even though they have different names.
I am now getting some exceptions but at least I can get the code running in the debugger again.

I think you'll have to open your .csproj file, and look for that file name. It sounds like ScruffyDuck.AirportDesignEditor.MainForm.resources is appearing more than once. Just remove the duplicate node (.csproj files are just xml).

Just remove obj directory from HD manually.
Clear solution from Visual Studio (Right click on project in SolutionExplorer and select "Clear")
Rebuild solution.
Cause could be a fault of generated resource file, due some conflicts happened in your project.
Should work.
Regards.

Related

Why might VS2019's Go To Implementation be showing duplicate references?

The behaviour of the Go To Implementation function accessed from the editor context menu or by clicking Ctrl-F12 in Visual Studio has somehow changed in my installation of VS2019.
It used to be that when I used it with the cursor on a method name reference, it would jump directly to the method's implementation unless there were multiple implementations; then it would show them in the Find Symbol Results window.
But something has changed and now it always shows the Find Symbol Results window even if there is only a single implementation. Furthermore, it shows a duplicate of the single implementation or of each if there are more than one. The screenshot shows this where you can see that the same method definition is listed twice with the same Project, File, Line and Column details.
Does anyone have any idea why this might be happening? Could it be some incorrectly cached data causing this? Where might such data be cached? I have cleared my temp files, and deleted contents of folders named *cache in any C:\Users\xxxx\AppData\Local\Microsoft\VisualStudio\16.0* folders but this hasn't made a difference.
The duplication can be caused when there are more than one TargetFrameworks e.g.
<TargetFrameworks>net5.0;netstandard2.0</TargetFrameworks>

Why does my project continue to look for an obsolete subfolder?

I changed the name of a subfolder in my project from "SOs_Forms" to "SOs_Pages"
Now, though, on noticing that several places in my project still referred to the old "SOs_Forms" I changed those to the updated name. But now the project won't compile, saying "Cannot resolve symbol 'Bla'" and then offering, through intellisense, to let me add the reference to the old subfolder/namespace.
So now I have both "SOs_Forms" and "SOs_Pages" referenced throughout my project; it seems that either/both are accepted at times, but other times it must be SOs_Forms, which no longer exists!
The odd thing about it being, if I acquiesce and allow the "old" subfolder namespace ("SOs_Forms") to be added so that the project will compile, and then right-click the formerly recalcitrant object name and select "Go to Declaration," it pops up "in \SOs_Pages" for both the xaml and the xaml.cs file. IOW, it knows it lives in "SOs_Pages" and yet forces me to add a reference to "SOs_Forms" so that it can be found...weird!
How can I tell the project once and for all that SOs_Forms is gone and is not coming back?
If you do a global find and replace you should resolve this issue (I have had to do it a few times).
Firstly before you do anything like this ideally you should have your code source controlled, and checked in so you can easily un-do it. If you don't have a source control system then stop everything and get one, seriously. (but if you can't at least take a copy of your code as it is and place it somewhere safe)
Now go to edit, find and replace, replace in files. Now type in the old namespace, then the new namespace. Then hit the go button.
That should solve it for you.

Xap packaging failed. Object reference not set to an instance of an object

I'm getting this error message on my PC when I try to build my Windows Phone app:
Xap packaging failed. Object reference not set to an instance of an object
I'm using Dropbox. On my laptop, It works perfectly fine and I can debug etc...On my PC however, I can't.
I tried many things such as:
Delete obj/Debug Folder
Check for files which are missing on the Solution Explorer
So far, nothing has helped.
Any idea how I can fix this?
You should check, in every folder of your project, for missing files or wrong references.
You can get this problem just with a single missing image, if its Build Action property is set to Content or similar...
Check your files and then Rebuild your project!
This can happen if a file is removed from the disk itself, but not from the Solution through Visual Studio. Delete the file through Visual Studio (it should be marked with a little yellow hazard icon) and Rebuild.
Credit to Andreas Hammar via http://blog.jayway.com/2011/06/03/wp7-build-error-xap-packaging-failed/ - his solution worked for me.
I am adding this reply because although the problem with app icons is covered in brief in some of the answers above, I wanted to give exact steps since it just happened to me. I got this error and then found this web page:
Xap Packaging Error
It turned out that my App icon file name was wrong due to a rename. I double-clicked on WMAppManifest.xml, found in the Properties folder, to open the editor for that file. I simply used the button to update the App Icon, re-found the file and selected it, and the error went away after rebuilding the project.
The problem lies in your startup object in your Application. I have met this error to many times.
It usually happens when I change the name of my class/namespace Application class. Or it might even be conflicting with your dropbox locations.
To Fix this.
Right click your main project or Alt+Enter
Go to the silverlight tab and set your startup object
Try the following:
Have Visual Studio closed
Download all your files to your computer
Delete Bin and obj folders completely.
Open the .sln
Rebuild
If if fails expand the References in te Solution explorer and make sure all your dll's are found. If a dll have a yellow exclamation point that means its not found. I'm thinking that one of your references are set to an absolute path on your laptop and that's missing on your PC.
If someone comes across this post and still has the issue I had where XAP packaging failed and that VS2012 can not find the file then check for spaces in the file name.
I had the issue where my tiles were "tilename 99.png" and it keep giving me the XAP packaging failed message. So I finally changed the file name to "tilename_99.png" and it worked.
Hope this helps someone in the same predicament.
In my case, I'd accidentally moved Background.png to a resource folder. Moved it back and it worked!
In my case, this error didn't go away even after trying all the above methods. Actually I had renamed the ApplicationIcon.png to "xyz.png". And reverting this, fixed the issue.
One more possibility is that you have a wrong path to an image in the project/options/Application dialog (icon, bg image, etc).
I had this error message, after some frustration I look in the obj folder, is was no part of the solution(but visual studio need it) but I had some conflicts files with dropbox. I deleted the obj folder rebuild, visual studio recreates the folder and the content of it and problem solved.
Ahh finally found my problem.
I'm using Visual Studio 2012, which doesn't always point out the "missing" file and makes it a little harder to fix.
MY SHORT SOLUTION
Relink the "linked" configuration file in the main project. It is a linked file because the original file remains in a referenced assembly, not in the current assembly. The file wasn't marked YELLOW so it wasn't obvious that it would be the problem, but when I double clicked on it, it failed to open, so I knew this was the problem file.
The silverlight application itself had a "linked" file called "ServiceReferences.ClientConfig" which contains information needed by a referenced project to make a web service call.
So the main project didn't have the web service reference itself, but it referenced a project which did, which is why it linked the "ServiceReferences.ClientConfig" file.
MY LONG SOLUTION
Keep rebuilding the main project file, and commenting out, and excluding project by project, file by file, until you CAN build the main project again. At that point it should be clear(er) which part of the solution is causing the problem.

Word files disappear from "Solution Items" in VS2010

I've run into a problem with VS2010 (it also exists in the latest version, SP1 (10.0.40219.1)):
Add an existing Word file to the "Solution Items" and check this new file in.
Check the file out for editing
Double click on the file and edit it in Word (just make some minor changes)
Save the file (CTRL-S)
Now the file is removed from the "Solution Items" in Visual Studio (you may have to repeat the editing and saving a couple of times)
Update: I'm using Visual SourceSafe 2005.
Despite my research efforts I haven't really found anything on this issue apart from this Microsoft page, and I'd like to know whether there is a way to prevent this problem from happening.
Any ideas are more than welcome, thanks in advance.
G.
After further investigation I think I found the reason behind this behaviour and a workaround.
Please also note that the behaviour described in the original question only occurs for files that are added directly underneath a solution or to a folder that is directly underneath a solution.
The reason
I'm not sure whether the following is 100% correct, but the main point is how Word (and probably other MS Office apps as well) saves an existing file:
Save the current version of the file to a temporary file
Rename the original file so it can be used later in case something goes wrong
Copy the temporary file to the location of the original file, using the original file's name
Delete the original file (that was renamed in step 2)
Visual Studio picks up that the file doesn't exist (for a very short time though) and removes it from its tree and the .sln file. This can also be reproduced by manually adding any kind of file, checking it out (if not checked out), renaming it to a different name and then back to its original name => file is no longer shown in Visual Studio.
The workaround
I've created an empty project template following the steps on Microsoft's site. I also set the output to "Class Library" so that the project would compile even if no static main method exists. This template can be used to add a "Documentation" project to an existing solution. Underneath this project you can add files and edit them as you wish, as Visual Studio behaves differently and does not remove the file when it is saved in this constellation.
Obviously this approach is still not very satisfying or elegant, but I hope that it may be helpful for others who might run into the same problem.
G.
I've run into the same issue. I simply undo changes for the solution after I've closed the document file and the solution files will be as they originally were before your document changes.

Why does my T4 template append a number to the file name?

Why do my T4 templates sometimes append a number to the output file and sometimes not? For instance, in one case I might have a template file called Foo.tt and I'll get an output file of Foo.cs. In other cases, I'll get an output file of Foo1.cs. In every case, there is no other Foo.cs file that might be causing it to append a number. In other words, it is definitely not the result of any obvious file name conflict.
I'm a deeply anal retentive developer, so I'd sure love to know how to get rid of that useless numeric suffix.
This happens when Visual Studio gets itself confused and briefly decides that it can't use Foo.cs as the output for some reason (usually hallucinatory), so it will use Foo1.cs instead, and then insists on remembering this setting.
The fix is to open the .csproj file in a text editor and locate the Foo.tt entry. This should have a sub-element called LastGenOutput. Change this back to Foo.cs, save the project file, and reopen it in VS.
And then -- sigh -- wait for it to happen again. You can see http://social.msdn.microsoft.com/Forums/en/linqtosql/thread/0c0f77a6-d712-43d2-a990-555df7960123 for more details, though nobody seems to be able to explain what causes VS to get into this state or how to stop it doing so...
#itowlson's answer really helped me out, but I discovered a slightly simpler workaround that I thought I'd share.
If you have:
Filename.tt
└── Filename1.cs
Just rename Filename.tt to Filename2.tt:
Filename2.tt
└── Filename2.cs
And back to Filename.tt again:
Filename.tt
└── Filename.cs
Voilà.
I've discovered something in VS2019 that might explain one potential cause of the issue.
In the CSPROJ file, VS expects a TT file be included using <Content Include="Generator.tt"> tags. When adding a TT file to a project via Cut/Copy/Paste using the contextual menu items in the interface built into VS, VS may sometimes use the wrong XML tag, such as <None Update="Generator.tt">. This will be despite the fact that if you open the Property sheet for the TT file, it will show 'Content' as the build action.
Open the CSPROJ file, and if you change the <None> tag to <Content> and also the Update attribute to Include, then restart VS, the issue appears to go away.

Resources