background preloader

Pinvoke.net: the interop wiki!

Pinvoke.net: the interop wiki!

- Programming, Life an... In my previous post I talked about Silverlight 2 unit testing, and I decided the next natural step was to figure out how to integrate Silverlight testing in a continuous integration process. Personally I’m a big fan of this development practice, and have practiced it with great success on several projects. One of the challenges of integrating Silverlight tests into a CI process is the fact that the Silverlight test framework runs inside the browser and you cannot write Silverlight tests using your favorite test framework like NUnit or MSTEST. The power of CI is to build your software as new code is added to the source control, run automated tests, package the software and deploy it to a testing environment. If the tests fail you stop the deployment and alert the development team. There are several tools you can use to set up a CI server. As you can see the WatiN API is straight forward, you can grab hold of form elements and interact with them.

Threading in C# - Free E-book Threading in C# Joseph Albahari Last updated: 2011-4-27 Translations: Chinese | Czech | Persian | Russian | Japanese Download PDF Part 1: Getting Started C# supports parallel execution of code through multithreading. A C# client program (Console, WPF, or Windows Forms) starts in a single thread created automatically by the CLR and operating system (the “main” thread), and is made multithreaded by creating additional threads. All examples assume the following namespaces are imported: using System; using System.Threading; class ThreadTest{ static void Main() { Thread t = new Thread (WriteY); t.Start(); for (int i = 0; i < 1000; i++) Console.Write ("x"); } static void WriteY() { for (int i = 0; i < 1000; i++) Console.Write ("y"); }} The main thread creates a new thread t on which it runs a method that repeatedly prints the character “y”. Once started, a thread’s IsAlive property returns true, until the point where the thread ends. Done static void Go(){ if (! Done Done (usually!) Join and Sleep

API Monitor: Spy on API Calls and COM Interfaces (New 32-bit and 64-bit Versions!) :: rohitab.com API Monitor API Monitor v2 is currently in Alpha. Installers for both 32-bit and 64-bit versions are now available. Download Now. Save Capture and Monitor Metro apps using the latest release, which includes 2500 new API’s. API Monitor is a free software that lets you monitor and control API calls made by applications and services. 64-bit Support API Monitor supports monitoring of 64-bit applications and services. Main Window Summary View Capture Filter Parameters Structures Breakpoints Breakpoint/Structure Unions Arrays Threads Display Filter Normal Decoded Buffer View Structure/Buffer Dynamic Arrays Pointer-to-Array GUID Decoding Memory Editor External DLL Filter Call Stack Decode API Error COM Monitoring Process View Services Hook Service Hook Process Options: Monitoring Options: Memory Options: Dll's API Loader Custom DLL Windows 2000, Windows XP 32-bit, Windows XP 64-bit x64, Windows Vista 32-bit, Windows Vista 64-bit x64, Windows 7 32-bit, Windows 7 64-bit x64, Windows 8 32-bit, Windows 8 64-bit x64

DllExports - Common Problems and Solutions Introduction There are numerous guides on how to export functions from DLLs, but somehow when you start doing DLLs yourself, you run into problems. If you create a DLL in one language and want to use it from another, there are some pitfalls to be aware of. The key to solving problems is really understanding what is going on. Background Sooner or later, you will find the need to use a DLL with exported functions. Let's go back a few years. VB6 was quite slow, and lacked elementary things like unsigned integers and bit shifting, and I think without being able to use DLLs made in other languages, VB6 would never have had as much success as it did. When speed really was needed someone just made a DLL in C or C++, or in any other language. How could VB6 call C++ DLLs? int Add(int a, int b) { __asm { ADD AX, BX RET } } To call this from VB6 any other language. Creating a DLL Project with a Minimal Stub This article is primarily about managing the exported names and ordinals. DLLMain #include "..

