After updating an application used as a COM server my application failed to access it correctly.
What to do?
Open a DOS prompt navigate to the directory of the new COM server,
type:
TheComServerName /regserver
To unregister a COM server type:
TheComServerName /unregserver
Friday, November 19, 2010
Tuesday, November 02, 2010
Does it work? Yes -> don't f#%k with it
Running an ubuntu server 8.04 without any really hazel. Then you get stupid thoughts. There is an upgrade 10.10 why don't I upgrade. Its newer and probably better,faster,cooler.
You don't think it through, yeeah I want the latest, no backup, haven't time.
Then the shit hits the fan, during the upgrade you get questions about different config-file, do you want to replace or keep, you really don't know for sure, but you want the new version up and running NOW.
Then when upgrade is completed, the server doesn't start. Then you remember all you data that might be lost due to the Raid Server that wont start. Database, subversion data, music...
But there are help out there, I finally figured out what the problem was. The two disks was targeting different raids md0 and md_d0 . There are heroes out on the net, mine today is called Milli
http://ubuntuforums.org/showthread.php?t=1168360&page=2
Thanks Milli, your post made my day.
You don't think it through, yeeah I want the latest, no backup, haven't time.
Then the shit hits the fan, during the upgrade you get questions about different config-file, do you want to replace or keep, you really don't know for sure, but you want the new version up and running NOW.
Then when upgrade is completed, the server doesn't start. Then you remember all you data that might be lost due to the Raid Server that wont start. Database, subversion data, music...
But there are help out there, I finally figured out what the problem was. The two disks was targeting different raids md0 and md_d0 . There are heroes out on the net, mine today is called Milli
http://ubuntuforums.org/showthread.php?t=1168360&page=2
Thanks Milli, your post made my day.
Friday, October 22, 2010
Windows cmd : fsutil
Create an empty file of an arbitrary size
This command is useful if you quickly need a file of a certain size that contains only zeros.
fsutil file createnew filename length
Create a hardlink
A hardlink is useful when you want to make the same file appear in different folders. Even if you can see it in many places on your drive, the hard drive space is allocated for only one instance.
The file is physically deleted when the last hardlink is removed.
fsutil hardlink create new_filename existing_filename
Sunday, June 06, 2010
Function SetMaxNumberOfDecimals()
The problem:
You has to show data (doubles) to the user but you don't know the size of the data.
if data is 0.34567890123 then you don't want to show all the decimals you might want to show 0.346.
Ok, then you user .Format(MyDbl,"F3"). But if the data in is 12345.6789012345 you doesn't want the decimals
to be shown 12345.679 because you doesn't have that kind of resolution of you measured data.
The Fix:
We make a function that limits the number of decimals and looks for number of significant digits.
''' <Summary>>
''' Limit number of decimal shown for a Double
''' In (0,3) -> 0.000, In (33.456789,3) -> 33.45, In (334.56743,3) -> 334.6)
''' In (12345.12345,6) -> 12345.1
''' </Summary>>
''' <param name="myVal">Value to make string of</param>
''' String with limited number of decimals.</returns>
''' <remarks></remarks>
Function SetMaxNumberOfDecimals(ByVal myVal As Double, ByVal decimals As Integer) As String
Dim x As Double = 0
' Get number of power of 10, exclude 0
If myDbl <> 0 Then
x = Math.Log10(Math.Abs(myDbl))
End If
' Round number of PowerOf10
x = Math.Floor(x)
' Calc number of decimal and handle exceptions
x = decimals - x
If x < 0 Then x = 0
If x > decimals Then x = decimals
Dim z As String = "F" + x.ToString
Return Format(myVal, z)
End Function
You has to show data (doubles) to the user but you don't know the size of the data.
if data is 0.34567890123 then you don't want to show all the decimals you might want to show 0.346.
Ok, then you user .Format(MyDbl,"F3"). But if the data in is 12345.6789012345 you doesn't want the decimals
to be shown 12345.679 because you doesn't have that kind of resolution of you measured data.
The Fix:
We make a function that limits the number of decimals and looks for number of significant digits.
''' <Summary>>
''' Limit number of decimal shown for a Double
''' In (0,3) -> 0.000, In (33.456789,3) -> 33.45, In (334.56743,3) -> 334.6)
''' In (12345.12345,6) -> 12345.1
''' </Summary>>
''' <param name="myVal">Value to make string of</param>
''' String with limited number of decimals.</returns>
''' <remarks></remarks>
Function SetMaxNumberOfDecimals(ByVal myVal As Double, ByVal decimals As Integer) As String
Dim x As Double = 0
' Get number of power of 10, exclude 0
If myDbl <> 0 Then
x = Math.Log10(Math.Abs(myDbl))
End If
' Round number of PowerOf10
x = Math.Floor(x)
' Calc number of decimal and handle exceptions
x = decimals - x
If x < 0 Then x = 0
If x > decimals Then x = decimals
Dim z As String = "F" + x.ToString
Return Format(myVal, z)
End Function
Wednesday, May 12, 2010
System.Text.ASCIIEncoding.ASCII
Saving a textfile from Vb or C# you think is just text but oh noo.
Following code:
isn't shown in your favourite text editor .
You can even compare two files in WinMerge and it doesn't report those extra characters.
The extra characters ÿþ is used to tag the file as a Utf-8 file.
To save a clean text file use the following code:
Following code:
My.Computer.FileSystem.WriteAllText("c:\MyFileName.txt", txt, False)
Saves a text file, BUT you will have a couple of extra characters ÿþ (0xFF 0xFE) in the beginning of the file thatisn't shown in your favourite text editor .
You can even compare two files in WinMerge and it doesn't report those extra characters.
The extra characters ÿþ is used to tag the file as a Utf-8 file.
To save a clean text file use the following code:
My.Computer.FileSystem.WriteAllText("c:\MyFileName.txt", txt, False, System.Text.ASCIIEncoding.ASCII)
This 'Feature' has made my day two times now, so its time for me to remember it,
System.Text.ASCIIEncoding.ASCII
System.Text.ASCIIEncoding.ASCII
System.Text.ASCIIEncoding.ASCII
System.Text.ASCIIEncoding.ASCII
System.Text.ASCIIEncoding.ASCII
System.Text.ASCIIEncoding.ASCII
Don't forget
System.Text.ASCIIEncoding.ASCII
System.Text.ASCIIEncoding.ASCII
System.Text.ASCIIEncoding.ASCII
Friday, April 30, 2010
WPF School Part.1 - Timers and Checkboxes
I use the dispatchtimer with wpf applications. Here a short example.
Rename Window to MainWindow, add a checkbox.
Class Window1
Dim WithEvents MyTimer As New System.Windows.Threading.DispatcherTimer
Dim n As Integer = 0
Private Sub CheckBox1_Checked(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles CheckBox1.Checked, CheckBox1.Unchecked
' Combined Checked and UnChecked event.
If CheckBox1.IsChecked Then
MyTimer.Start()
Else
MyTimer.Stop()
n = 0
End If
End Sub
Private Sub MyTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyTimer.Tick
n += 1
MainWindow.Title = n.ToString
End Sub
Private Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles MainWindow.Loaded
MyTimer.Interval = New TimeSpan(500000) ' 50 ms, 100 ns/bit
End Sub
End Class
Note also how to handle the Checkbox Check event, there is no CheckChanged event in wpf.
In Windows Form Application you write like below:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
' To something when checked....
Else
' To something when unchecked....
End If
End Sub
In wpf you have to combine two events, .Checked and .Unchecked. The property .Checked is in wpf replaced with .IsChecked.
Rename Window to MainWindow, add a checkbox.
Class Window1
Dim WithEvents MyTimer As New System.Windows.Threading.DispatcherTimer
Dim n As Integer = 0
Private Sub CheckBox1_Checked(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles CheckBox1.Checked, CheckBox1.Unchecked
' Combined Checked and UnChecked event.
If CheckBox1.IsChecked Then
MyTimer.Start()
Else
MyTimer.Stop()
n = 0
End If
End Sub
Private Sub MyTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyTimer.Tick
n += 1
MainWindow.Title = n.ToString
End Sub
Private Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles MainWindow.Loaded
MyTimer.Interval = New TimeSpan(500000) ' 50 ms, 100 ns/bit
End Sub
End Class
Note also how to handle the Checkbox Check event, there is no CheckChanged event in wpf.
In Windows Form Application you write like below:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
' To something when checked....
Else
' To something when unchecked....
End If
End Sub
In wpf you have to combine two events, .Checked and .Unchecked. The property .Checked is in wpf replaced with .IsChecked.
Saturday, February 27, 2010
WindowsXP Cheap
I was running Windows 7 for a while, but got tired of all the incompatibility with old hardware and old software I'm using. also the color scheme and fonts are not of my likings.
Opening a menu in Windows 7 you get flashed by the bright colors. So back to old trustful WinXP.
I got in trouble trying to find some place to buy Windows XP, luckily I found http://software-users.com/ where you can buy and download OEM copies really cheap. I paid 75 $ for a copy of WinXP, about 40% of what you have to pay in a shop (If you find one selling WinXP).
Opening a menu in Windows 7 you get flashed by the bright colors. So back to old trustful WinXP.
I got in trouble trying to find some place to buy Windows XP, luckily I found http://software-users.com/ where you can buy and download OEM copies really cheap. I paid 75 $ for a copy of WinXP, about 40% of what you have to pay in a shop (If you find one selling WinXP).
Friday, February 05, 2010
VB.net Hex2Dec
I found this trying to convert string hex value "B4" to a byte value.
dim myHex as string="B4"
Dim value As byte = Byte.Parse(myHex,Globalization.NumberStyles.HexNumber)
simple isn't it, when you find the correct function to do it.
Sunday, January 24, 2010
Windows7 installation
Just installed Windows7, no hazzle and quick. Someone at MS actually to a good job.
Wednesday, January 20, 2010
.Net DataTable.Select bug
Be very careful how you write you FilterExpression using DataTable.Select(FilterExpression).
You add some columns to your DataTable without specifying what type they are it will be set to String as default. Later when you filter out data expecting integer datatype you get some corrupt stuff back. So don't forget ' ' around string parameters in your FilterExpression if you column are of String type.
The Net framework accept invalid filters and return crappy data back instead of saying that this FilterExpressing is crap, if your unlucky you will not find out until its too late.
Code example: (Same bad behavior occurs in C#)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dt As New DataTable
dt.Columns.Add("ix1")
dt.Columns.Add("ix2")
dt.Columns.Add("ix3")
dt.Rows.Add(New Object() {1, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {5, 1, 8})
dt.Rows.Add(New Object() {5, 1, 8})
dt.Rows.Add(New Object() {13, 1, 8})
dt.Rows.Add(New Object() {13, 1, 8})
Dim x As Integer
Dim cnt As Integer
x = 1
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=1
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString)
x = 3
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=5
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString + ", this should be 5, wtf")
' Fix, column(0) is string instead of integer so filter will be for string
x = 3
cnt = dt.Select("ix1='" + x.ToString + "'").Length
' THIS will return cnt=5
MsgBox("ix1='" + x.ToString + "', cnt= " + cnt.ToString)
x = 13
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=0 and not 2
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString + ", this should be 2, wtf")
' Fix, column(0) is string instead of integer so filter will be for string
x = 13
cnt = dt.Select("ix1='" + x.ToString + "'").Length
' THIS will return cnt=2
MsgBox("ix1='" + x.ToString + "', cnt= " + cnt.ToString)
End Sub
You add some columns to your DataTable without specifying what type they are it will be set to String as default. Later when you filter out data expecting integer datatype you get some corrupt stuff back. So don't forget ' ' around string parameters in your FilterExpression if you column are of String type.
The Net framework accept invalid filters and return crappy data back instead of saying that this FilterExpressing is crap, if your unlucky you will not find out until its too late.
Code example: (Same bad behavior occurs in C#)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dt As New DataTable
dt.Columns.Add("ix1")
dt.Columns.Add("ix2")
dt.Columns.Add("ix3")
dt.Rows.Add(New Object() {1, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {3, 1, 8})
dt.Rows.Add(New Object() {5, 1, 8})
dt.Rows.Add(New Object() {5, 1, 8})
dt.Rows.Add(New Object() {13, 1, 8})
dt.Rows.Add(New Object() {13, 1, 8})
Dim x As Integer
Dim cnt As Integer
x = 1
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=1
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString)
x = 3
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=5
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString + ", this should be 5, wtf")
' Fix, column(0) is string instead of integer so filter will be for string
x = 3
cnt = dt.Select("ix1='" + x.ToString + "'").Length
' THIS will return cnt=5
MsgBox("ix1='" + x.ToString + "', cnt= " + cnt.ToString)
x = 13
cnt = dt.Select("ix1=" + x.ToString).Length
' THIS will return cnt=0 and not 2
MsgBox("ix1=" + x.ToString + ", cnt= " + cnt.ToString + ", this should be 2, wtf")
' Fix, column(0) is string instead of integer so filter will be for string
x = 13
cnt = dt.Select("ix1='" + x.ToString + "'").Length
' THIS will return cnt=2
MsgBox("ix1='" + x.ToString + "', cnt= " + cnt.ToString)
End Sub
faulting module kernel32.dll, version 5.1.2600.3541, fault address 0x00012a6b.
I got following fault running my VB application from the IDE:
Faulting application MyApp.vshost.exe, version 9.0.21022.8, faulting module kernel32.dll, version 5.1.2600.3541, fault address 0x00012a6b.
It triggers on: Expanding a treeview or opening an old function that have been working for ages.
Stepping through the code doesn't really help, the fault triggers before opening the function.
When running the released exe, no fault is triggered, but running the debug version of the exe-file does. It turned out to be a common dll used by several objects that had different versions somehow.
So one day of scrathing my head finally solved.
Fix: Remove all /bin/debug and /bin/release the rebuild solution.
Faulting application MyApp.vshost.exe, version 9.0.21022.8, faulting module kernel32.dll, version 5.1.2600.3541, fault address 0x00012a6b.
It triggers on: Expanding a treeview or opening an old function that have been working for ages.
Stepping through the code doesn't really help, the fault triggers before opening the function.
When running the released exe, no fault is triggered, but running the debug version of the exe-file does. It turned out to be a common dll used by several objects that had different versions somehow.
So one day of scrathing my head finally solved.
Fix: Remove all /bin/debug and /bin/release the rebuild solution.
Monday, January 18, 2010
AT Commands
Playing around with my mobile phone dialing using Com-port over BlueTooth.
-Connect using HyperTerminal
- Select Comport, use default settings 2400,8,N,1
To make a call:
Type: ATDT ThePhoneNumber;
(Don't forget the ; at the end.)
To answer a Call:
Type: ATA
To hang up a call:
Type: ATH
You find lots of reference for 'AT commands' by searching on Google.
ref: http://developer.sonyericsson.com/getDocument.do?docId=65054
-Connect using HyperTerminal
- Select Comport, use default settings 2400,8,N,1
To make a call:
Type: ATDT ThePhoneNumber;
(Don't forget the ; at the end.)
To answer a Call:
Type: ATA
To hang up a call:
Type: ATH
You find lots of reference for 'AT commands' by searching on Google.
ref: http://developer.sonyericsson.com/getDocument.do?docId=65054
VB.Net BackgroundWorker
A BackgroundWorker runs an asyncron thread for you.
Private WithEvents backgroundWorker1 As New System.ComponentModel.BackgroundWorker
' Start the BackgroundWorker
Public Sub RunAbackgroundworker()
If Not backgroundWorker1.IsBusy Then
backgroundWorker1.RunWorkerAsync()
End If
End Sub
Dim i As Integer = 0
Private Sub backgroundWorker1_DoWork(ByVal sender As Object, ByVal e As _
System.ComponentModel.DoWorkEventArgs) Handles backgroundWorker1.DoWork
i = 0
Do
i += 1
If i > 100 Then
Exit Do
End If
System.Threading.Thread.Sleep(50)
Loop
End Sub
Private Sub backgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles _
backgroundWorker1.RunWorkerCompleted
MsgBox("We are done now!")
End Sub
Private WithEvents backgroundWorker1 As New System.ComponentModel.BackgroundWorker
' Start the BackgroundWorker
Public Sub RunAbackgroundworker()
If Not backgroundWorker1.IsBusy Then
backgroundWorker1.RunWorkerAsync()
End If
End Sub
Dim i As Integer = 0
Private Sub backgroundWorker1_DoWork(ByVal sender As Object, ByVal e As _
System.ComponentModel.DoWorkEventArgs) Handles backgroundWorker1.DoWork
i = 0
Do
i += 1
If i > 100 Then
Exit Do
End If
System.Threading.Thread.Sleep(50)
Loop
End Sub
Private Sub backgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles _
backgroundWorker1.RunWorkerCompleted
MsgBox("We are done now!")
End Sub
Subscribe to:
Posts (Atom)
MySQL to MariaDB
Here is a good description how to migrate to MariaDb MySQL to MariaDb Example of how to dump data from MySQL port=3307: mysqldump --user=ro...
-
When converting an VB2008 application to VB2010 I run into trouble regarding COM objects while compiling. you get errors like: Error 1...
-
In a module you have declared a Structure or Enum that you will use through out a project. Module Module1 Public Structure dummy ...
-
Apache2 crashes on Ubuntu Linux 22.04.5 after Zabbix was updated to 7.0.26 During a upgrade of my Ubuntu server there was a new package for ...