简体   繁体   English

错误System.Windows.Baml2006.TypeConverterMerkupExtension。 会是什么呢?

[英]error System.Windows.Baml2006.TypeConverterMerkupExtension. What could it be?

I found out that the error occurs during initialization 我发现初始化期间发生错误

Error: Providing value for System.Windows.Baml2006.TypeConverterMerkupExtension "caused an exception. Line number 8 and the position in row 9 错误:“为System.Windows.Baml2006.TypeConverterMerkupExtension提供值”引起了异常。第8行和第9行中的位置

What could it be? 会是什么呢?

<Window x:Class="Client.Index"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:Client.index"
        Title="Главная программа"
        x:Name="window"
        KeyDown="window_KeyDown"
        WindowState="Maximized"
        Icon="/Client;component/Client.ico"
        >
    <Border x:Name="p_border">
        <ScrollViewer VerticalScrollBarVisibility="Auto" >
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0" x:Name="gridrtfbox" Visibility="Collapsed">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                </Grid>
                <Grid Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="20" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <DockPanel x:Name="stack_d" Grid.Row="0"  Grid.ColumnSpan="4" VerticalAlignment="Stretch" >
                        <!--<l:CategoryView  />-->
                    </DockPanel>
                    <DockPanel x:Name="stack_trainer" Grid.Row="1"  Grid.ColumnSpan="4" DockPanel.Dock="Bottom" >
                        <!--<loc:TrainerView />-->
                    </DockPanel>

                    <Button Content="Почта" x:Name="mails"  Grid.Row="2" Grid.Column="0"  Width="100" HorizontalAlignment="Center" VerticalAlignment="Center"  Click="mails_Click"/>
                    <Button Content="Оплатить" Width="100" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"  Click="Button_Click_Payment"/>
                    <Button Content="Тех помощь" Width="100"  Grid.Row="2" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center"  x:Name="support" Click="support_Click"/>
                    <Button Content="Настройки" x:Name="settings"  Grid.Row="2" Grid.Column="3"   Width="100" HorizontalAlignment="Center" VerticalAlignment="Center" Click="settings_Click"/>
                </Grid>
            </Grid>
        </ScrollViewer>
    </Border>
</Window>

C#: C#:

using System;
using System.Windows;
using System.Windows.Input;
using System.Collections.ObjectModel;
using Client.payment;
using System.Data;
using MySql.Data.MySqlClient;
using DataBase;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Threading;
using SandboxApplication.Alerts;
using System.Linq;
using System.Windows.Media.Imaging;
using System.Net;
using System.IO;
using System.Windows.Media;


namespace Client
{
    /// <summary>
    /// Interaction logic for Index.xaml
    /// </summary>
    public partial class Index : Window
    {


        static public string idClient = "0";
        static public string idPersonClient = "0";

        static public DataTable dtPayment;
        //DATE_FORMAT(bday,'%d.%m.%Y') as bday

        //private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
        //[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        //private static extern IntPtr SetWindowsHookEx(int id, LowLevelKeyboardProc callback, IntPtr hMod, uint dwThreadId);
        //[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        //private static extern bool UnhookWindowsHookEx(IntPtr hook);
        //[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        //private static extern IntPtr CallNextHookEx(IntPtr hook, int nCode, IntPtr wp, IntPtr lp);
        //[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        //private static extern IntPtr GetModuleHandle(string name);
        //[DllImport("user32.dll", CharSet = CharSet.Auto)]
        //private static extern short GetAsyncKeyState(System.Windows.Forms.Keys key);

        //private IntPtr ptrHook;
        //private LowLevelKeyboardProc objKeyboardProcess;


        Timer timer;

        public System.Windows.Controls.Border GetSetBorder
        {
            get { return p_border; }
            set { p_border = value; }
        }


        DateTime interval = new DateTime();


        string id = "";
        public void Update()
        {
            idPersonClient = id;
            MessageBox.Show("idPersonClient = id;");
            SetIdClient();
            MessageBox.Show(" SetIdClient();");
            DataPaymentGood(idClient);
            MessageBox.Show("DataPaymentGood(idClient);");
            string background_path = "";
            string myback = "";
            try
            {
                string sql = @"SELECT *";
                //string sql = @"SELECT  *";
                using (MySqlConnection connection = ConnectToDataBase.GetConnection())
                {
                    MySqlCommand command = new MySqlCommand(sql, connection);
                    // MySqlDataAdapter adapter = new MySqlDataAdapter();
                    connection.Open();
                    myback = command.ExecuteScalar().ToString();

                    if (File.Exists("images/" + myback) == false)
                    {
                        sql = @"SELECT *";
                        command = new MySqlCommand(sql, connection);
                        background_path = command.ExecuteScalar().ToString();
                        myback = background_path.Substring(background_path.LastIndexOf("/") + 1);
                        myback = "background" + myback;
                        string request = string.Format("{0}", background_path);
                        HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create(request);
                        loHttp.Method = "GET";
                        loHttp.ProtocolVersion = HttpVersion.Version11;
                        HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();


                        using (StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream()))
                        {
                            System.Drawing.Image webImage = System.Drawing.Image.FromStream(loWebResponse.GetResponseStream());

                            webImage.Save(Directory.GetCurrentDirectory() + "/images/" + myback);
                            webImage.Dispose();
                        }
                        sql = "UPDATE *";
                        command = new MySqlCommand(sql, connection);


                        command = new MySqlCommand(sql, connection);
                        command.Parameters.Clear();
                        command.Parameters.AddWithValue("@background", myback);
                        command.Parameters.AddWithValue("@id", Index.idPersonClient);

                        int a = command.ExecuteNonQuery();
                    }


                    MessageBox.Show("int a = command.ExecuteNonQuery();");
                    //string back = background_path.Substring(background_path.LastIndexOf("/")-1);


                    // Create an ImageBrush

                    ImageBrush imgBrush = new ImageBrush();
                    imgBrush.ImageSource = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + "/images/" + myback, UriKind.Absolute));
                    p_border.Background = imgBrush;
                    imgBrush = null;




