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.
Related
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.
I just started with C# at work and I did read like a lot of the questions that are about my error here at StackOverflow. Unfortunately I still don't get what I'm doing wrong.
So, I followed this (http://qafriend.com/c-ui-automation-tutorial/automate-using-c-tutorial-guide-part-5) tutorial that is about C# and UI Automation. Everything went fine until I had to write actual code. So my code is this:
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 System.Windows.Automation;
using Automation = System.Windows.Automation;
namespace AutomateCSharp
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
static AutomationElement desktopObject = AutomationElement.RootElement;
static Automation.Condition testWindowNameCondition = new PropertyCondition(AutomationElement.NameProperty, "Demo Window For Csharp Automation");
static Automation.Condition textConditionOne = new PropertyCondition(AutomationElement.AutomationIdProperty, "InputOne");
static Automation.Condition textConditionTwo = new PropertyCondition(AutomationElement.AutomationIdProperty, "InputTwo");
static Automation.Condition textConditionTotal = new PropertyCondition(AutomationElement.AutomationIdProperty, "Total");
static AutomationElement testWindow = desktopObject.FindFirst(TreeScope.Children, testWindowNameCondition);
static AutomationElement textOne = testWindow.FindFirst(TreeScope.Descendants, textConditionOne);
static ValuePattern valuetextOne = textOne.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
valuetextOne.SetValue("4");
}
}
And I get the Error: The name 'valuetextOne' does not exist in the current context.
Could someone please tell me what I'm wrong about? Thanks a lot in advance :)
This problem has to do with the fact that functions can't be called inside class bodies directly. Only fields, properties and methods can be written there. What you need to do, is wrap it inside another function, like so:
public partial class MainWindow : Window
{
// Stuff
public void SetValue() => valuetextOne.SetValue("4");
}
And then you call it as:
public void Foo()
{
MainWindow window = Bar();
window.SetValue();
}
I go into more detail here about this.
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);
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.
I wrote a user control in XAML and after it gets compiled into C# the resulting C# has this line:
using Microsoft.Windows.Themes;
Which throws an error now:
The type or namespace name 'Themes' does not exist in the namespace
'Microsoft.Windows' (are you missing an assembly reference?)
I figured since I can't affect the output of compiled C# (there's nothing to remove from XAML), I would just add that as Reference.
However, the Add Reference dialog does not contain Microsoft.Windows.Themes. Is this not part of .NET?
Here's an example XAML user control that causes this problem:
<UserControl x:Class="GG.UserControls.MainMenu"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<StackPanel>
<Menu VerticalAlignment="Top" Background="{x:Null}">
... // Just static menu items.
</Menu>
</StackPanel>
</UserControl>
And C# code behind it:
using System;
using System.Windows.Controls;
namespace GG.UserControls
{
/// <summary>
/// Interaction logic for MainMenu.xaml
/// </summary>
public partial class MainMenu : UserControl
{
public MainMenu()
{
InitializeComponent();
}
}
}
Here's an example of compiled C#:
#pragma checksum "..\..\..\..\UserControls\MainMenu.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "5A85C5B16565514165AD23641F944BC6"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17020
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using GG;
using GG.UserControls;
using Microsoft.Windows.Shell;
using Microsoft.Windows.Themes; // <---- WTF?
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 GG.UserControls {
/// <summary>
/// ChangesetHistory
/// </summary>
public partial class MainMenu : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
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;
System.Uri resourceLocater = new System.Uri("/GG;component/usercontrols/mainmenu.xaml", System.UriKind.Relative);
#line 1 "..\..\..\..\UserControls\MainMenu.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
this._contentLoaded = true;
}
}
}
Microsoft.Windows.Themes is found in the theme-specific PresentationFramework assemblies. You'll want to add a reference to one of the following depending on which one is referenced in your XAML:
PresentationFramework.Aero.dll
PresentationFramework.AeroLite.dll
PresentationFramework.Classic.dll
PresentationFramework.Luna.dll
PresentationFramework.Royale.dll