.NET Column: Safe Thread Synchronization Safe Thread Synchronization Jeffrey Richter By far, the most common use of thread synchronization is to ensure mutually exclusive access to a shared resource by multiple threads. In the Win32® API, the CRITICAL_SECTION structure and associated functions offers the fastest and most efficient way to synchronize threads for mutually exclusive access when the threads are all running in a single process. In this column, I'm going to explain how this common use of thread synchronization is exposed via the .NET Framework. The Great Idea The .NET Framework employs an object-oriented programming structure. Here's the basic idea: every object in the heap has a data structure associated with it (very similar to a Win32 CRITICAL_SECTION structure) that can be used for thread synchronization. In Win32, an unmanaged C++ class with this design would look like the one in Figure 1. Implementing the Great Idea When the common language runtime (CLR) initializes, it allocates a cache of SyncBlocks.

John Howard - Hyper-V and virtualization blog : How-to use MakeCert for trusted root certification I wasn't originally going to blog this, but my colleague, Mat, and I were discussing encryption late last night. Mat was specifically interested in its use for security traffic in the context of SQL Reporting Service, but we got massively sidetracked and ended up talking about IPSec, MAPI and all sorts of other things along the way. Interesting, none-the-less. One thing Mat wanted to demonstrate was the use of a certificate for encrypting traffic between a SQL Reporting Server and a back-end database. Why not install a certificate server, he said. MakeCert.exe allows you to (for test/dev purposes) generate both a trusted root certificate and a certificate signed by that trusted root certificate for encryption purposes (also for signature purposes, but that wasn't relevant in this context). From the command prompt, in the directory where you downloaded makecert.exe, enter all the green bits below on a single line (ie exclude my comments in the right-most column).

Hate Add-Member? (PowerShell's Adaptive Type System to the Rescue) - Windows PowerShell Blog Do you hate Add-Member as much as I do? Wait - maybe you aren't familiar with Add-Member or the glory of PowerShell's Adaptive Type System. (ATS). When I looked at the .NET type system, my reaction was "....almost". There are 4 main components of ATS: Type Adapters. A lot of technologies implement their own type systems within .NET. We adapt that object so it looks like this: ExitCode : 0 Name : AeLookupSvc ProcessId : 1068 StartMode : Auto State : Running Status : OK Extended Metadata System .NET gives you a meat-and-potatoes type system giving you properties, fields, methods, interfaces and events. Type MashUps One of the most powerful and least used aspects of PowerShell is it's type mashup system. Dynamic Types In addition to extending a TYPE, you can dynamically extend any instance of a type. Adds a user-defined custom member to an instance of a Windows PowerShell object. Here is an example of it in use: SOOOO - why do I hate Add-Member? <? Lessons learned/relearned: Enjoy!

Chickenfoot Click the link below to install Chickenfoot. If this is the first time you've installed Chickenfoot, Firefox will display a yellow warning bar asking whether you want to install it. Install Chickenfoot 1.0.7 (for Firefox 3 only; released December 18, 2009) Chickenfoot is copyright © Copyright (c) 2004-2008 Massachusetts Institute of Technology. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Old Versions Chickenfoot 1.0.6 (released October 19, 2009)

.NET Column: Calling Win32 DLLs in C# with P/Invoke Calling Win32 DLLs in C# with P/Invoke Jason Clark Code download available at:NET0307.exe(133 KB) I have noticed a trend in my programming of late, and that trend has inspired the topic of this month's column. Recently, I have done a fair amount of Win32® Interop in my Microsoft® .NET Framework-based apps. I am not saying that my apps are full of custom interop code, but from time to time I bump into a minor, but nagging, inadequacy in the .NET Framework Class Library that can quickly be alleviated by a call into the Windows® API. As I think about it, any feature limitation in the .NET Framework version 1.0 or 1.1 class library that is not shared by Windows doesn't come as a huge surprise. As an increasing developer base moves its production applications to managed code, it seems only natural that there will be even more occasions for developers to dip down into the underlying operating system for some critical tidbit of functionality—at least for the time being. Enter P/Invoke Style Right.

Related: