A while ago I posted an item about Visual Studio 2008 Power Commands. Although it really adds some nice features to the IDE it also added a less nice feature. It turned out that Power Commands was able to let Visual Studio 2008 crash.
I wanted to add some items to the toolbox, so I clicked on the 'Choose Items' menu item in the contextmenu of the toolbox. After a few seconds of loading the active instance of Visual Studio was closed.
The following error was logged into the Event Logs:
.NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (66DE5E00) (80131506)
After reading a bit on the Internet it turned out that Power Commands could be source. After removing Power Commands the issue was disappeared as well.
Power Commands is still in development, however there hasn't been a lot of activity lately. You can get the latest version here.
To update this blog I use Windows Live Writer. After playing around for a while I discovered that this application can be extended with plugins. So I decided to spend my sunday afternoon on trying to make my own plugin. And it turned out that this is actually pretty easy and interesting as well.
To create your own plugin, just open up Visual Studio, create a new class library and add a reference to the Windows Live Writer API. This API can be found in c:\program files\Windows Live\Writer.
After that you can specify what kind of plugin you'd like to create. There are several types.
Example:
Because code says more than words, a short example.
1: Imports WindowsLive.Writer.Api
2: Imports System.Windows.Forms
3:
4: <InsertableContentSource("PluginName"), _
5: WriterPlugin("310A4D7F-97F4-4db7-9A4A-DF6E88A4AF3D", _
6: "PluginName", _
7: PublisherUrl:="http://blogs.windowsclient.net/MathieuRoseboom", _
8: Description:="Description", _
9: ImagePath:="Image.png")> _
10: Public Class MyPluginContent
11: Inherits ContentSource
12: ' Methods
13: Public Overrides Function CreateContent(ByVal dialogOwner As IWin32Window, ByRef content As String) As DialogResult
14: Dim frm As New frmMain
15:
16: frm.ShowDialog()
17: If (frm.DialogResult = DialogResult.OK) Then
18: content = form.Code
19: Return DialogResult.OK
20: End If
21: Return DialogResult.Cancel
22: End Function
23: End Class
24:
25:
The pluginarchitecture uses attributes to determine the plugins. The InsertableContentSource attribute defines the plugintype. The WriterPlugin attribute defines that this class is a Windows Live Writer plugin and Windows Live Writer will automatically register this plugin.
The class inherits from ContentSource. This basically means that this plugin inserts content. (what's in the name)
The content parameter which is given By Reference can be filled with the end HTML code.
Resources:
Recently I 'discovered' this nice add-on for Visual Studio. I know, it's out for a while, but I think it's a very nice tool which helps you doing several standard tasks just a little bit quicker.
This add-in integrates into Visual Studio 2008 and will add several menu items on several places like opening a command prompt or open the folder containing the current project.
For more information: http://code.msdn.microsoft.com/PowerCommands. You can download the latest version there as well.
Some time ago I decided to make my very first tool for Windows Mobile. I wanted to be able to make screenshots easily. Of course there where already some tools available to achieve this but since I'm a developer I wanted to create it on my own.
The result is PocketScreen.
It includes a timer and the option to make several screenshots at a time. (with the timer as interval)
Very simple, very straightforward, but it certainly does the job.
The code to actually create the screenshot is also pretty easy with some P/Invoke's
' imports the GDI BitBlt function that enables the background of the window
' to be captured
<DllImport("coredll.dll")> _
Private Shared Function BitBlt(ByVal hdcDest As IntPtr, _
ByVal nxDest As Integer, _
ByVal nyDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As Int32) As Boolean
End Function
<DllImport("coredll.dll")> _
Public Shared Function GetDC(ByVal hWnd As IntPtr) As IntPtr
End Function
<DllImport("coredll.dll")> _
Public Shared Function ReleaseDC(ByVal hWnd As IntPtr, _
ByVal hDC As IntPtr) As Integer
End Function
''' <summary>
''' Creates a screenshot of the current screen, including taskbar and softkeys and saves it at the given location.
''' </summary>
''' <param name="Filename">Filename of the screenshot</param>
''' <param name="ImageFormat">Type of image (PNG, JPG, GIF, BMP)</param>
Private Function CaptureScreen(ByVal Filename As String, _
ByVal ImageFormat As System.Drawing.Imaging.ImageFormat) As Boolean
' Get the handle of the form's device context and create compatible
' graphics and bitmap objects
Dim srcDC As IntPtr = GetDC(IntPtr.Zero)
Dim bm As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
Dim graphics As Graphics = graphics.FromImage(bm)
' Get the handle to the graphics object's device context.
Dim bmDC As IntPtr = graphics.GetHdc
' Copy the form to the bitmap
BitBlt(bmDC, 0, 0, bm.Width, bm.Height, srcDC, 0, 0, &HCC0020)
' Release native resources
ReleaseDC(IntPtr.Zero, srcDC)
graphics.ReleaseHdc(bmDC)
graphics.Dispose()
' Save the bitmap
Try
bm.Save(Filename, ImageFormat)
Return True
Catch ex As Exception
Return False
End Try
End Function
The function CaptureScreen is just a wrapper about the BitBlt function which is in the coredll.dll.
Welcome at my blog. I'll use this blog to post some programming issues related to Windows Mobile (.NETCF).