我一直在开发一个Windows Phone应用程序,它将图像和文本放在一起并上传到服务器。
调试应用程序时出现问题。问题似乎是技术问题。我真的不知道该怎么做。
这就是为什么我想在这里发布这个问题。如果有人帮助解决这个问题,我真的很感激在这里给予的帮助。
我非常感谢这里所做的工作。没有你们,我们真的不会做到这一点。你让我们有机会从错误中吸取教训。
再次感谢。
请检查我的代码是否需要进行任何调整。
以下是我在模拟器上调试时弹出的错误消息:
无法分配属性'System.Windows.Controls.Primitives.ButtonBase.Click'。 [线:41位置:250]
这是我的第一篇文章,所以我不能发布图片。
我很欣赏这里所做的工作。
private void button3_Click(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
//void photoChooserTask_Completed(object sender, PhotoResult e)
//{
{
System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
bmp.SetSource(e.ChosenPhoto);
image1.Source = bmp;
byte[] sbytedata = ReadToEnd(e.ChosenPhoto);
string s = sbytedata.ToString();
WebClient wc = new WebClient();
Uri u = new Uri("ftp://ftp.icupload.cs201.com/icupload.cs201.com/images/");
wc.OpenWriteCompleted += new OpenWriteCompletedEventHandler(wc_OpenWriteCompleted);
wc.OpenWriteAsync(u, "POST", sbytedata);
}
}
public static void wc_OpenWriteCompleted(object sender, OpenWriteCompletedEventArgs e)
{
if (e.Error == null)
{
object[] objArr = e.UserState as object[];
byte[] fileContent = e.UserState as byte[];
Stream outputStream = e.Result;
outputStream.Write(fileContent, 0, fileContent.Length);
outputStream.Flush();
outputStream.Close();
string s = e.Result.ToString(); ;
}
}
public static byte[] ReadToEnd(System.IO.Stream stream)
{
long originalPosition = stream.Position;
stream.Position = 0;
try
{
byte[] readBuffer = new byte[4096];
int totalBytesRead = 0;
int bytesRead;
while ((bytesRead = stream.Read(readBuffer, totalBytesRead, readBuffer.Length - totalBytesRead)) > 0)
{
totalBytesRead += bytesRead;
if (totalBytesRead == readBuffer.Length)
{
int nextByte = stream.ReadByte();
if (nextByte != -1)
{
byte[] temp = new byte[readBuffer.Length * 2];
Buffer.BlockCopy(readBuffer, 0, temp, 0, readBuffer.Length);
Buffer.SetByte(temp, totalBytesRead, (byte)nextByte);
readBuffer = temp;
totalBytesRead++;
}
}
}
byte[] buffer = readBuffer;
if (readBuffer.Length != totalBytesRead)
{
buffer = new byte[totalBytesRead];
Buffer.BlockCopy(readBuffer, 0, buffer, 0, totalBytesRead);
}
return buffer;
}
finally
{
stream.Position = originalPosition;
}
}
这是第41行...位置252是“Click = myButton3_Click”
<Button BorderBrush="#FFFF7300" Content="Capture Photo" FontSize="22" Foreground="#FFFF7300" Height="78" Margin="263,23,-10,0" Name="myButton" VerticalAlignment="Top" Click="button2_Click" FontFamily="Tahoma" BorderThickness="4" />
<Image Height="275" HorizontalAlignment="Left" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="269" />
<Button Content="Comment & Location" Height="72" HorizontalAlignment="Left" Margin="92,599,0,0" Name="button1" VerticalAlignment="Top" Width="294" Foreground="#FFFF7300" OpacityMask="#FFFF7300" BorderBrush="#FF091A08" FontFamily="Tahoma" FontWeight="Normal" Background="Transparent" Click="button1_Click" />
<Button Content="Select Photo" HorizontalAlignment="Left" Margin="264,107,0,0" Name="button2" Width="202" FontSize="24" Foreground="#FFFF7300" FontFamily="Tahoma" Background="Transparent" BorderBrush="#FFFF7300" BorderThickness="4" Height="78" VerticalAlignment="Top" Click="button2_Click_1" />
<Button Content="Upload" Height="84" HorizontalAlignment="Left" Margin="272,191,0,0" Name="myButton3" VerticalAlignment="Top" Width="186" BorderBrush="#FFFF7300" BorderThickness="4" FontFamily="Tahoma" FontSize="26" Foreground="#FFFF7300" Click="myButton3_Click" ClickMode="Release" DataContext="{Binding}" />
<TextBlock Height="200" HorizontalAlignment="Left" Margin="28,290,0,0" Name="textBlock1" Text="" VerticalAlignment="Top" Width="400" FontSize="30" TextTrimming="WordEllipsis" TextWrapping="Wrap" />
在您提到的所有更改之后,我仍然会遇到三个相同的错误。
错误2'System.Windows.RoutedEventArgs'不包含'ChosenPhoto'的定义,并且没有可以找到接受类型为'System.Windows.RoutedEventArgs'的第一个参数的扩展方法'ChosenPhoto'(你是否错过了使用指令或程序集引用?)C:\ Users \ Yaseen \ Desktop \ IC Final \ Phone Application \ MainPage.xaml.cs 107 41电话应用程序
这些直接来自button3语法