Check Paypal account balance and transactions via C# API

How to use Paypal-API in CsharpAfter we had a look at how to sent push notifications via C# recently, there are plans for the next C# article today. This time it’s about how to read account balance, sales and transactions and other things of a Paypal account.
First some basic information. Although Paypal is an “online account”, in many ways it differs from an online (giro) account of a “classic” bank. For example, Paypal does not support the Homebanking Computer Interface (HBCI) to retrieve account information or send payments. Instead, Paypal offers different APIs (REST, SOAP, + SDKs, …), which differ not only in structure and technology, but especially in the range of functions. For our purposes we will use the so-called “NVP / SOAP API” and connect to it […]

Manipulate any program by using C#

Manipulate any program by using CsharpThis article is going to be all about how you can control, customize and extend other programs using C#. As an example scenario we’re going to be extending the default Windows program Notepad with a custom function.
The C# application will modify all running instances of Notepad by adding a new button to the UI and listening for clicks on the button. A click on the button will convert the text in the Notepad text field into HTML using a Markdown parser (What is Markdown?) and display the HTML in our application.
If you follow the article, the finished product is going to look like this:

The article will have you construct the program step by step. If you want to read the […]

How to use C# Web Service Client with BasicAuth (for SAP)

SAP Webservice with .NET Webservice Client and BasicAuthNo matter how frumpy SAP may look most of the time, nevertheless you can build such modern things like web services inside the SAP system. Even the WSDL (Web Service Description File) file can be generated in SAP. I read about this feature (WSDL generation) just at the right time, because recent days I should write a web service in SAP which should be triggered by a C# application.
In .NET web services can easily integrated via their WSDL file by using the WebReference feature of Visual Studio. Therefore Visual Studio generates a so-called proxy class from the given WSDL file which can be used to call all functions of the webservice without thinking too much.
As far as in theory. In practice I had to choose the security mode for the web service in […]

How to use alias for using-directives and namespaces in C#

Anyone who has already written one or the other program in Visual Studio with C# probably knows the following problem. Sometimes you use different libraries (Dlls) from different developers/vendors. Partly also libraries that fulfill similar purposes. This might go well, but it doesn’t have to.
Often you will get confronted with an error message like this: “‘XYZ’ is an ambiguous reference between ‘LibraryA.XYZ’ and ‘LibraryB.XYZ’”
What next? In the following I’ll explain how to solve this kind of error by taking the example of the AForge library. For instance we profess that we included the following using-directives into our program.
using System.Drawing;
using AForge.Imaging;
So now, if we use the class “Image” in our program, we will see the following error message, which result from the fact that there are two “Image” classes referenced. One in the System.Drawing namespace as also one in the AForge.Drawing namespace. Visual Studio (and later on it’s compiler) doesn’t know which Image class to […]

Javascript’s escape() in C# – a C# equivalent to the escape()-function

csharp_vs_javascriptThe .NET framework provides a large number of ways to encode HTML code and URLs. There exist, for example, Uri.EscapeDataString(), Uri.EscapeUriString(), System.Web.HttpUtility.UrlEncode(), System.Web.HttpUtility.UrlPathEncode(), System.Web.HttpUtility.HtmlEncode() or System.Web.HttpUtility.HtmlAttributeEncode().
However, if you are looking for equivalent functionality to Javascript’s escape(), so you will be disappointed by all of these aforementioned functions. None of these inherently with the .NET framework delivered functions is equivalent to the Javascript escape() function.  For better understanding, I made the following example:
The test text is in german, because the ‘ä’ is a nice character to show the problems. Translated to english it means: “Raffi’s annoying C# testcode”.

// Original source text
// Raffi’s ärgerlicher C# Teststring/Testcode.

// Javascript original (produced by escape())
// Raffi%27s%20%E4rgerlicher%20C%23%20Teststring/Testcode.

// Uri.EscapeDataString():
// Raffi’s%20%C3%A4rgerlicher%20C%23%20Teststring%2FTestcode.

// Uri.EscapeUriString():
// Raffi’s%20%C3%A4rgerlicher%20C#%20Teststring/Testcode.

// System.Web.HttpUtility.UrlEncode():
// Raffi%27s+%c3%a4rgerlicher+C%23+Teststring%2fTestcode.

// System.Web.HttpUtility.UrlPathEncode():
// Raffi’s%20%c3%a4rgerlicher%20C#%20Teststring/Testcode.

// System.Web.HttpUtility.HtmlEncode():
// Raffi's ärgerlicher C# Teststring/Testcode.

// System.Web.HttpUtility.HtmlAttributeEncode():
// Raffi's ärgerlicher C# Teststring/Testcode.

But I would not blog about it if I did not have […]