I was building an app to show a picture then play a sound when tapped in WP7. I get the "If the access level of a method in a class library has changed, recompile any assemblies that reference the library." error when I compile, pointing at Main. Well Actually at "Attempt to access the method failed: System.IO.Directory.GetFiles(System.String). This may be due to porting it to WP7 whole from WinCE, but I am not sure.
This app is dirt simple (see code below), so I am having a hard time figuring out what has the wrong permissions. Have I made some fundamental error (I mean besides not making functions instead of copy-pasting functionality) ? Google is unhelpful, and Microsoft is AMAZINGLY unhelpful.
I apologize now for the length of code, but since I'm not sure what I am looking for I don't know how to reduce it to the "target" code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.IO;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework;
namespace KanaFlash_WP7
{
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
string[] files = System.IO.Directory.GetFiles("*.png");
Random random = new Random();
int randomNumber = random.Next(0, files.Length);
string picturefilename = files[randomNumber];
BitmapImage bt = new BitmapImage();
bt.UriSource = new Uri(picturefilename, UriKind.Absolute);
image1.Source = bt;
string soundfilename = System.IO.Path.GetFileNameWithoutExtension(picturefilename);
soundfilename = soundfilename.ToLower();
soundfilename = soundfilename.Replace("_", "");
btnEnglish.Content = soundfilename;
soundfilename = soundfilename + ".wav";
}
bool silencer = false;
string[] files = System.IO.Directory.GetFiles("*.png");
private void image1_ImageFailed(object sender, GestureEventArgs e)
{
}
public void PlayNewFile(string media)
{
var stream = TitleContainer.OpenStream(media);
var effect = SoundEffect.FromStream(stream);
effect.Play();
}
public void GestureListener_Tap(object sender, GestureEventArgs e)
{
Random random = new Random();
int randomNumber = random.Next(0, files.Length);
string picturefilename = files[randomNumber];
BitmapImage bt = new BitmapImage();
bt.UriSource = new Uri(picturefilename, UriKind.Absolute);
image1.Source = bt;
string soundfilename = System.IO.Path.GetFileNameWithoutExtension(picturefilename);
soundfilename = soundfilename.ToLower();
soundfilename = soundfilename.Replace("_", "");
btnEnglish.Content = soundfilename;
soundfilename = soundfilename + ".wav";
if (silencer == false)
{
if (System.IO.File.Exists(soundfilename))
{
PlayNewFile((soundfilename));
}
}
}
public void btnEnglish_Click(object sender, RoutedEventArgs e)
{
if (silencer == true)
{
silencer = false;
}
else silencer = true;
}
}
}