                    //ImageSource imageSource = new BitmapImage(new Uri("images/background.jpg", UriKind.Relative));
                    //p_border.Background = new ImageBrush(imageSource);
                    //GetSetBorder.Background = null;

                }
                // idPersonClient
            }
            catch (NullReferenceException nullex)
            {
                //нет выбраного у польозвателя фона
                try
                {
                    string sql = @"SELECT path FROM Background LIMIT 1";
                    using (MySqlConnection connection = ConnectToDataBase.GetConnection())
                    {
                        MySqlCommand command = new MySqlCommand(sql, connection);
                        // MySqlDataAdapter adapter = new MySqlDataAdapter();
                        connection.Open();
                        background_path = command.ExecuteScalar().ToString();

                        string request = string.Format("{0}", background_path);
                        HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create(request);
                        loHttp.Method = "GET";
                        loHttp.ProtocolVersion = HttpVersion.Version11;
                        HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();

                        StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream());
                        System.Drawing.Image webImage = System.Drawing.Image.FromStream(loWebResponse.GetResponseStream());

                        webImage.Save("images/background.jpg");

                        sql = "UPDATE *";
                        command = new MySqlCommand(sql, connection);
                        command.Parameters.Clear();
                        command.Parameters.AddWithValue("@id", Index.idClient);

                        int a = command.ExecuteNonQuery();

                        //System.Windows.Controls.Image finalImage = new  System.Windows.Controls.Image();
                        //BitmapImage logo = new BitmapImage();
                        //logo.BeginInit();
                        //logo.UriSource = new Uri("images/background.jpg");
                        //logo.EndInit();
                        //finalImage.Source = logo;







                        //FileStream fs = new FileStream("images/background.jpg", FileMode.Open);
                        //Image img = Image.FromStream(fs);
                        //fs.Close();


                        //ImageSource imageSource = Bitmap.FromFile();

                        // Create an ImageBrush
                        ImageBrush imgBrush = new ImageBrush();
                        imgBrush.ImageSource = new BitmapImage(new Uri("images/background.jpg", UriKind.Relative));


                        p_border.Background = imgBrush;
                    }
                }
                catch (NullReferenceException nullex2)
                {
                    //нет не одной записи в фоне
                    p_border.Background = null;
                }
                catch { }
            }
            catch (Exception ex) { }


            UpdateMessages();
            if (timer == null)
            {
                interval = DateTime.Parse(new TimeSpan(0, 0, 30).ToString());
                timer = new Timer(CheckMess, interval, 1000, long.Parse(interval.TimeOfDay.TotalSeconds.ToString()) * 1000);

            }

            try
            {

                //ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule;
                //objKeyboardProcess = new LowLevelKeyboardProc(captureKey);
                //ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(objCurrentModule.ModuleName), 0);
            }
            catch { return; }
        }
        public Index(string id)
        {
            this.id = id;
            MessageBox.Show("public Index(string id)");
            InitializeComponent();
            MessageBox.Show("  InitializeComponent();");



        }
        public void SetIdClient()
        {
            try
            {
                string sql = @"SELECT *";
                using (MySqlConnection connection = ConnectToDataBase.GetConnection())
                {
                    MySqlCommand command = new MySqlCommand(sql, connection);
                    // MySqlDataAdapter adapter = new MySqlDataAdapter();
                    connection.Open();
                    idClient = command.ExecuteScalar().ToString();
                }
                // idPersonClient
            }
            catch { MessageBox.Show("Произошла ошибка в SetIdClient, обратитесь к администрации или попробуйте перезайти - программа может работать не коректно"); }
        }
        //[StructLayout(LayoutKind.Sequential)]
        //private struct KBDLLHOOKSTRUCT
        //{
        //    public System.Windows.Forms.Keys key;
        //    public int scanCode;
        //    public int flags;
        //    public int time;
        //    public IntPtr extra;
        //}
        //static bool LWin = false;
        //private IntPtr captureKey(int nCode, IntPtr wp, IntPtr lp)
        //{
        //    if (nCode >= 0)
        //    {
        //        KBDLLHOOKSTRUCT objKeyInfo = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lp, typeof(KBDLLHOOKSTRUCT));
        //        if (objKeyInfo.key == System.Windows.Forms.Keys.PrintScreen) //здеся и перехватываем код клавиши
        //        {
        //            MessageBox.Show("Не шалить! ");
        //            if (Clipboard.ContainsImage())
        //            {
        //                Clipboard.Clear();
        //            }
        //            return (IntPtr)1;
        //        }
        //        else if (objKeyInfo.key == System.Windows.Forms.Keys.LWin)
        //        {
        //            LWin = true;
        //            return CallNextHookEx(ptrHook, nCode, wp, lp);
        //        }
        //        else if (objKeyInfo.key == System.Windows.Forms.Keys.D)
        //        {
        //            if (LWin)
        //            {
        //                return (IntPtr)1;
        //            }
        //        }
        //        LWin = false;
        //    }
        //    return CallNextHookEx(ptrHook, nCode, wp, lp);
        //}



        static public DataTable DataPaymentGood(string id)
        {
            try
            {
                DataSet temp = new DataSet();
                string sql = "SELECT *";
                using (MySqlConnection connection = ConnectToDataBase.GetConnection())
                {
                    MySqlCommand command = new MySqlCommand(sql, connection);
                    MySqlDataAdapter adapter = new MySqlDataAdapter();
                    connection.Open();
                    adapter.SelectCommand = command;
                    int count = adapter.Fill(temp, "Purchased");
                }
                dtPayment = temp.Tables["Purchased"];
                return dtPayment;
            }
            catch (Exception ex)
            {
                //Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
                MessageBox.Show(ex.Message);
                return null;
            }
        }
        static ObservableCollection<BasketTheme> basketTheme = new ObservableCollection<BasketTheme>();
        public static ObservableCollection<BasketTheme> GetBasketTheme { get { return basketTheme; } }

        static ObservableCollection<BasketTrainer> basketTrainer = new ObservableCollection<BasketTrainer>();
        public static ObservableCollection<BasketTrainer> GetBasketTrainer { get { return basketTrainer; } }

        private void Button_Click_Payment(object sender, RoutedEventArgs e)
        {
            try
            {
                Payment p = new Payment();
                p.ShowDialog();
            }
            catch { }
        }

        private void window_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.F5)
                {
                    Index i = new Index(idClient);
                    i.Show();
                    this.Close();
                }
                if (e.Key == Key.Escape)
                    this.Close();
            }
            catch { }
        }

        private void support_Click(object sender, RoutedEventArgs e)
        {
            Support s = new Support(this);
            s.Show();
        }

        private void mails_Click(object sender, RoutedEventArgs e)
        {
            Mail s = new Mail(this);
            s.Show();
        }




        #region Messages



        static ObservableCollection<Message> messages = new ObservableCollection<Message>();
        public static ObservableCollection<Message> GetMessages { get { return messages; } }
        DataSet dtSet = new DataSet();
        int total_messages = 0;
        public void ChekingMess()
        {
            try
            {
                string sql = @"SELECT *";
                using (MySqlConnection connection = ConnectToDataBase.GetConnection())
                {
                    MySqlCommand command = new MySqlCommand(sql, connection);
                    connection.Open();
                    int temp_total_messages = int.Parse(command.ExecuteScalar().ToString());

                    if (temp_total_messages > total_messages)
                    {

                        this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                        {
                            UpdateAll();
                            SimpleAlert am = new SimpleAlert();
                            am.Title = "У вас новое сообщение ";
                            am.Message = "Зайдите в сообщения";
                        }));
                    }
                }
            }
            catch { }
        }
        void CheckMess(object obj)
        {
            ChekingMess();
        }
        #region UPDATE
        public void UpdateMessages()
        {
            try
            {
                Helper.RemoveAll(GetMessages);

                string sql = @"SELECT *";
                total_messages = -1;
                if (dtSet.Tables["Messages"] != null)
                    dtSet.Tables["Messages"].Clear();
                using (MySqlConnection connection = ConnectToDataBase.GetConnection())
                {
                    MySqlCommand command = new MySqlCommand(sql, connection);
                    MySqlDataAdapter adapter = new MySqlDataAdapter();
                    connection.Open();
                    adapter.SelectCommand = command;
                    total_messages = adapter.Fill(dtSet, "Messages");

                }
                if (total_messages > 0)
                {
                    for (int i = 0; i < dtSet.Tables["Messages"].Rows.Count; i++)
                    {
                        int id = int.Parse(dtSet.Tables["Messages"].Rows[i].ItemArray[0].ToString());
                        int from_id = int.Parse(dtSet.Tables["Messages"].Rows[i].ItemArray[1].ToString());
                        string name_from = dtSet.Tables["Messages"].Rows[i].ItemArray[2].ToString();
                        int to_id = int.Parse(dtSet.Tables["Messages"].Rows[i].ItemArray[3].ToString());
                        string name_to = dtSet.Tables["Messages"].Rows[i].ItemArray[4].ToString();
                        string title = dtSet.Tables["Messages"].Rows[i].ItemArray[5].ToString();
                        string text = dtSet.Tables["Messages"].Rows[i].ItemArray[6].ToString();
                        DateTime send_date = new DateTime();
                        DateTime receive_date = new DateTime();
                        try
                        {
                            send_date = DateTime.Parse(dtSet.Tables["Messages"].Rows[i].ItemArray[7].ToString());
                        }
                        catch { }
                        try
                        {
                            receive_date = DateTime.Parse(dtSet.Tables["Messages"].Rows[i].ItemArray[8].ToString());
                        }
                        catch { }
                        Message f = new Message(id, from_id, name_from, to_id, name_to, title, text, send_date, receive_date);
                        messages.Add(f);
                    }
                }
                messages = new ObservableCollection<Message>(messages.OrderBy(Send_date => Send_date));
            }
            catch { }
        }
        void UpdateAll()
        {
            UpdateMessages();
            //UpdateClient();

            //UpdateAdmin();
            //UpdateClientNotPaid();
        }
        #endregion



        #endregion

        private void settings_Click(object sender, RoutedEventArgs e)
        {
            Settings s = new Settings(this);
            s.ShowDialog();
        }
    }
}

The problem is in your XAML, in the Icon property. 问题出在XAML的Icon属性中。 You can try simply using 您可以尝试简单地使用

Icon="Client.ico"

instead of the absolute path 代替绝对路径

Icon="/Client;component/Client.ico"

You' probably want to set up a single icon for your whole application instead of an icon per window. 您可能希望为整个应用程序设置一个图标,而不是每个窗口设置一个图标。 See the MSDN reference on System.Windows.Window.Icon for more information. 有关更多信息,请参见System.Windows.Window.Icon上的MSDN参考。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.Windows.Baml2006.TypeConverterMarkupExtension - System.Windows.Baml2006.TypeConverterMarkupExtension 如何解决此错误:“在&#39;System.Windows.Baml2006.TypeConverterMarkupExtension&#39;上提供值” - How do I fix this error : 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' 使用触发器更改图像获取System.Windows.Baml2006.TypeConverterMarkupExtension错误 - Change an image using triggers getting System.Windows.Baml2006.TypeConverterMarkupExtension error 在“ System.Windows.Baml2006.TypeConverterMarkupExtension”上提供值引发异常 - Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception System.Windows.Baml2006.TypeConverterMarkupExtension&#39;抛出异常。&#39; 行号&#39;6&#39;和行位置&#39;10 - System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '6' and line position '10 '在 'System.Windows.Baml2006.TypeConverterMarkupExtension' 上提供值引发异常。 - 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' &#39;为&#39;System.Windows.Baml2006.TypeConverterMarkupExtension&#39;提供价值,引发了一个异常。 行号&#39;49&#39;和行位置&#39;38&#39; - 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '49' and line position '38' 未知的生成错误,“无法加载文件或程序集” System.Windows - Unknown build error, 'Could not load file or assembly 'System.Windows “LinkAssemblies”任务意外失败。 xamarinandroidException:错误 XA2006:无法解析引用 - The “LinkAssemblies” task failed unexpectedly. xamarinandroidException: error XA2006: could not resolve reference 什么可能导致System.Windows.Forms.InputLanguage.CreateInputLanguageChangingEventArgs中的溢出异常 - What could cause an overflow exception in System.Windows.Forms.InputLanguage.CreateInputLanguageChangingEventArgs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM