I am making my first Skype app that can simply message a user but when I debug I get a exception that crashes my app.
Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using skype_app;
using SKYPE4COMLib;
namespace skype_app
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
var oskype = new SKYPE4COMLib.Skype();
oskype.PlaceCall(textBox1.Text);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
var oskype = new SKYPE4COMLib.Skype();
oskype.SendMessage(textBox1.Text, textBox2.Text);
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
}
}
i have use some extra references
references list:
Microsoft.Csharp
SKYPE4COMlib
SkypeDialoglib
system
system.core
system.data
system.data.DataSetEXTensions
system.deployment
system drawing
System.Windows.forms
System.xml.linq
Here is the exception i get:
System.RUntime.InteropServices.ComException : {"connection refused"}
So I guess my main question is why does my connection get refused when Skype dose not even open the dialogue asking if I want to allow the connection ?
The issue is that you're trying to debug in Visual Studio. Unfortunately, according to Skype themselves, they do not support using this API & debugging in VS:
Per the link:
The most comment cause for this is you are trying to debug the program
in Visual Studio. Going forward we will not be able to support using
the visual studio hosting process for debugging. You can turn it off
by:
Open your project in VS
Open your projects properies
click the debug tab
untick "use visual studio hosting process"
rebuild your application and begin debugging and it should work ok.
i face the same issue. this way i solved it.
here is my code
Skype skype;
skype = new SKYPE4COMLib.Skype();
Call call = skype.PlaceCall(txtPhonenNo.Text);
first thing login to skype and go to Tools > option > advanced settings
your screen would look like
click on manage other program's access to skype
then another window will come which will show all program name which try to access skype. if any exist just select all and remove it.
then run your program again and go to that screen where this option was available called click on manage other program's access to skype
click there and a windows will come which will display the name of your apps just select that name and click on change button then another window will come which looks like
in that window just select the option called allow this program to access skype then a dialog come on the skype window which looks like
where you need to click on allow access button and then your job will be done. hope this will help.
Related
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.
Trying to debug an application that is opened by opening a text-file associated to open the application being debugged.
Is there a way to start the debug and wait for the application to be called without the "Start external program" start action?
Ultimately I'm trying to get the file information of the text-file that opens the application, so that it can be used in the application as a "saved project" file.
I have a text-file named "myFile.cats", I've associated this file extension to open with my executable solution made by the visual studio application in the debug bin.
I've tried using the StartupEventArgs, but it doesn't come back with anything obviously since it's not being called from an external file. So I don't seem to have a way of testing this to make sure it works...
Any help would be greatly appreciated.
using Caliburn.Micro;
using ApplicationWPFUI.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using ApplicationLibrary;
namespace ApplicationWPFUI
{
public class Bootstrapper : BootstrapperBase
{
public Bootstrapper()
{
Initialize();
}
//myFile.cats File opens this exe and the 'OnStartup' runs, where is the myFile.cats information being passed in?
protected override void OnStartup(object sender, StartupEventArgs e)
{
if (e.Args.Count() != 0)
{
//Save the startupEventArgs to a variable
GlobalConfigs.FileList.Files = e.Args.ToList();
}
DisplayRootViewFor<MainViewModel>();
}
}
}
I was doing it correctly already, with one slight change that needed to be made.
The information needed for the file that opens the application is in the GlobalConfigs.FileList.Files = e.Args.ToList();. But, I only need the first variable in that list.
So calling the following does the trick:
GlobalConfigs.FileList.Files = e.Args[0].ToString();
Obviously, the StartupEventArgs will not always have information in there, since I'll be calling the application by itself as well as opening it with associated files. So I just wrapped that in an if statement:
if (e.Args.Count() != 0) {
GlobalConfigs.FileList.File = e.Args[0].ToString();
}
And Bobs your uncle.
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());
}
I have successfully built a C# Word 2013 project (ReportGenerator) that opens an MS ACCESS database and generates a MS WORD 2013 report. The results are very good. The issue I have is at the moment it can only be run from inside Visual Studio. My boss wants it to run via a windows form.
I have the competence to build a new project (ReportRunner) that contains a windows form with a datagrid, populate it and put a button on it. What I lack is the competence to know how to:
Open the report generation code from ReportGenerator in the
onclick event of ReportRunner
Pass a variable from ReportRunner to ReportGenerator so to avoid
hard coding.
I was expecting to be able to write a line like “ReportGenerator.ThisDocument.ThisDocument_Startup” in the click event of the button. This isn't happening.
The significant bits of code in my projects are:
ReportGenerator
namespace ReportGenerator
{
public partial class ThisDocument
{
ReportData reportData = new ReportData();
public void ThisDocument_Startup(object sender, System.EventArgs e)
{
int idToLookFor = 2;
reportData = MyFunctionToReadAccessData(idToLookFor);
MyFunctionToPutDataIntoReport();
}
}
}
ReportRunner
using ReportGenerator;
namespace ReportRunner
{
public partial class Form1 : Form
private void button1_Click(object sender, EventArgs e)
{
int idToLookFor = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
//HOW DO I MAKE IT OPEN REPORT GENERATOR ThisDocument_Startup
// AND PASS IT THE idToLookFor
}
}
Update:
I'm having trouble understanding your comment so here's a few updates:
You can call method from a Document-level Addin from a seperate C# WinForm using the link I provided. It doesn't matter if it's an Application-level addin or a Document-level addin - the approach is the same. See this link.
Why did you build a ReportRunner Form project that is separate from your ReportGenerator Add-in project? As I said below, you can create a single VS solution with 2 projects - one is a Document-level addin, the other is a WinForm and you can simply call the WinForm from the Ribbon associated with the addin.
I assume that you're asking how to call a function from a Word Addin from a Winform? I recently explained how to do this here: How to call a VSTO AddIn method from a separate C# project?
That being said, I don't recommend doing this becaues you can simply package your WinForm together with your Addin and then open it like this using a Ribbon:
private void button1_Click(object sender, RibbonControlEventArgs e)
{
Form1 aForm = new Form1();
aForm.Show();
Can you set up a bare bones WCF project in Visual Studio Express 2013 for Windows Desktop C#
The walkthrough described in the MS Getting Started tutorial (http://msdn.microsoft.com/en-us/library/ms734712(v=vs.110).aspx) refers to Visual Studio (NOT the express edition), which has templates that are not available in Visual Studio Express (WDExpress.exe), specifically WCF Service Library.
How do you start something similar in WDExpress.exe without the templates?
Incidentally, I've tried copying templates over from Visual Studio Express for Web 2013 (VWDExpress.exe), but without success.
Here's a possible workaround for http://msdn.microsoft.com/en-us/library/bb386386.aspx using Visual Studio Express 2013.
All the steps are carried out in VSE 2013 for Windows Desktop (WDExpress.exe)
Step 1 - Start a new project using the template for Class Library - it should generate a project with the default name ClassLibrary1
Step 2 - Go to References (in Solution Explorer) and add references to System.ServiceModel and System.Runtime.Serialization
Step 3 - Create a new class called WCFServiceLibrary1.cs with the following content
using System.ServiceModel;
namespace ClassLibrary1
{
public class WCFServiceLibrary1 : IWCFServiceLibrary1
{
public string GetData(string value)
{
return string.Format("You entered: {0}", value);
}
}
}
Step 4 - Create a new class called IWCFServiceLibrary1.cs with the following content
using System.ServiceModel;
namespace ClassLibrary1
{
[ServiceContract]
public interface IWCFServiceLibrary1
{
[OperationContract]
string GetData(string value);
}
}
Step 5 - You need a client to run the WCF, so create a Windows form, which will have the default name Form1.cs, and add three controls; a textBox, (textBox1), a label (label1), and a button (button1)
Step 6 - in [Design] mode, double click on button1 and edit the action so that Form1.cs looks like this
using System;
using System.Windows.Forms;
namespace ClassLibrary1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
ClassLibrary1.WCFServiceLibrary1 client = new ClassLibrary1.WCFServiceLibrary1();
label1.Text = client.GetData(textBox1.Text);
}
}
}
Step 7 - add a Main class called Program.cs with the following content
using System;
using System.Windows.Forms;
namespace ClassLibrary1
{
public class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 form = new Form1();
Application.Run(form);
}
}
}
Step 8 - Open the Application tab in project properties (PROJECT >> ClassLibrary1.properties) and set Output Type to Windows Application and Startup Object to ClassLibrary1.Program
Step 9 - F5 will launch the form, which will behave as described at the end of the walkthrough under To build a client application
So, what this method does NOT do is go through "Testing the Service" in the walkthrough. Also, it shortcuts a few steps and it bundles the WCF in the same project as the Windows form. Hopefully, it provides bare-bones working code that you can develop and adapt for your application.