Mittwoch, Juni 30th, 2010 | by Richard Deininger | Posted in .NET Framework, C#, Compact Framework, Windows Mobile | 3 Comments »
Since I do some Compact Framework programming on the side. I ran into the problem on how to do full screen applications on WM. Due to our background as “third level developers” we got a pretty good framework for C# Compact Framework programming and there I found the good old HHTaskBar “Hack”.
public static class TaskBar
{
private static IntPtr taskbar;
[DllImport("coredll.dll", EntryPoint = "FindWindowW", SetLastError = true)]
private static extern IntPtr FindWindowCE(string lpClassName, string lpWindowName);
[DllImport("coredll.dll")]
private static extern IntPtr ShowWindow(IntPtr hWnd, int visible);
[DllImport("coredll.dll")]
private static extern bool EnableWindow(IntPtr hwnd, bool enabled);
/// <summary>
/// hides windows taskbar
/// </summary>
public static void HideTaskbar()
{
taskbar = FindWindowCE("HHTaskBar", null);
ShowWindow(taskbar, 0);
EnableWindow(taskbar, false);
}
/// <summary>
/// shows windows taskbar
/// </summary>
public static void ShowTaskbar()
{
ShowWindow(taskbar, 1);
EnableWindow(taskbar, true);
}
}
This is fine,… but if the app crashes or you forget to implement the ”ShowTasbar” function your TaskBar is gone (till the next cold reset). So I searched and found the following “lightweight” way to “hide” the TaskBar.
public static void FullSize(Form frm)
{
frm.WindowState = FormWindowState.Maximized;
frm.Size = Screen.PrimaryScreen.WorkingArea.Size;
frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
}
Only tested for WM 5.0, 6.0 and 6.5!
Montag, Mai 31st, 2010 | by Alexander Schölzhorn | Posted in .NET Framework, C# | 1 Comment »
Deserializing large xml files (>500kb) can be quite slow, because it produces a lot of harddrive IO operations. There is a simple trick to avoid this using a memory stream:
UTF8Encoding encoding = new UTF8Encoding();
XmlSerializer serializer = new XmlSerializer(typeof(MyClass));
MemoryStream stream =
new MemoryStream(encoding.GetBytes(File.ReadAllText(filename)));
MyClass myClass = (MyClass)serializer.Deserialize(stream);
Donnerstag, März 11th, 2010 | by Andreas Bruckner | Posted in .NET Framework, C#, Problemlösungen, Programmierung Allgemein | No Comments »
Although my OS is english (!) version, running the english (!) version of Office, I get an error when opening an Excel workbook via COM. The error message doesn’t help locating the real problem:
Because my locals are german, and the Office Multilanguage Pack is not installed, Excel tries to locate the german language pack and fails.
Solution: set your application’s CurrentCulture to en-US, and it work’s like a charm!
Donnerstag, März 11th, 2010 | by Andreas Bruckner | Posted in .NET Framework 4, C# | No Comments »
Hier eine Kurzzusammenfassung der aus meiner Sicht wichtigsten Neuerungen in .Net 4.0 bezüglich COM:
1) COM (interops)
Endlich wird es möglich sein, eine interop für z.B. Excel 2003 einzubinden, und das Programm auch für Office 2007 laufen zu lassen. Bislang mußte auf Fremdkomponenten zurückgegriffen werden, oder LateBinding benutzt werden. Bei längeren Codes bricht man sich dabei schon mal die Hände.
2) Optionale Parameter
Ebenfalls in Bezug auf COM eine wesentliche Erleichterung. Beispiel: öffnet man ein Excel-Dokument, benötigt dieses 13 Parameter. Ich benötige aber nur den 1. (FileName). Die restlichen Parameter mußte ich bislang mit Type.Missing auffüllen.
In VB geht das wesentlich einfacher von der Hand, daher benutze ich dieses gerne für die Office-Programmierung.
3) Named Parameter
Ebenfalls in VB.NET schon längst bekannt, jetzt auch in C#: Excel.Open(filename:”test.xmls”)
4) Parameter “dynamic”
Die Typzuordnung erfolgt erst zur Laufzeit. Damit sind Typkonvertierungen oder Reflection bei COM nicht mehr zwingend.
Mittwoch, Februar 24th, 2010 | by Andreas Bruckner | Posted in .NET Framework, C#, Problemlösungen, Visual Studio, Windows Forms | 2 Comments »
Today I run into a strange error: In an .NET Windows Form I’m referencing a ConnectionString from Application Settings.
At 12:00 it worked.
Changed a line of code; recompiled; started over at 12:01.
The app came up with an error: “Unrecognized configuration settings UserSettings“, the debugger pointed me to the settings file.
Tried a lot. Searched the internet. Found the only working solution:
Navigate to your user’s application data folder, and delete all the config-files belonging to your app.
Dienstag, Februar 2nd, 2010 | by Andreas Bruckner | Posted in .NET Framework, Betriebssysteme, C#, Visual Studio, Windows 7, Windows Forms | 1 Comment »
As a .NET Developer:
Ever tried to find out more information about your computer’s system?
Ever needed a list of connected USB-Devices, available Serial Ports or Printers?
Ever heard of WMI?
Did you know, it’s also supported by Mono?
There’s a free tool from Microsoft, which is of great help navigating through namespaces, classes and their properties called “WMI Code Creator“.
This tool offers the possibility to create C#, VB.Net & VBScript code.

download here (it’s free!)
Donnerstag, Januar 28th, 2010 | by Oliver Lampl | Posted in .NET Framework, C#, Visual Studio | No Comments »
Ich arbeite gerade an einem Plugin für Enterprise Architect.
Mit Visual Studio 2008 und Vista Ultimate x64 lief alles reibungslos.
Gestern habe ich mir Win7 Ultimate x64 installiert, nun kam folgende Fehlermeldung:
“Microsoft (R) Visual Studio registry capture utility has stopped working”
Nach kurzer Recherche fand ich diesen Workaround.
1. Locate regcap.exe here: C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\Deployment
(Pfad für x64 Szsteme: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\Deployment)
2. Right click and select properties.
3. Select Compatibility tab
4. Check box to Run this program in compatibility mode.
5. Select Windows Vista SP2 in the OS drop-down.
6. Click Ok and Recompile.