C# Console Application failing to run - c#

I am using Visual Studio 2008 Express and I tried creating a simple console application to test it. When I try to compile it, it compiles fine, but when I try to run it, it complains about the absence of a manifest file. As far as I know, VStudio should create the manifest file automatically, but since it is a simple console application without any dependencies, I asked VS to create the application without a manifest. It didn't change a thing. It kept asking for a manifest file saying that the application was supposed to have one. I remembered old bugs from the vshost process from previous VS Express versions so I tried disabling it. When I did, the error message changed to say that the application failed to load properly and would be closed, both with the option to create a manifest or not. I am pretty sure it is some misconfiguration on VS Express on my part, but I couldn't really find where. Anyone had any similar problems?

I think you should just create the manifest file. It's like 30 seconds to set up and I'm sure you have wasted much more time by googling and trying to solve the issue.
Here's the MSDN article about assembly manifests (in .NET 3.5):
http://msdn.microsoft.com/en-us/library/1w45z383.aspx
EDIT & note for the person who downvoted this answer: This is a helpful answer, and I tell you why. When implementing software projects, sometimes we all make mistakes and waste a lot of time by trying do something in a way that just doesn't make sense. It is a very important engineering skill to be able to realize that "I'm doing it wrong" as early as possible and not try to force a non feasible solution.

Related

How to fix Error Code CS0433 in Visual Studio 2015

I have a friend who has made some code in visual studio. But when I run his code (after getting it with git), I get Error Code CS0433. The weird thing is another guy on our team can get the exact same code and run it just fine on his computer. Here is a screen shot of the errors:
CLICK HERE FOR A BIGGER PICTURE
What is even more weird, another friend working on a different branch also gets Error CS0433 when running his code. But I can get it and run it just fine on my computer.
I have tried a couple of things to no avail.
Rebuild the solution
Clean solution
Manually deleted bin and obj folders, then do a clean/rebuild
I looked around the web for a solution. I found some people with similar problems, but theirs are in ASP.NET and not .NET. See here and here.
I have also taken a look at the documentation at MSDN on error CS0433. But I'm a beginner find MSDN's explanations very cryptic...
Is there anyone who has an idea as to what is causing this problem and/or a solution on how I can fix it?
If you need additional information feel free to write a comment. I will supply it as fast as I can.
You have references to dotnetcore50, and system.dll. This is causing (I think) most of the problems.
Try removing all the dotnetcore50 references. Start with vanilla .NET and try and migrate to the core libraries slowly. This [blog.marcgravell.com/2015/11/… might help.

Remove GAC Dependency that does not appear in Prerequisites

This is so frustrating. For some reason I have added a dependency Microsoft.VisualStudio.Text.Logic into my application so when I deploy it, it gives me the typical "Unable to install or run the application. The application requires that assembly XXX be installed in the Global Assmebly Cache (GAC) first". No big deal.
So I went to the application files section and it doesn't show up. Then I checked my references and nothing shows up. As a last ditch effort I checked under the "Add References" panel and it's not there. For some reason my Build Server has it, but all my end users as well as my development machine do not. Is there anywhere that I can check as to what dependencies are required and remove them? I cant find any code in my application that would required this DLL.
I guess this question can be generalized as this: "What is the best way to find dependencies for a project to prevent new ones from being created"?
So i found a solution that probably doesnt directly solve it for most people, but it is something good to keep in mind. What i didnt realize was that the Visual Studio versions were different and for some reason the one on the build server was adding a bunch of dependencies (like 15). I solved the issue by updating the server to contain the same visual studio version as my development machine.

.NET C# App running good on Development PC but doesn't run on Production computer

So it's basically as stated in the title. I've created a WPF app in Visual Studio 2013 using some external libraries.
Application works flawlessly on my Development machine (Windows 8.1 x64 + Visual Studio 2013) but doesn't run at all on Production device (Tablet with Windows 8 (NOT 8.1)). App is developed under .NET 4.5, doesn't matter if I try to run Debug or Release version. The proccess just hangs a while and then closes without any errors or messages.
If anyone would know what to do or how to fix this I would be very happy.
Thanks in advance :).
The first thing too look up in this situation, would be the Windows event log. When a .NET application crashes badly, the .NET Runtime will log an event there.
Most of the time, these events will log the stack trace which lead to the crash. This will give you a hint as to what happened.
Such logs are found in the "Application" category, and the source name you need to look for is ".NET Runtime". Usually, there will be another entry with the source name "Application Error", but this one is much less likely to help you.
Another useful technique, is to add a Console.WriteLine call at the start of your program, in order to see if that line gets to run at all.
Depending on what you find using these techniques, you may also want to use tools such as Dependency Walker or ILSpy, as suggested by Mike Dinescu.
Most likely a binding error occurs at start-up but the production machine you're testing on is configured to silently report these errors and it doesn't display the typical dialog box that would inform you that the process crashed.
Don't fret though, that message would probably not help you too much anyway.
What you need to do is inspect the main executable with a tool that can generate a dependency tree and figure out which DLLs are missing. Most likely these will be native binaries, not managed. The usual suspects are the VC runtime, or MFC or ATL libraries but there could be others too. That's why you need to use a tool such as DependencyWalker or RedGate's Reflector to find all dependencies for the main executable.
It is because your external libraries are not compiled into final .exe file. So you either need to include them in the same folder or merge them into exe but this process can be quite tricky. Look for ILMerge. However it is way easier to just copy them with your exe file.

VS 2008 suddenly can't start debugging session

I am having great problems running the application in the debugger from Visual Studio 2008.
When I'm using vshost.exe, it says:
And when vshost.exe is turned of, it simply states:
Interesting thing about it is that when i do use vshost, debugger is actually started and breakpoint is hit on the first line of the Main().
I tried:
rebuilding the project(s)
removing .ncb, .suo, .user for the projects
repairing Visual Studio 2008
changing the build architecture for the project
... no help there...
Any experience in (trouble)shooting that?
More info: some projects DO work, and one that I have to work on, does not.
I have some ideas such as:
trying to create NEW project, add thing by thing to it and see at what point it will start to miss behave
work it other way around, delete project by item by item to see when it will (if it will) be working OK again.
EDIT (for google, as I see that there are many similar questions on the web):
Errors:
Error while trying to run project: Unable to start debugging.
and
Error while trying to run project: Unable to start program '....\PlayKontrol.exe'
Try upgrading your Visual Studio to Service pack 1, if you haven't already.
Did you restarted your computer? You never know how windows will react to that :).
Also be sure there aren't any keys stuck, like the ctrl or windows key.
Note that the key does not have to be visually stuck, it can be stuck for visual studio and not for the explorer.
The most common source of sudden problems like this is corruption of one of the data files that vs uses to cache information between builds.
You've tried a clean build, but this won't delete everything. A real clean build is: quit vs, delete bin, obj, debug, release folders, delete all generated files in the root - primarily ncb. Do the same for any locally built libraries that you're project references.
The easiest way to do this is if you have the code in source control, as you can rename away your entire code folder and then force a get of all the source.
You often need to do all of these things in one hit to clear the problem.
Less frequently, a reinstall of vs will sort things out (although this sounds unlikely in your case if it is only one project that breaks)
Also think carefully about anything you might have installed just prior to it failing... And remember that some install effects may not occur until the next reboot so it could be days ago. A particular cause of this are automatic windows updates and trial versions of things like the vs 11 beta.
You might try running the application from outside of VS, but have a line of code that looks like this: Debugger.Launch(); where you want your first breakpoint.

Visual Studio 2008 crashes when opening solutions in a TortiseSVN directory? How do I fix this?

I'm using TortiseSVN for my subversion client on a Windows Server 2008 box and I've got a folder with code checked out into it.
When I go to open the solution file that's under source control Visual Studio 2008 starts and before it can even finish loading the solution from what I can tell Visual Studio crashes. I'm trying to open a solution that has VB code in it. It gives no error messages or warnings. It's just gone.
I have checked the files and they all seem fine. The solution file seems fine when I look at it with a text editor.
This is also Visual Studio 2008 SP1 and I've got all the latest .NET service packs installed.
Has anyone else seen this before and know how to fix it?
Edit: I just did an SVN export to a new directory and it still crashes in the exported directory where there is no longer any SVN attached to it.
Additionally, it crashes EVERY time I try to open the project that came from SVN.
You should be looking at the solution file with an xml editor, at least then you will get some help for subtile flaw's in the formatting or something like that.
You can also submit feedback to Microsoft on the VIsual Studio Connect site, if the bug turns out to be real.
Some commonsense things todo however would be, goto your visual studio command prompt, start off with "devenv /ResetSettings", that often helps isolate any weirdo add-on or something lke that.
Also, try to build clean with msbuild or vcbuild, then build fully with either one (i.e. if vcbuild can not build your solution, use msbuild). That can help by laying out the symbols and such and maybe clear out some corrupted file or something.
You also may have .suo files from your subversion, those are binary files that do contain some settings, it's common for people to accidentially check them in, but they are usually better off being kept on a per-developer basis (not in the source tree). The /resetsettings will likely clear these out also, but you may want to make sure.
You can also double check the path's to all of the assemblies referenced, that your not going from a 32/64 bit host, and the CLR DLL's are in different path's now etc...
One last thing, if your really stuck, you can get a stack trace and debug the crash a bit ;), see where the fault is occuring and search that module online, your'll often find that somebody may have a specific solution.
Oh yeah, also, hooker's can be trickey. Don't trust them for a minute. Make sure you set tsvn's "only load in windows exlporer" option and configure it specifically for what folders on your system have local-svn working directories, this will greatly reduce the working set for their shell extension. On most any system, over time, one program or another (apple irw.exe or adobe pdf-preloader.exe sort's of ad-ware) will try to work it's way into your shell. You should try to make sure your dev box is rather clean from anything hook's, simular to what VladV was saying...
I had a similar problem and I fixed it and afterwards I wasn't quite sure how I managed it.
It basically involved going to the tools/options menu and setting the source control plugin to none. However, I obviously had to have had the solution open in Visual Studio if doing this was to fix the solution, but yet I thought the problem was I could not open the solution.
The only possible scenario would be if I was able to open the solution, but not open any of the projects inside it, hence able to change the source control settings immediately after opening the solution.
Does that make sense?
Try opening your solution and projects files in a text editor, and looking for anything strange.
I once heard of a similar problem: a solution contained SVN bindings created by AnkhSVN, but Visual Studio had no AnkhSVN installed, and failed to open the solution without giving any meaningful error information.

Categories

Resources