Error When trying to run my C# WPF and C++ Project - c#

hey there I've just now started making a engine with tutorials while I was doing so I stumbled upon a error.
Here Is What the Error Told:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'ProjectBrowserDialg' could not be found (are you missing a using directive or an assembly reference?) Editor C:\Users\abrus\OneDrive\Documents\cpp_files_me\MehroofEngine\src\MehroofEngine For C++\Editor\MainWindow.xaml.cs 37 Active
this is the code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Editor
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Loaded += OnMainWindowLoaded;
}
private void OnMainWindowLoaded(object sender, RoutedEventArgs e)
{
Loaded -= OnMainWindowLoaded;
OpenProjectBrowserDialog();
}
private void OpenProjectBrowserDialog()
{
var projectBrowser = new ProjectBrowserDialg();
}
}
}
if I forgot something in the code please reply
if not enough information please reply it helps me make better posts.

Related

WPF Combobox Populated from LINQ To SQL Class Displaying Types Instead of Names

I have a WPF window with a combo box. The contents of the combo box should be populated from a column in a SQL table. I created a LINQ To SQL Data Context Class in a models folder and set the ItemsSource of the ComboBox to the class (Customers) generated by the data context.. But when I run the program, the contents of the combobox are the types of the items it pulled..
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using eTouchLV.GatekeeperUI.Models;
namespace eTouchLV.GatekeeperUI
{
public partial class MainWindow : Window
{
SQLDataClassDataContext dc = new SQLDataClassDataContext(Properties.Settings.Default.GatekeeperDBConnectionString);
public MainWindow()
{
InitializeComponent();
AssignDataToComponents();
}
private void AssignDataToComponents()
{
this.CheckDBIsValid();
comboCustomers.ItemsSource = dc.Customers;
}
private void CheckDBIsValid()
{
if (!dc.DatabaseExists())
{
MessageBox.Show("Program started on the machine but can't seem to find the database...", "Error connecting to DB on SQL server.");
}
}
}
}
Program:

How to change rectangle property in its .cs code?

I have created my own control for WPF and in .cs code I want to define method to change margin parameter.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
public String TagName { get; set; }
public UserControl1(String TagName)
{
this.TagName = TagName;
InitializeComponent();
}
public double TagValue { get; set; }
public void test(double val) {
valueRectangle.Margin.Top(10);
}
}
}
But I'm still getting error while setting any value to Margin.Top
Edit: Errorcode here:
Severity Code Description Project File Line Suppression State
Error CS1955 Non-invocable member 'Thickness.Top' cannot be used like a method. WpfApplication1 X:\07_projects\00_ostatni\CSharp\WpfApplication1\WpfApplication1\UserControl1.xaml.cs 36 Active
As Clemens wrote:
Besides that Top is a property, not a method, you should assign a new
Thickness like valueRectangle.Margin = new Thickness(0, 10, 0, 0);

Breakpoint in App.XAML.CS not working

Whenever I put a breakpoint in the WPF App.XAML.cs file, the breakpoints are not hitting. As if the file is not executed at all. So weird.... There is no the usual 'yellow breakpoint' indicating the breakpoint is not hit. It just runs the program as if the file is not being executed at all
Anybody know why?
here's my App.Xaml.cs code
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Abt.Controls.SciChart;
using Abt.Controls.SciChart.Model.DataSeries;
using Abt.Controls.SciChart.Utility;
using Abt.Controls.SciChart.Visuals;
using Abt.Controls.SciChart.Visuals.Axes;
using Abt.Controls.SciChart.Visuals.Annotations;
using Abt.Controls.SciChart.Visuals.RenderableSeries;
using Abt.Controls.SciChart.ChartModifiers;
using Abt.Controls.SciChart.Numerics.CoordinateCalculators;
namespace Hub
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
CUtilities.WCFCalls = new List<string>();
}
}
}
here's my app.g.cs file
#pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "788CF6544127ABDC6D6160DE3D084FC8"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
namespace Client {
/// <summary>
/// App
/// </summary>
public partial class App : System.Windows.Application {
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
#line 4 "..\..\App.xaml"
this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
#line default
#line hidden
System.Uri resourceLocater = new System.Uri("/Client;component/app.xaml", System.UriKind.Relative);
#line 1 "..\..\App.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public static void Main() {
Client.App app = new Client.App();
app.InitializeComponent();
app.Run();
}
}
}
I seem to remember this happening with older versions of Visual Studio, it's like it would take a second or two for the debugger to hook in to the process or something. I found I could force it manually with Debugger.Break(); In any case try manually deleting the bin/obj folders and doing a rebuild, sometimes it's also the result of the incremental compilation getting itself confused.

Call webservice from Windows Phone library

Regards,
I am trying to call a webservice from within the library of windows phone application that I am creating, however I have a weird problem and I hope that you can help me.
First of all I have the following code on my Application main page:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
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 Library;
using System.Threading;
namespace Host
{
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
Class1.AsyncCall test = new AsyncCall();
test.Call("0002145", 51);
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
}
}
}
My AsyncCall class is in my library and it has the following code:
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Threading;
using Library;
using Library.WebserviceRemote;
namespace Library
{
public class AsyncCallWS
{
WebserviceCall com = new WebserviceCall();
com.methodOne("methodOne", "1221", 122);
}
}
My WebserviceCall is another class in library and the method that is called looks like this:
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
//using System.ServiceModel;
using Library.WebserviceRemote;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
namespace Library
{
//[DebuggerNonUserCode]
public class WebserviceCall
{
public void methodOne(String Method, String param1, int param2)
{
WebserviceRemote client = new WebserviceRemote ();
System.Diagnostics.Debug.WriteLine("I am in methodOne " + param1 + param2);
client.methodOneOnServiceCompleted += new EventHandler<methodOneOnServiceCompletedEventArgs>(client_methodOneOnServiceCompleted);
client.methodOneOnServiceAsync("1221", 122);
System.Diagnostics.Debug.WriteLine("After call to webservice ");
}
private void client_methodOneOnServiceCompleted(object sender, methodOneOnServiceCompletedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("This is the response " + e.Result);
}
}
}
Well the problem is that the method client_methodOneOnServiceCompleted is never read, the application never gets in it so I cannot get the response from webservice. I think it has something due to the EventHandler since this is all done in library not the applications page.
However, I am not aware why it doesn't get in that method. Furthermore, there are no errors and everything is there on output except this:
System.Diagnostics.Debug.WriteLine("This is the response " + e.Result);
Another notice: this code works like a charm when the call is made from within application itself but I really need to make webservice call from library, so please help :)
PS: this is all tested in emulator 7.0
Thank you.

