'Debug' does not contain a definition for 'Print' - c#

In the following code I would like to just output "hi" into a console window as a test when both of the check boxes are checked.
using System;
using System.Diagnostics;
private void button_Click(object sender, RoutedEventArgs e)
{
show.Text = inputText.Text;
if (check1_cont && check2_cont == true )
{
Debug.Print("hi");
}
}
The only problem is that in System.Diagnostics, the 'Print' in 'Debug.Print' doesn't seem to exist. I've checked https://msdn.microsoft.com/en-us/library/system.diagnostics.debug.print(v=vs.110).aspx and the Print method does exist. Any help regarding a solution to an absent Paint method would be much appreciated.
EDIT 1:
Apparently Debug.WriteLine doesn't give an error, but when I run the program and check the two boxes and press the button, no console appears.
EDIT 2:
In case it helps anyone, here is the full code for the GUI application that I am using.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Diagnostics;
using Microsoft;
using System.Threading.Tasks;
using System.Data;
using System.Dynamic;
using System.Xml;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace normieap
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public Boolean check1_cont = false;
public Boolean check2_cont = false;
public MainPage()
{
this.InitializeComponent();
}
private void button_Click(object sender, RoutedEventArgs e)
{
show.Text = inputText.Text;
if (check1_cont && check2_cont == true )
{
MessageBox.Show("hi");
}
}
private void check1_Click(object sender, RoutedEventArgs e)
{
check1_cont = true;
}
private void check2_Click(object sender, RoutedEventArgs e)
{
check2_cont = true;
}
}
}
The button is going to cause multiple things to go at once, one of the things I would like to go at once is an instance of a console window of some sort to open.
EDIT 3:
This is meant to be a application for PC but for some reason when I started the project, Visual Studio 2015 community thought it was an application for a phone and is causing problems with PC exclusive commands. If someone could give information on how to fix that as well, that would be great.

You appear to not be using the full desktop framework and instead are using some kind of mobile framework. For example, if you check Silverlight's documentation you can see Debug.Print is not available.
If you check the "Version information" for Print you will see
Version Information
.NET Framework
Available since 2.0
Switch to Debug.WriteLine("hi") instead, that should work in all frameworks, its version information says
Version Information
Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
If you are not seeing output I would recommend showing what your test variables are instead.
private void button_Click(object sender, RoutedEventArgs e)
{
show.Text = inputText.Text;
Debug.WriteLine(check1_cont.ToString());
Debug.WriteLine(check2_cont.ToString());
}

Related

How to make visioforge run

I am having trouble getting a screen capture program to work that I am trying to replicate from a YouTube video. the picture is the error I am getting and my code is supplied. I do not believe my error is in my code I think there is a file I am supposed to run or add somewhere but I can not figure out what I need to do.
IMMAGE OF ERROR WHEN HITTING BUTTON 1 (START BUTTON)
IMMAGE OF THE ERROR WHEN THE PROGRAM IS PUBLISHED
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using VisioForge.Types.OutputFormat;
namespace SCREEN_RECORDER_V2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
videoCapture1.Screen_Capture_Source = new
VisioForge.Types.Sources.ScreenCaptureSourceSettings()
{ FullScreen = true };
videoCapture1.Audio_PlayAudio = videoCapture1.Audio_RecordAudio = false;
videoCapture1.Output_Format = new VFAVIOutput();
videoCapture1.Output_Filename = Environment.GetFolderPath
(Environment.SpecialFolder.MyVideos) + "\\output.avi";
videoCapture1.Mode = VisioForge.Types.VFVideoCaptureMode.ScreenCapture;
videoCapture1.Start();
}
private void button2_Click(object sender, EventArgs e)
{
videoCapture1.Stop();
}
}
}
Based on my test, I reproduced your problem in the picture. After some attempts, I can capture the screen successfully.
First, you could download x64 or x86 exe both by clicking Base package->x64 or x86 in the picture you provided.
Second, please run as administrator to the run the exe.
Third, please install the nuget-package SDK redist base package x86 or x64 and Video Capture SDK redist package x86 or x64.
Finally, after publish the program or directly click the button1 to start the record.

Change the Target App Size when using LaunchUriAsync in Windows Universal Application

I just started playing around with Windows App Development. I am trying to open a browser window from the app on a button click. I want the Target App (in this case my window browser) to be of a smaller size. Better if I can give the size by some means.
I found that DesiredRemainingView will do the trick but it somehow does not.
Any help is
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.System;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace App1
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public ViewSizePreference UseHalf { get; private set; }
//public ViewSizePreference UseHalf { get; private set; }
public MainPage()
{
this.InitializeComponent();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
greetingOutput.Text = "Hello, " + nameInput.Text + "!";
}
async private void Button_Click(object sender, RoutedEventArgs e)
{
//greetingOutput.Text = UseHalf.ToString();
// The URI to launch
var uriBing = new Uri("http://www.bing.com");
// Set the option to show a warning
var promptOptions = new Windows.System.LauncherOptions();
//promptOptions.TreatAsUntrusted = true;
promptOptions.DesiredRemainingView = UseHalf;
// Launch the URI
var success = await Windows.System.Launcher.LaunchUriAsync(uriBing, promptOptions);
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
}
}
}
Yes, we can use the LauncherOptions.DesiredRemainingView to specify the target app’s desired view size. But what kinds of the Windows Browser are you using?
If your Windows Browser is the Internet Explorer or Edge, please make sure that you have closed the Windows Browser before you run the source app, after that it will open a new Windows Browser to show the target app which goes to the www.bing.com website and the LauncherOptions.DesiredRemainingView will work fine.
But if we do not close the Windows Browser(Internet Explorer or Edge), after that when we run the source app, the target app will append as a new tab of the current Windows Browser instead of opening a new Windows Browser. In this way we can not see the effect which the LauncherOptions.DesiredRemainingView should bring.
But if your Windows Brower is the Chrome or other third part browsers, the LauncherOptions.DesiredRemainingView may not wokr. The reason for the third part browsers can not reply on LauncherOptions.DesiredRemainingView to implement the correct behavior may be related with the internal settings of the browsers. Because if we want to implement the launching function correctly, the target app needs to understand the Protocols or Rule or others theory.
The following is the result after closing the Windows Brower Edge before running the App:
Thanks.

