Sunday, December 28, 2008
Microsoft's bizspark program
1. You must pay Microsoft a $100 fee after three years.
2. You must not have had an operating business with your idea (startups only).
3. You must be in the business of developing software.
4. You must be private
5. You must have < 1M in annual revenue (not a problem in my case)
Also, you have to find a sponsor before you can enroll. If you are interested in enrolling you will be presented with a list of available businesses on the enrollment page willing to help sponsor along with their contact email address.
Check it out and Good Luck!
Friday, November 7, 2008
Writing a thread-safe console log
I'm going to give the example in VB .NET but it will work easily in C# also.
First off, create a simple delegate:
Public Delegate Sub LogSafeCall(ByVal s As String)
Then create a Sub to provide thread safety. I will use a listbox in this example but you could also use a textbox. The reason for choosing the listbox is due to the fact that it stores strings in a collection. A textbox would require appending to the text property, and...since strings are immutable, this would create many seperate strings in memory.
Here's the Threadsafe logging function, m_console is a listbox control:
Private Sub Log(ByVal s As String)
If (m_console.InvokeRequired) Then
Dim d As LogSafeCall = New LogSafeCall(AddressOf Log)
m_console.Invoke(d, s)
Else
m_console.Items.Add(s)
'if you wish to have the last item selected then uncomment the following:
'm_console.SelectedIndex = m_console.Items.Count - 1
End If
End Sub
Since I wanted to Log in a file as well as display the messages into the textbox, I created the following class and inherited the TextWriter streaming class So here is the complete code:
Option Explicit On
Option Strict On
Imports System.IO
Imports System.Windows.Forms
Public Delegate Sub LogSafeCall(ByVal s As String)
Public Class ListBoxWriter
Inherits TextWriter
Private m_console As ListBox
Public Sub New(ByVal console As ListBox)
m_console = console
End Sub
Public Overrides ReadOnly Property Encoding() As System.Text.Encoding
Get
Return System.Text.Encoding.ASCII
End Get
End Property
Public Overrides Sub WriteLine(ByVal value As String)
MyBase.WriteLine(value)
Log(value)
End Sub
Private Sub Log(ByVal s As String)
If (m_console.InvokeRequired) Then
Dim d As LogSafeCall = New LogSafeCall(AddressOf Log)
m_console.Invoke(d, s)
Else
m_console.Items.Add(s)
'm_console.SelectedIndex = m_console.Items.Count - 1
End If
End Sub
End Class
Thursday, October 30, 2008
New Dell Laptop XPS M1730
Thursday, October 16, 2008
CodeSmith Review
Generate Code based on database schema - using included examples
Port my own code into a template for re-use
Generate both VB and C# Code
The possibilities are endless, you can create libraries of code you are confident works and you wish to reuse over and over. There's a handy properties pane similar to the one in Visual Studio that you can use to change the custom properties you define in the template file. Once the template file is written, all that's required is setting a few properties in the properties pane and generating the code.
There's a few videos to help you get started on the Codesmith website http://www.codesmithtools.com/ . I highly recommend the product if you find yourself writing similar code all day. Hey, you can do a days work in 5 minutes once the template is in place! Look good all day while hardly breaking a sweat. It is a bit pricey for those, like me that are buying this themselves for around $400, but worth it in time savings.
Wednesday, October 15, 2008
Seagate 1.5 TB Drive
Saturday, October 11, 2008
SQLCE and ASP.NET
Here's how I solved the problem:
There's a command line tool in the Microsoft SDKs folder for creating entities for various databases called SQLMetal. It's in the folder: \Program Files\Microsoft SDKs\Windows\v6.0A\Bin\SqlMetal.exe
The use of the program is as follows:
SqlMetal.exe MyData.sdf
example: SqlMetal.exe northwind.sdf /code:northwind.cs
That solved the problem and created the Sql Compact 3.5 entity.
I created a batch file to make it easier (see below) :
@echo off
Set SQLMetalPath="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin"
Set DBPath="C:\Users\Jonathan\Documents\Visual Studio 2008\WebSites\CSharpSolutions_8_2008\App_Data"
Set AppCodePath="C:\Users\Jonathan\Documents\Visual Studio 2008\WebSites\CSharpSolutions_8_2008\App_Code"
cd %DBPath%%SQLMetalPath%\SqlMetal.exe CSharpSol.sdf /code:%AppCodePath%\CSharpSol.cs
Here's problem #2 I had using SQL Compact 3.5 but the resolution came from Steve's site:
Force SQLCE to run under ASP.NET
Steve Lasker posted blog entry on how to use SQLCE under ASP.NET using the pre-release version of the SQLEV. Under SQLEV you set a flag that would tell the SQL Connection, “yes I know this isn’t supported, but let me do it anyway”:
AppDomain.CurrentDomain.SetData("SQLServerEverywhereUnderWebHosting", true)
As you can see the name of the product is right there in the key. Well they changed the name of the product and so they changed the name of the key. So, if you were using the beta for development and are now switching over to the release version of SQLCE , you will need to change the key:
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true)
That should allow you to use the database under ASP.NET. Now you can revel in the fact that you are swimming in unsupported waters!
Note:
I placed the AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true) line of code in my default page's constructor in the code behind section:
Hope that helps
Thursday, September 25, 2008
My Thoughts on the Financial Crisis
This is a bit off topic from the computing subject, but we are living in a remarkable time in history right now. The financial markets are about to crash probably next week. Washington Mutual just folded today and I'm certain more will follow soon. In a way, I feel that these companies deserve to fail because they were imprudent and lacked integrity. My reaction at this point is to let the market do what it does for the next few weeks before any government intervention is introduced. I know that it will hurt business since the money supply will be tight for the foreseeable future, but that's the cost of these times. The markets will eventually work themselves out without intervention from the Bush Administration, although it may be quite painful. I don't believe the role of government should be insurance for failing banks. Perhaps at the end of this mess, common sense and integrity will return to the business of banking. Well, I'm not much of a banker, and perhaps I'm all wet, but that's the way I see it.