type or namespace name 'Serializable' does not exist in the namespace 'System' (are you missing an assembly reference?

I am VS 2012 silverlight-5 beginner. I tried to serialize and de-serialize from a xml file. I have following error while doing this :
The type or namespace name 'Serializable' does not exist in the namespace 'System' (are you missing an assembly reference?)
The type or namespace name 'SerializableAttribute' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DatamemberAttribute' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'Datamember' could not be found (are you missing a using directive or an assembly reference?)
My code for serialization is :
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Runtime.Serialization.Json;
using System.Runtime;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.IO;
namespace Model.XML
{
public static class Serialization<T> where T : class
{
public static T DeserializeFromXmlFile(string fileName)
{
if (!File.Exists(fileName))
{
return null;
}
DataContractSerializer deserializer = new DataContractSerializer(typeof(T));
using (Stream stream = File.OpenRead(fileName))
{
return (T)deserializer.ReadObject(stream);
}
}
}
}
But i am interested in having each class seperately (not all the 3 classes (parameter,component and attribute) obtained in one class).
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Runtime.Serialization.Json;
using System.Runtime;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.IO;
using System.Xml.Serialization.XmlTypeAttribute;
using System.Serializable; //It gives red line under Serializable
namespace Model.XML
{
[Serializable] //It gives red line
public class attribute
{
[Datamember] //It gives red line
public string name { get; set; }
[Datamember] //It gives red line
public string label { get; set; }
[Datamember] //It gives red line
public string unit { get; set; }
[Datamember] //It gives red line
public component thisComponent { get; set; }
}
}
i tried to reference using System.Serializable; but it is not available in the dll list i have in my VS2012.
What is the cause of problem and how to get a rid of it ? Thanks in advance.
EDIT AFTER Comments:
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Runtime.Serialization.Json;
using System.Runtime;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.IO;
using System.Collections.Generic;
namespace Model.XML
{
[DataContract]
public class attribute
{
[DataMember]
public string type { get; set; }
[DataMember]
public string displayed { get; set; }
[DataMember]
public string add_remove { get; set; }
[DataMember]
public string ccypair { get; set; }
[DataMember]
public List<int> item { get; set; }
public static void Main()
{
attribute Obj1 = Serialization<attribute>.DeserializeFromXmlFile("C:\\Users\\SHEK\\Desktop\\VannakNew\\DEV_CENTER\\Model\\XML\\XmlParameter.xml");
// Obj1.type = "shekhar";
}
}
}
And serialization.cs is :
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Runtime.Serialization.Json;
using System.Runtime;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.IO;
namespace Model.XML
{
public static class Serialization<T> where T : class
{
public static T DeserializeFromXmlFile(string fileName)
{
if (!File.Exists(fileName))
{
MessageBox.Show("File Path is wrong");
return null;
}
DataContractSerializer deserializer = new DataContractSerializer(typeof(T));
using (Stream stream = File.OpenRead(fileName))
{
return (T)deserializer.ReadObject(stream);
}
}
}
}
Xml file is XmlParameter.xml
<?xml version="1.0" encoding="utf-8" ?>
<parameter>
<name>bands_amounts</name>
<label>Bands Amounts</label>
<unit></unit>
<component>
<type>List</type>
<attributes>
<type>Integer</type>
<displayed>4</displayed>
<add_remove>yes</add_remove>
<item>1 000 000</item>
<item>5 000 000</item>
<item>10 000 000</item>
<item>20 000 000</item>
</attributes>
<attributes>
<ccypair>XAUUSD</ccypair>
<item>100</item>
<item>500</item>
<item>1000</item>
</attributes>
</component >
</parameter>
**It is working without error but i wonder why it always null object(on debugging) even the path of XmlParameter.xml file is correct. Is it due to using "[DataContract]" instead of [Serialized] ? because it si silverlight application. Actually i have todisplay the elements inside the nodes like,i have to display "XAUUSD" in my attribute.cs class which present in node <ccypair>XAUUSD</ccypair> **
There is no System.Serializable namespace; the SerializableAttribute class is in the System namespace. You should just write using System;.
I think you're confusing C# using statements with Java import statement. In Java, you import specific classes (or all classes from a package with *). In C#, the using statement imports all types in the specified namespace.
Currently, specifying a class name after using is an error, but in C# 6 it will be possible, and will import all static members from the class.
Other issue: you wrote Datamember instead of DataMember; C# is case sensitive. And anyway, DataMember has no effect on a class that doesn't have the DataContract attribute.
Also make sure you have referenced the System.Runtime.Serialization assembly.
I got the same problem and by adding this resolved the problem
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
Just add
using System.Runtime.Serialization;
This can also be caused if the application was targeted for .NET 2.0 but your are compiling if for a different .NET version/stack.

Categories