简体   繁体   中英

MessageBox.Show not working at all

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:

  1. Open Solution Explorer
  2. Right Click Reference Folder
  3. Add Reference
  4. Go to Assemblies
  5. Go to Browse
  6. Navigate to: C:\\Windows\\Microsoft.Net\\Assembly\\GAC_MSIL\\PresentationFramework
  7. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM