2011 Apr 5, 10:00
For my GeolocMock weekend project I intended to use the Bing Maps API to display a map in a WebBrowser control and allow the user to
interact with that to select a location to be consumed by my application. Getting my .NET code to talk to the JavaScript in the WebBrowser control was surprisingly easy.
To have .NET execute JavaScript code you can use the InvokeScript method passing the name of the JavaScript function to execute and an object array of parameters to pass:
this.webBrowser2.Document.InvokeScript("onLocationStateChanged",
new object[] {
latitudeTextBoxText,
longitudeTextBoxText,
altitudeTextBoxText,
uncertaintyTextBoxText
});
The other direction, having JavaScript call into .NET is slightly more complicated but still pretty easy as far as language interop goes. The first step is to mark your assembly as ComVisible so
that it can interact with JavaScript via COM. VS had already added a ComVisible declaration to my project I just had to change the value to true.
[assembly: ComVisible(true)]
Next set ObjectForScripting attribute to the object you want to expose to JavaScript.
this.webBrowser2.ObjectForScripting = this.locationState;
Now that object is exposed as window.external in JavaScript and you can call methods on it.
window.external.Set(lat, long, alt, gUncert);
However you don't seem to be able to test for the existence of methods off of it. For example the following JavaScript generates an exception for me even though I have a Set method:
if (window.external && window.external.Set) {
javascript webbrowser .net technical csharp 2011 Mar 28, 4:06"ILSpy is the open-source .NET assembly browser and decompiler. Development started after Red Gate announced that the free version of .NET Reflector would cease to exist by end of February 2011."
.net tools reflector c# development csharp dotnet technical tool 2010 Aug 20, 11:20
For a new project I'm working on involving IE's installed Accelerators and OpenSearch search providers via the Windows 7
Accelerator Platform, I've created a C#/COM interop class for those APIs.
Download the osinterop.cs interop file here.
technical accelerator csharp com 2010 Aug 14, 5:34pInvoke.net is a wiki for the C# interop declarations for various Win32 functions.
pinvoke c# csharp consle api windows reference wiki technical 2010 Mar 5, 12:33ClickOnce is a .NET app deployment technology that lets you easily install apps with minimal user interaction even from the web. This is what Google Chrome uses to install so easily.
msdn technical development security windows .net csharp programming clickonce google chrome 2009 Jun 20, 9:43How to use the WIA APIs in C#. WIA is Windows API to get images from scanners and cameras. And, as I found out, if you want to use the API in PowerShell try '$deviceManager = new-object -ComObject
WIA.DeviceManager'
video scanner api wia csharp howto programming camera image photo .net webcam technical 2008 May 5, 11:45Free OpenSource C# paint program replacement with many more features than paint.exe =)
windows photo art microsoft csharp .net opensource development free paint 2008 Apr 21, 2:58"This example shows you how to use the Win32 API function SetClipboardViewer to create a Clipboard Viewer application" and the example is in C# and VB.Net.
.net csharp clipboard programming windows setclipboardviewer dllimport 2008 Apr 12, 10:38
For Encode-O-Matic, my encoding tool written in C#, I had to figure out the appropriate DllImport declarations to use IDN Win32
functions which was a pain. To spare others that pain here's the two files CharacterSetEncoding.cs and NationalLanguageSupportUtilities.cs that declare the DllImports for IdnToUnicode, IdnToAscii,
NormalizeString, MultiByteToWideChar, and WideCharToMultiByte.
encodeomatic boring csharp widechartomultibyte idn tool dllimport 2008 Feb 16, 11:53The free downloadable versions of Visual Studio
microsoft visual-studio csharp c c++ trial express free 2007 Oct 8, 3:15Microsoft Research is working on Singularity, a new managed microkernel OS.
msdn microsoft channel9 video singularity os research csharp 2007 Feb 22, 7:23A C# graph layout library for free from Microsoft Research.
.net free graph microsoft research visualization csharp library glee 2006 Jun 27, 3:12Home to papers and code from Microsoft Research
microsoft research free programming csharp 2006 Jun 27, 3:08The Data Visualization Components give you six .NET components for adding data visualization into your own programs: - Treemaps - Bubble Charts - Piano Rolls - Spire Charts - Thread Trees - Time
Series Charts
csharp programming free visualization microsoft 2006 Jan 16, 11:59A Better Random Number Generator
development math random-number java c csharp algorithm csc