I am developing an app for Windows Phone 8 with C#
And I've been working alot with MessageBox.Show() , and All the time it used to show a PopUp message like i wanted , but then suddenly , it Won't show anything , I debugged the app , the code runs normally and compiles the Line MessageBox.Show("Something");
but it doesn't pop up !
I also tried to put it in another page , doesn't work too !
All i remember that yesterday I have messed with References of the Project
But is that the problem ?
Anyways here's a photo of the references of my Project
When you build a Windows Phone Project it automatically generates all the required dependencies for you. You should be able to in your class file and add the following using statement:
using System.Windows
Once you've done that you'll be able to implement the MessageBox class. If not, then you'll need to do the following:
Open Solution Explorer
Right Click Reference Folder
Add Reference
Go to Assemblies
Go to Browse
Navigate to: C:\Windows\Microsoft.Net\Assembly\GAC_MSIL\PresentationFramework
Reference PresentationFramework.dll
Once you've referenced that library, you'll be able to call: MessageBox.Show(#"Something"); without a single hiccup.
Solved!
1.) Restarted my computer
2.) Deleted the app from the phone
3.) Debug
I had a problem with MessageBox.Show() not working.
It happened on two different pieces of software: Kaxaml, and an example from the Troelsen C# book.
I troubleshot it by just using a simple string inside the Show() instead of the "Exception" delegate in different spots in the code, and that helped tell me that I had the right references. Obviously, if MessageBox worked in any place in the code at all, that told me I had the correct references.
Basically, what was happening was the Visual Studio debugger would fire before the catch-try blocks, preventing the MessageBox from ever appearing. When I used the Release version, there would be no MessageBox either though.
What solved it was by just turning off a little click-box that said on Visual Studio, something like, "Don't show this exception". Kind of odd that Visual Studio still fired off an exception error, even though it was in a catch-try block, but whatever, this worked for me.
Related
This is very strange. I have a custom UserControl called UIControl. That user control has another custom control (derived from Label control).
This worked OK for long time. Both at design time and at run time. However, now, I needed to edit that custom UIControl but the Visual Studio 2019 shows this error message:
This error means that the RealTime.DigitalClock is not found. As you see in the project, that control is not part of an external assembly, but the same assembly where UIControl is.
I have compiled and recompiled thousand of times and compilations finish perfectly. Even the application runs.
Furthermore, when I build the project, those user controls appear in tool box, but when I try to place it in any form, an error telling that the component could not be added and it will be removed from the tool box is shown.
I don't really know what is happening here. I have even closed and re-open VS 2019 but no avail.
Regards
Jaime
According to To prevent possible data loss in windows form c#, I suggest that you can do as the following steps.
First, Please find all the RealTime.DigitalClock related code in UIControl.designer and UIControl.cs.
Second, you can delete the above code.
Third, you need to rewrite the code you just deleted.
Finally, rebuild it and check if it works for you.
I have created a small program in C# WinForms that runs fine when I start it in Visual Studio 2017. But when I build the solution and double click the .exe, nothing happens, no screen appears, even the task manager doesn't see it. No errors. It's like it doesn't do anything! My only guess is that I built it wrong because I used Nuget to install newtonsofts JSON.NET in the solution. Do I need to do anything differently or should just building the solution work?
[solved]
today i learned the difference between the bin and obj folder, thanks to everyone for helping
Based on your comment:
it is in the obj/debug folder of the project
It sounds like you're running the wrong .exe. The obj folder is used for temporary/misc. files from the build process (see What is obj folder generated for?).
Instead, you want to run the exe within bin\Debug, if "Debug" is the configuration you're building for. You can see which configuration at the top of VS.
Like others have also mentioned, make sure that Newtonsoft.Json.dll is being copied to that output directory as well. Programs and their dependencies need to be together, generally speaking. Otherwise, your exe will not know where to find the JSON code it needs to function.
99% of the time, you should pretend the obj directory isn't even there.
If that still isn't pointing you in the right direction, run the app from a command window. Any exception should get printed to it and the window will remain open for you to examine (and this has the benefit of not needing any additional logging or exception handling code to see this error).
For example, I wrote up a bad application that get a NullReferenceException in a method called Test that is called from Main. As you can see, the stacktrace is easily visible, even though my app has crashed (credit to ColinM for bringing this up originally).
I believe that there's a problem with the startup module. Follow the steps below
Open your Solution in visual studio
Double click on properties
Select output type to Windows Application
Make sure to set the startup object as follows
I hope it helps
I think there is only one reason
There is a command line argument predefined in Visual Studio. Your application uses this argument to be executed, without it, it closes itself too quickly and you even can't see your application opened.
Right click on your project in VS -> Properties -> Debug and see if there is a value in command line arguments
exe and their supporting files should be in the bin folder. Do not copy only exe from bin folder and try to run it. It is a good idea to write some exception code to get the detail.
For future reference, yet another reason (that I have experienced) can be
System.Diagnostics.Debug.Assert();
statements. In my case, the program executed normally when started from VS but when I run it by clicking its .exe (created in the Debug Mode) then it hung/freezed. No exceptions, no printed logs. Frustrating. Then I checked the Windows Event Viewer (Our true friend). It explicitly displayed the problem and the culprit was a Debug.Assert() statement.
The lesson learned again: Check
Windows Event Viewer > Windows Logs > Application
especially when your app hangs/freezes/deadlocks or when no app logs are available.
I have created a vsix plugin for VS 2015 that receives some data of a REST-Service, writes it into a file and then it adds the file to my C# Project.
Well the problem is that after the files were written on the file system and integrated to the project my user input in visual studio is blocked:
e.g. I can write for example "asdf" in a code file, but when I try to delete the text with the backspace button it is not working. Other buttons like CTRL are also not working.
The interesting part is when I close VS2015 the following error appears:
The problem is definitly caused by this line:
project.ProjectItems.AddFromFile(filePath);
project is an EnvDTE.Project object! The thing is the files were added to my project but I have to kill and restart VS to continue with my work.
I have also found a little workaround: When I disable TFS in my project all is working fine!
So my conclusion is that the problem is caused by TFS!
Can anybody tell me what I can do, to solve this problem! It costs me a ton of time to restart VS every time!
When using TFS, you need to checkout the project for modification first, use SourceControl.CheckoutItem: https://msdn.microsoft.com/en-us/library/envdte.sourcecontrol.checkoutitem.aspx
The problem here is not what you are doing, but how. Some modal window you are opening it's been locked to the screen. Make sure you closed it correctly.
This behavior it's common when using modal. Try to figure it out what window you are opening and try change it from modal to not-modal.
It will stop this problem.
I can't seem to be able to debug. When I try to, I don't get any build errors, and the layout changes to debug mode, but the windows never pops up. I have an orange bar at the bottom of VS, which I think is standard, but nothing happens after that. It's not just in the project I'm working on. I have started a new WFA and tried to debug without adding any code and the same thing happens. Anybody have similar issues?
I've encountered this before. Not sure what causes it, but generally it is one of a couple of things to fix it.
make sure you are building in debug and not release
close VS, go to the project's dir and delete the obj and bin directories. Reopen in VS and rebuild.
there is an option under tools - options - build (iirc) that allows for checking if source is same as code file. However, you should see a message in output window if this is the case.
on the project properties in the build (iirc) you can throttle the pdb file from full debug symbols to no pdb at all. If you are not the only person on the project check this setting still has full pdb enabled (low probability this got changed though)
make sure you're on the right platform that you are building to (x64 vs x32)
...lots more, but a starting place...
Addendum as per comment...
So, those messages are good. It is saying there are no problems (but it sounds like you already know that :) ). I would start with the general debug options you mention. Do this on a hello world app. That way you can troubleshoot the lowest common first. Here are my settings. Try to match them and see if that works. For example, I know "ask before deleting breakpoint" is irrelevant, but "break all processes when one process breaks" is important. So, I just added them all to make it easier to troubleshoot.
ALso, make sure you are getting a red dot here like so in your code in visual studio (I've seen instances where VS won't let you put this here):
Right click on the project
Click on the properties.
go to web.
Check the Box for Enable Edit and Continue .
Hope that helps :)
This is an issue with visual studio 2012. It doesn't ALWAYS show up. I've found that if you stop your program during debugging, or if you close the console window, this will almost always trigger.
However, letting it run to completion isn't enough either, sometimes this just happens.
Also you can build your application in debug mode, go to the output, run the program, and attach to that process. :P
Amazing answers already given but they dont help in the purpose. So here is my finding, no matter if i am late in answering, but it really works for me.
Even if you are developing a web app, just go to the website properties by right-clicking the project and then you see a "Web" tab on left as i have highlighted. Then just check the box saying "Enable Edit and Continue". Thats all you need to do. it works for me!
I had a similar problem, and solution was absolutely dumb. VS was confused with two instances of Internet Explorer in “Browse with” setting. So, I set Google Chrome (any browser) as default, and then set IE as default again. It deleted the other instance of IE (only one remained) and debugging was enabled.
Hope it help!
I had a similar issue.
I added up:
using namespace std;
and this solved the problem
For me, uninstalling the Redgate's Reflector plugin that had expired fixed it. I spent more than 4 hours uninstalling, rebooting, reverting to older code, etc etc..
When my default browser was changed to CHROME, I could no longer debug my User Interface. Setting IE back to the default browser fixed it. Alternatively you can attach the process plug-in during debug.
I had the same problem with my desktop application and as this forum says you should mark your project as a startup project, since visual studio has unmarked. It worked just fine for me an I believe it will help other people that may have this problem, since I believe you have finished this project.
One of my VB .NET Winforms projects wouldn't allow debugging.
This was due to the configuration manager set to 'Release' even though the toolbar dropdown indicated 'Debug'.
You need to select the mode dropdown and select the last option 'Configuration Manager' and ensure that the main project is set to 'Debug' and not 'Release'
Install Microsoft SSDTSetup.exe 450Kb and Close the SSDT tool during install. After installation open the SSDT tool and execute the script task and Component with breakpoint. Worked for me
try checking your output without debugging
Ctrl + F5
good luck
I'm updating an old mobile device application for better flexibility. I had basically added the ability to configure the address of our SQL server in the case that we want to use our test server as opposed to our production server. I don't think this is causing the problem, but I wanted to state it. I also upgraded the project from a VS 2003 project to a VS 2005 project.
The issue I am having is that when I try to run the program in the VS emulator for Pocket PC, I get an error. It occurs after our "main menu" form loads and the user selects the next form to load. The form is initialized without issue, but when we try to run the .ShowDialog() method, it throws a System.MissingMethodException.
I don't have a lot of experience with the Compact Framework and really have no idea where to start looking for problems. I stepped the debugger through the entire initializing process for the new form and it ran without issue. But, again, when we come to the ShowDialog call, it throws the error.
Any ideas in where to start looking or known issues would be greatly appreciated.
I'm usually getting MissingMethodException for this reason:
I've got at least two files in my project, for instance an .exe file and a .dll file
I make changes to the .dll file's source code, and recompile
VS says it deploys the new .dll file to the device, but indeed it does not (it keeps the old file)
The .exe starts up fine, but when it starts accessing the .dll file the application throws a MissingMethodException, because it can't find the methods in the old dll file.
Fix: Delete the entire application directory from the device and redeploy.
I should have added this long ago. The answer ended up being that the incorrect version of .NET was installed on the Mobile Device.
A possible issue that can cause this situation is that the DLL is not being updated when deployed. It can be caused by the DLL in question being a dependency for more than one executable.
For example let's say executable A is running on the device and it is dependent on the DLL's method callA. You are trying to debug executable B which is also dependent on the DLL but on the method callB that you just added. When Visual Studio goes to deploy the DLL with callB in it, it is unable to do so because executable A is still using it. Visual Studio does not tell you that it was not successful in deploying the DLL. (Liar VS! ;)
To fix it, kill all the executables that depend on the DLL and then deploy it.
#Felix Alcala - You got an up vote from me. I would add this as a comment to your fix because it is directly related. Alas, I did not have the rep to do so. But, I want this answer to be public because I found it helpful
Start looking in the ShowDialog method itself. The error is slightly misleading - it's not ShowDialog which it can't find, but the JIT compiler is probably trying to compile ShowDialog, and throwing that exception (because ShowDialog is trying to call something it can't find). If ShowDialog is in a different assembly, then there may be something static that can't be initialized, which could similarly cause this - but start out looking in ShowDialog itself.
Because of this, one trick to finding the problem (if it isn't obvisou) is to reduce the code in ShowDialog until you find the line causing the problem. I'd start out commenting ALL the code, to confirm my hypothesis. If you no longer get the exception, try uncommenting about half of the remaining code at a time, etc.
You can get this exception when you try to use a regular WinForm class from a compact project.