Visual Studio not recognizing file after changing from erroneous extension - visual-studio

I've been struggling with this for a couple of hours and then I just fixed that.
Problem is, when I was creating another .cpp file I misspelled the extension with .cp and then I immediately changed that file back to .cpp with Visual Studio's rename file feature.
The linking just stopped working after that. It was saying to me that i have unresolved external. My .h file couldn't be linked with that .cpp file which I renamed from .cp.
Somehow, when I created the file with a wrong extension, VS remembered that and even after renaming that file back to the correct extension, it still didn't recognize it.
I fixed my problem by just creating a new .cpp file (this time without an error), and everything just started working.
Has anyone experienced that before? Someone probably knows but I have not found anything related to this problem yet.

If you acidentaly typed wrong extension when creating C++ file then to make VS treat it as C++ file you should right click on the file item in Solution Explorer, open Properties dialog and change Item type on General tab from does not participate in build to C++ compiler (or to C++ header if it suppose to be a header file).

Related

adding .dll file to visual studio, and open in the code

Hi I currently have a uni course in f#, where i need to use a .dll file that my professor made, in my code. In this picture, the parser.dll file has a red circle around it, and the current f# file has a blue:
Now the parser.dll is a parser that i need to pass some strings to, and get some output in my f# program.
My professor is for some reason able to acces this file by simply putting the parser.dll file in the current directory. When i do this in visual studio, the .dll file is hidden in the file explorer, and i am not ablue to acces it in the code either.
Now i could read some places that it could be a good idea to create references to it in the solution explorer>add>Reference>Browse, and try to find it on my machine (tried a few different locations), it is still hidden to me in the browse tool.
What is the best thing for me to do? and why is my dll file hidden from me when I attempt to add it using the "browse feature"?
Thank 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.

VS2010 Compile Error

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.

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.

Export Visual Studio Template error: "Unable to read an exported file"

When exporting a Visual Studio project to a Template (File/Export Template...) I get the following error upon clicking the Finish button:
Unable to read an exported file for the following
reason: The file cannot be opened with the selected
editor. Please choose another editor.
Screenshot http://img687.yfrog.com/img687/1756/templateerror.png
A Google search for this error has only led to several dead ends. There aren't any unusual file types in this project. Any ideas what could be going on?
By laborious trial and error (start with an empty project, add a folder, try to export template) I was able to narrow this down to a single Javascript file. As it happens, it's one of the language definitions for prettify.js (which is used on this site for code coloring). The file in question is lang-hs.js, and for some reason Windows on my machine treats this file differently from other Javascript files: It opens in Notepad, when I have the .js extension mapped to Visual Studio.
I'm not sure what the underlying explanation is, but I've already wasted enough time on this and I believe I can live without Haskell code coloring (!) so I'm just deleting this file and moving on.
It seems ".cur" files are often a culprit in this error. I have removed them from my project and now the exportation works correctly.
Microsoft staff suggest looking at log files (../windows/system32/compmgmt.msc) but this error does not spawn an entry into the Application EventLog.

Resources