maandag 14 december 2009

How To: 'Reverse engineer a .net application?'

With Reflector you can revert the CIL to .net code with the help of an reflector add-in by Denis Bauer: http://www.denisbauer.com/NETTools/FileDisassembler.aspx

This add-in allows you to generate a .net project.
Only a designer file isn't generated. The Designer code is merged in the code-behind form class file.

Save XLS File to CSV File (VB.net)

Private Sub SaveExcelFileAsCVSFile()

Dim excelfile As Microsoft.Office.Interop.Excel.Application =
New Microsoft.Office.Interop.Excel.Application
Dim sFileName As String
Dim wb As Workbook = excelfile.Workbooks.Open( _
"FILE.xls", CorruptLoad:=XlCorruptLoad.xlRepairFile)
sFileName = wb.Path & "\FILE.csv"
wb.SaveAs(sFileName, XlFileFormat.xlCSV, XlSaveAsAccessMode.xlNoChange)
wb.Close()
excelfile.Quit()

End Sub

Export excel file to csv (VBA Macro)

Set Separator (;)


Sub SaveToCSVFile()

Dim fs As Object, a As Object, i As Integer, j As Integer, s As String, t As String, l As String, mn As String
Set fs = CreateObject("Scripting.FileSystemObject")
Dim newFileName As String
newFileName = ThisWorkbook.FullName
newFileName = Replace(newFileName, ".xls", ".csv")
Set a = fs.CreateTextFile(newFileName, True)
Range("A1").Select
i = ActiveCell.CurrentRegion.Columns.Count
ActiveCell.CurrentRegion.EntireRow.Delete


For rowNumber = 1 To Range("A65536").End(xlUp).Row
s = ""
Col = 1
For j = 0 To i
s = s & Cells(rowNumber, Col) & ";" 'Separator
Col = Col + 1
Next j
a.writeline s 'write line
Next rowNumber

End Sub

woensdag 9 september 2009

Select distinct on a DataTable

vrijdag 14 augustus 2009

donderdag 13 augustus 2009

Save xml file with indenting

XmlTextWriter textWriter = new XmlTextWriter(@"D:\temp.xml", null);
textWriter.Formatting = Formatting.Indented;
MyXmlDoc.Save(textWriter);

woensdag 12 augustus 2009

How to generate a XML file From XSD schema

Find out here

maandag 10 augustus 2009

Combobox.SelectedIndex vs Combobox.SelectionChangeCommitted

By using the SelectionChangeCommitted event, you know that it's a user who changed the combobox selected index


SelectedIndexChanged
* raised when DataSource is set
* raised when SelectedIndex is set programmatically

SelectionChangeCommitted
* not raised when DataSource is set
* not raised when SelectedIndex is set programmatically

SelectionChangeCommitted is raised first when a user selects an item from combobox before the SelectedIndexChanged is raised. Both events are not raised when items are added throught the Items property of the control.

source

donderdag 30 juli 2009

Async webservice method (2.0)

Create a webservice with a method that returns something.



If u create a web reference in visual studio the async methods are automatically created.
Call the webservice async method and attach an eventhandler for methodCompleted event.

dinsdag 28 juli 2009

Rename Files

Get All columns + size and type from a given SQL table

XML XSD validator class

Use this class to validate an xml file against it's xsd schema...

XML node encryption (TripleDES)

Use this class to encrypt or decrypt one ore more xml nodes with sensitive data, with the use of the TripleDES encryption algorithm. This encryption generates only private keys. (symmetric encryption)


woensdag 25 maart 2009

Ajax And Sharepoint wss 3.0 SP1

first install Asp.net ajax extensions and modify the web.config of your sharepoint site. instructions can be found here: msdn ajax install .

a simpler and safer way to put a scriptmanager is to add it to the masterpage (can be found :C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\TEMPLATE\GLOBAL\default.master )
and add an scriptmanager :
(asp:scriptmanager runat="server" enablepartialrendering="true" id="ScriptManager1")

just afer

(webpartpages:spwebpartmanager id="m" runat="Server")


Use this abstract class to inherit your webpart from and make it ajax-enabled.

dinsdag 10 maart 2009

Windows SharePoint Services 3.0 SP1 on Vista x64/x86

You can now run sharepoint services and develop webparts on vista, no more VM's !

This nice solutions was created by Bamboom solutions.
Check out the instructions and downloads here.
For me the install was successful and really easy, and I created some webparts with VS2008 that deployed without any problem.

maandag 9 maart 2009

Working with performance counters.

this example reads out two cache performance counters.



next example creates 2 new performance counters and increments their value.

vrijdag 6 maart 2009

Simple delay calculator

Reading ID3v2 tags with taglibsharp

Taglibsharp latest build can be found on http://developer.novell.com/wiki/index.php/TagLib_Sharp
This testapp will read out every ID3v2 tag it finds and keeps a collection of mp3's which don't have any ID3v2 tag.

donderdag 5 maart 2009

VB's 'RedimPreserve' in C# (generic)

Google API - code search

Fill in a query and number of results and get a result back from google's code search service.


Set Color of console.

SetConsoleTextAttribute() can change the color of the console.

Visual studio addin - extra feature on errorlist

This code puts an extra popup commandbar on the errorlist with all the error descriptions as commandbarbuttons, each button has a lookup event (google lookup).


maandag 2 maart 2009

New C# 4.0 features

1) dynamic

"most anything that you could do with some variable, you can do with a dynamic variable."

static double SumDouble(double a, double b) { return a + b; }
static decimal SumDecimal(decimal a, decimal b) {return a + b;}

this can now be writen as :

static dynamic Sum1(dynamic a, dynamic b) { return a + b; }

or more generic :

static dynamic Sum2(T1 a, T2 b) {
dynamic
ad = a;
dynamic
bd = b;
return
ad + bd;
}


more:
Dynamically Typed Objects with C# 4.0 (xml example)



2) Named arguments, optional arguments, and default values

By giving method parameters default values.

public class ContactList
{
List<Contact> SearchForContacts(
string name = "any",
int age = -1,
string address = "any") { ... }

static void Main()
{
ContactList list = new ContactList();
var x = list.SearchForContacts(age:26);
}
}
U can then call the method like this:

list.SearchForContacts(age:26);

or

list.SearchForContacts(address:"home", name:"sam", age:30);