Form showing nothing. using CefSharp with Windows form in C#

I am trying to show a webpage in a form using C#. I am using CefSharp to show the webpage (as I would like to test & learn how it works). But since I have worked only on inbuilt webbrowser, I have no idea how to get started with CefSharp(Finding it difficult to get any tutorials). I tried to write this code which executes but the form shows nothing in it. Where am I going wrong ?
Here is my Code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;
namespace chrometest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Cef.Initialize(new CefSettings());
var test = new CefSharp.WinForms.ChromiumWebBrowser("http://www.google.com")
{
Dock = DockStyle.Fill,
};
this.Controls.Add(test);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Edit :
I tried to run the example from https://github.com/cefsharp/CefSharp/tree/cefsharp/41/CefSharp.WinForms.Example
When I try to build the solution, it shows a dialog box saying "Restoring Nuget Package cef.redist.x64 3.2454.1317" with a progresss bar which takes hell lot of time to complete but never completes and after sometime it hangs.
Please help what should I do to get the example running.
The CefSharp project has a few different examples as part of the main project.
Basic Example using Nuget
https://github.com/cefsharp/CefSharp.MinimalExample
More Advanced Examples
https://github.com/cefsharp/CefSharp/tree/cefsharp/41/CefSharp.WinForms.Example
When you installed the project using Nuget it should have opened a Readme.txt file, it contains a lot of useful information.
https://github.com/cefsharp/CefSharp/blob/cefsharp/41/NuGet/Readme.txt
In the context of WinForms there's a few tutorials
http://www.codeguru.com/columns/dotnet/if-you-like-it-put-an-html5-ui-on-it.html
http://thechriskent.com/2014/08/18/embedded-chromium-in-winforms/
For those reading this looking for WPF, there's
http://www.codeproject.com/Articles/881315/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part
http://www.codeproject.com/Articles/887148/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part
More Links
https://github.com/cefsharp/CefSharp.Tutorial
http://thechriskent.com/category/net/cefsharp/

Trying to implement "Enter" event handler to textbook

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Text.RegularExpressions;
using Microsoft.VisualBasic;
namespace HelloWorld
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
string filePathTEST = "";
public MainWindow()
{
InitializeComponent();
// Clearing text event handlers
textBox1.GotFocus += textBox1_GotFocus;
// Enter event handlers for textboxes
textBox1.KeyDown += new System.Windows.Input.KeyEventHandler(textBox1_KeyDown);
}
static void textBox1_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
//enter key is down
}
}
The error I am getting when I try to run the above code is the following:
Cannot implicitly convert type
'System.Windows.Forms.KeyEventHandler' to
'System.Windows.Input.KeyEventHandler'
Then I tried changing the code to System.Windows.Input and then I get the following:
Error 1 'System.Windows.Input.KeyEventArgs' does not contain a
definition for 'KeyCode' and no extension method 'KeyCode' accepting a
first argument of type 'System.Windows.Input.KeyEventArgs' could be
found (are you missing a using directive or an assembly reference?)
The whole point of me doing this is that when I press enter on a textbox, I want to take the text in that textbox and populate a certain text file with it but I am not sure how to go about doing that.
The compiler thinks you mean to use 'System.Windows.Forms.KeyEventHandler' due to the namespace you've added: System.Windows.Forms.
Remove this line and your code should work:
using System.Windows.Forms;
Second, you should use Key instead of KeyCode since that is the WPF variant:
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
{
//
}
}
You're running foul of the rather confused state of Windows client development. System.Windows.Forms is part of the WinForms library, the original UI framework that shipped with .NET 1.0. The project you're working with is written in WPF (Windows Presentation Framework) the new lib that started shipping in .NET 3. There's a lot of overlap, but the two libraries are distinctive.
The class you want is System.Windows.Input.KeyEventArgs. If you go up onto MSDN for the documentation for this class, you'll see that it does NOT in fact have a KeyCode property. It does, however, have a Key property which should do what you want.
I'll leave actually finding and reading the MSDN documentation as an exercise for the reader. :-)

How to find a function of application with ollydbg?

Let's say i released the application below.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World!","Message Box");
}
}
}
Now here is my questions:
How to find the function of button which is responsible to show
message box after pressing the button with ollydbg?
How to disable the button click ?
Notes:this must be done with ollydbg only. Assume that i don't have access to the code.
A step-by-step example would be greatly appreciated.
Using Olly or IDA is a lot of work for nothing.
Use .NET Reflector for decompilation(there is 14-day trial) and download Reflexil plugin to be able to modify code.
Finding the place should not be too hard since you have decompiled sourcecode.
If you cannot find the place you can try one of these:
Connect reflector to Visual studio
Export source code and just run it from Visual studio
If code is obfuscated I cannot help you there, you just must start playing with it till you defeat obfuscation
With Reflexil addon you can simply delete/modify the function
Why not use IDA? You can "easily" nop out the function.

Categories

Resources