Website zur Ereignisanzeige von Windows

Im Sinne von Browser-Cache.de, auf den wir in unserem Support-Forum gerne verlinken, habe ich nun eine Website für die Benutzung der Windows-Ereignisanzeige erstellt.

Ereignisanzeige.de

Dort beschreibe ich in einfachen, knappen Worten, was die Ereignisanzeige ist, wie der Anwender diese starten kann, und wo Informationen zu finden sind.

Im Laufe der Zeit werde ich dort sicher noch mehr Informationen platzieren. Ggf. auch ein kleines Erklär-Video.

Windows-Authentifizierung zeigt ständig Anmelde-Bildschirm

Heute habe ich bei einem Kunden den Fall gehabt, dass trotz dass Windows-Anmeldung im IIS 7 konfiguriert war, und im korrekt angezeigten Browser-Anmelde-Dialog die richtigen Anmeldedaten eingegeben wurden, keine Anmeldung möglich war.

Vielmehr ist 3 mal der Anmelde-Dialog erschienen und danach kam die HTTP-Fehlermeldung 401.2 (oder war’s 401.1?).

Die Lösung wurde dann von einem wirklich kompetenten Administrator beim Kunden geliefert: Die Authentifizierungsprovider waren in der Reihenfolge „Negotiate“ und dann „NTLM“.

Als wir NTLM ganz nach oben geschoben haben, ging alles.

windows-authentication-not-working
windows-authentication-successfully-working

OMG!

Von Windows 7 aus via ODBC auf eine benannte SQL-Server-2000-Instanz zugreifen

Heute ist Legacy-Tag!

Issue

Für ein Projekt müssen wir von Microsoft Office Access 2010 auf einen SQL Server 2000 via ODBC zugreifen.

Die Herausforderung ist, dass der SQL Server 2000 als benannte Instanz („Named instance“) auf dem Server installiert ist (Windows 2008 R2). Also so was wie „MEINSERVER\SQL2000“, anstatt nur „MEINSERVER“.

Lokal auf dem Server kann ich wunderbar auf den SQL Server 2000 zugreifen, alleine via Netzwerk von einem PC mit Windows 7 ging es nicht. Es kam immer wieder die Meldung, dass keine Verbindung hergestellt werden konnte.

Lösung

Die Lösung war dann im Microsoft-Knowledge-Base-Artikel „How to connect to SQL Server by using an earlier version of SQL Server“ zu finden:

Vom Prinzip via cliconfg.exe-Programm auf dem Client einen Alias zu IP-Adresse und Port des SQL Server 2000 machen und dann über den Alias zugreifen.

Zitate aus der Lösung:

Server:

Determine the TCP/IP port number of the instance of SQL Server. To do this, use one of the following methods, depending on which version of SQL Server that you are running.

  1. On the server that is running SQL Server 2000, start the Server Network Utility. To do this, click Start, click All Programs, click Microsoft SQL Server, and then click Server Network Utility.
  2. Click the General tab, and then select the instance that you want from the Instances list.
  3. Click TCP/IP, and then click Properties. The TCP/IP port number for this instance is shown. Note this number so that you can use it later.

Client:

Configure the server alias on the client computer. To do this, use one of the following methods, depending on your version of SQL Server.

  1. Start the Client Network Utility. To do this, click Start, click Run, type cliconfg.exe, and then press Enter.
  2. On the General tab, verify that TCP/IP appears in the list under Enabled protocols by order.
  3. Click the Alias tab, and then click Add.
  4. Under Network libraries, select TCP/IP.
  5. In the Server name text box, type the IP address of the server that is running SQL Server 2000.
    Note The IP address that you type here is the one that is configured to use the TCP/IP port number.
  6. Click to clear the Dynamically determine port check box, and then type the port number of the instance of SQL Server 2000 in the Port number text box.
  7. Type a name in the Server alias text box, and then click OK.

Dann ging die ODBC-Verbindung („Verbindungstest“ war erfolgreich).

Bubble Mouse Move events from child controls up the hierarchy in Windows Forms

Windows Forms (or „WinForms“ for short) does not know the concept of event bubbling (also called „event propagation“ sometimes). To solve this in terms of command routing, I’ve written some small classes earlier.

To bubble up events from child controls to parent controls (or the form itself), the idea is to hook into the child control creation and hook up for those specific events and manually forward them.

Based on this idea and with the help of a forum answer on MSDN, I’ve written a small class that you can attach to a control and get all child control MouseMove events. The class looks like:

public sealed class MouseEventBubbler
{
    private readonly Control _attachTo;

    public MouseEventBubbler(Control attachTo)
    {
        _attachTo = attachTo;

        _attachTo.MouseMove += _attachTo_MouseMove;

        _attachTo.ControlAdded += _attachTo_ControlAdded;
        _attachTo.ControlRemoved += _attachTo_ControlRemoved;

        foreach (Control control in _attachTo.Controls)
        {
            AttachToControl(control);
        }
    }

    public void _attachTo_MouseMove(object sender, MouseEventArgs e)
    {
        OnMouseMove(e);
    }

    public event MouseEventHandler MouseMove;

    private void _attachTo_ControlAdded(object sender, ControlEventArgs e)
    {
        AttachToControl(e.Control);
    }

    private void _attachTo_ControlRemoved(object sender, ControlEventArgs e)
    {
        DetachFromControl(e.Control);
    }

    private void AttachToControl(Control c)
    {
        c.MouseMove += Child_MouseMove;
        c.ControlAdded += Child_ControlAdded;
        c.ControlRemoved += Child_ControlRemoved;
        AttachToChildren(c);
    }

    private void AttachToChildren(Control parent)
    {
        foreach (Control child in parent.Controls)
        {
            AttachToControl(child);
        }
    }

    private void DetachFromControl(Control c)
    {
        DetachFromChildren(c);
        c.MouseMove -= Child_MouseMove;
        c.ControlAdded -= Child_ControlAdded;
        c.ControlRemoved -= Child_ControlRemoved;
    }

    private void DetachFromChildren(Control parent)
    {
        foreach (Control child in parent.Controls)
        {
            DetachFromControl(child);
        }
    }

    private void Child_ControlAdded(object sender, ControlEventArgs e)
    {
        AttachToControl(e.Control);
    }

    private void Child_ControlRemoved(object sender, ControlEventArgs e)
    {
        DetachFromControl(e.Control);
    }

    private void Child_MouseMove(object sender, MouseEventArgs e)
    {
        var pt = e.Location;
        var child = (Control)sender;
        do
        {
            pt.Offset(child.Left, child.Top);
            child = child.Parent;
        }
        while (child != _attachTo);

        var newArgs = new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta);
        OnMouseMove(newArgs);
    }

    private void OnMouseMove(MouseEventArgs newArgs)
    {
        var h = MouseMove;
        if (h != null)
        {
            h(this, newArgs);
        }
    }
}

I’ve also saved it as a PasteBin.

The class can be adjusted to match other events than the MouseMove event, if required.

Mehrere Excel-Hauptfenster

Schon des Öfteren wäre es mir ein Anliegen gewesen, zwei oder mehr Excel-Dokumente nebeneinander in zwei getrennten Hauptfenstern (z.B. auf zwei Monitoren) anzuzeigen.

Obwohl ich Excel 2010 besitze, habe ich keine Option gefunden. (In Excel 2013 scheint das der Standard zu sein)

Workaround/Lösung

Es gibt zwar Zusatztools und -Programme, doch an die erinnere ich mich selbst nach der Installation nach kurzer Zeit nicht mehr.

Stattdessen ist die für mich einfachste Lösung schlicht mehrere Instanzen von Excel zu starten (einfach im Startmenü mehrfach das Excel-Symbol anklicken oder Start > Ausführen > „excel“) und dann jeweils in einer Instanz explizit ein Dokument laden.

“Nicht identifiziertes Netzwerk. Kein Internetzugriff.” unter Windows 7 lösen

Seit Jahr und Tag ärgere ich mich über die vermeintliche Intelligenz von Windows, beim Herstellen von Netzwerkverbindungen:

“Nicht identifiziertes Netzwerk. Kein Internetzugriff.”

Fuck you!

Nach vielem Suchen und dem Finden von ganz ausgefuchsten Lösungen bin ich nicht weiter gekommen.

+++WERBUNG+++ Professionell eine eigene Website erstellen +++WERBUNG+++

Die (für mich akzeptable) schlichte Brute-Force-Lösung sah dann schließlich so aus:

  1. Dienste-MMC aufmachen (Start -> Ausführen -> “services.msc”).
  2. Den Windows-Firewall-Dienst suchen.
  3. Diesen Dienst stoppen und deaktivieren.

Danach ging es endlich wieder.

Was mir außerdem geholfen hat, war der Tipp in diesem Technet-Artikel:

  1. Open an Administrator: Command Prompt. To do so, click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.
  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
  3. At the command prompt, type the following command:
    netsh advfirewall set profiles state off

    where profiles is AllProfilesCurrentProfileDomainProfilePrivateProfile, or PublicProfile.

Ich habe mir dann konkret mit folgendem geholfen:

netsh advfirewall set AllProfiles state off

Was sogar auch mal geholfen hatte, war im Netzwerk-Center auf das rote X bei der symbolischen Leitung zu klicken und „Reparieren“ zu wählen. Das hatte ewig gedauert und danach hat es tatsächlich funktioniert.

Update 2013-12-06

Heute hatte ich einen Fall mit einem IBM-/Lenovo-Notebook, bei dem ich über WLAN dasselbe Phänomen hatte:

“Nicht identifiziertes Netzwerk. Kein Internetzugriff.”

Nach einer Stunde erfolglosem Try-and-Error habe ich aufgegeben und das Gerät via LAN-Kabel erfolgreich ans Netz bekommen.

Update 2013-12-09

Mein Kollege hatte ein ähnliches Phänomen (via WLAN) und hat es wohl dadurch gelöst, dass er sicher gestellt hat, dass der Gateway und DNS-Server alle im selben Subnetz sind. Dann wurde das Netzwerk automatisch erkannt.

Es war also eine reine IP-Einstellungs-Geschichte bei ihm, ganz ohne Firewall-und-Co.-Magie.

Update 2014-05-15

In einer VMware-Maschine habe ich das ganze gelöst bekommen, indem ich das Netzwerk von „Bridged“ auf „NAT“ umgestellt habe (in den Einstellungen der virtuellen Maschine).

Update 2014-08-15

In meiner VMware-Maschine wollte ich unbedingt wieder „Bridged“ haben. Ich habe lange gesucht und probiert, und die Lösung war letztendlich, beim „Bridged to“ von „Automatic“ auf meinen tatsächlichen LAN-Adapter umzustellen:

vmware-virtual-network-editor-bridget

Danach konnte ich erfolgreich wieder von der Maschine aus ins Internet und auch von meinem Lokalen PC auf die virtuelle Maschine kommen.

Fixing „A dynamic link library (DLL) initialization routine failed.“ error on Windows 8

Just fixed an issue with our Zeta Producer 11 that occurs only on the brand new Windows 8. The German error message was:

Die Datei oder Assembly „ZetaHtmlTidy.dll“ oder eine Abhängigkeit davon wurde nicht gefunden. Eine DLL-Initialisierungsroutine ist fehlgeschlagen. (Ausnahme von HRESULT: 0x8007045A)

Translated to English it was:

System.IO.FileLoadException ‚A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)‘

The DLL in concern was a mixed Managed/Unmanaged C++ assembly that wrapped the popular HTML Tidy C sources into a .NET-usable assembly.

So my first idea was that some CRT DLLs were missing:

  • msvcm90.dll
  • msvcp90.dll
  • msvcr90.dll
  • Microsoft.VC90.CRT.manifest

But all were present, even the well-known Dependency Walker/Viewer did not help any further.

Since version 10 of our application worked and version 11 did not work and brought the above error, I was clueless. The main difference was:

  • Version 10 was installed into „C:\Program Files (x86)\Zeta Producer 10“.
  • Version 11 was installed into „C:\Users\YourName\AppData\Local\Zeta Producer 11″ (to bypass administrative setup permissions).

When I moved Version 10 also below the „C:\Users\…“ folder, the error also occurred!

So the cause was not a missing assembly but some kind of (weird?) policy thing.

Some further digging/googling finally lead to the solution on Stack Overflow. The solution was to add some more App.config settings.

My previous, non-working App.config file contained:

<startup>
    <supportedRuntime version="v2.0.50727"/>
    <supportedRuntime version="v4.0"/>
</startup>

My new, working App.config file was:

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v2.0.50727"/>
    <supportedRuntime version="v4.0"/>
</startup>

So it seems that setting „useLegacyV2RuntimeActivationPolicy“ to „true“ finally switched something to allow for loading mixed-mode DLLs from local folders. Doh!

Solving „Exception of type ‚System.ComponentModel.Design.ExceptionCollection‘ was thrown.“ error messages in Visual Studio .NET 2010 Windows Forms Designer

Recently I got an error message

---------------------------
Microsoft Visual Studio
---------------------------
Exception of type 'System.ComponentModel.Design.ExceptionCollection' was thrown.
---------------------------
OK
---------------------------

when trying to edit a form in the Windows Forms Designer of Visual Studio .NET 2010. Searching Google for this error brought up some results but didn’t help me.

There was one hint that stated:

Sometimes I get the message „Exception of type ‚System.ComponentModel.Design.ExceptionCollection‘ was thrown“ When trying to open a Form in designer view.

The real problem of the „ExceptionCollection“ being thrown is that when there is a WSOD (White Screen of Darn) indicating a designer load issue, the designer gets unloaded. These get caught by the unload method and get displayed in the dialog box you see.

So, to fix this you should:

  • Attach a visual studio debugger to VS. Turn on exception catching when first thrown (in the Debug|Exceptions menu).
  • Open the designer with the debugger attached
  • Determine what component is throwing the exception.

This was actually a copy from a Microsoft Connect bug report. I tried this, but the error message still popped up and the debugger never stopped at this message (although it stopped at other native errors).

Steps to solve

Since all this didn’t help, I did another approach that was finally successfully:

  1. Make a SVN commit for the file.
  2. Open the „*.designer.cs“ file of the form that shows the error in source view.
  3. Remove larger blocks of form element declarations.
  4. Fix all compilation errors with ReSharper (i.e. ensure that nothing is red anymore on the side-indicator).
  5. Save the file. No need to compile.
  6. Open the Windows Forms Designer of the form.
  7. If the error still shows up, do a SVN revert to go back to the initial state.
  8. Repeat steps 2 to 7 until the error does not show up anymore.
  9. Now you’ve encircled the erroneous child control that causes the error.
  10. Repeat steps 2 to 7 with a smaller amount of controls you remove, until you have only one control left.

In my case it was a user control inside a group control inside a tab control, so I first identified the tab control, then the group control and then the user control.

You could isolate the user control inside a new form to further investigate. In my case it was rather easy; I put checks for design mode around most of the functions inside my control to ensure the code only gets executed if the control is not in design mode.

This fixed my error.

See also:

Handling WM_MOVING in Windows Forms

Just a quick snippet:

public class FormWithWmMoving :
    Form
{
    private const int WM_MOVING = 0x0216;

    private static readonly object EVENT_MOVING = new object();

    public event EventHandler Moving
    {
        add { Events.AddHandler(EVENT_MOVING, value); }
        remove { Events.RemoveHandler(EVENT_MOVING, value); }
    }

    public class MovingEventArgs : EventArgs
    {
        private readonly Rectangle _rectangle;

        public MovingEventArgs(
            Rectangle rectangle)
        {
            _rectangle = rectangle;
        }

        public Rectangle Rectangle
        {
            get { return _rectangle; }
        }
    }

    protected virtual void OnMoving(MovingEventArgs e)
    {
        var h = (EventHandler)Events[EVENT_MOVING];
        if (h != null)
        {
            h(this, e);
        }
    }

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == WM_MOVING)
        {
            var r = (Win32NativeMethods.RECT)Marshal.PtrToStructure(m.LParam, typeof(Win32NativeMethods.RECT));
            var rectangle = new Rectangle(r.left, r.top, r.Bounds.Width, r.Bounds.Height);

            var args = new MovingEventArgs(rectangle);
            OnMoving(args);
        }

        base.WndProc(ref m);
    }
}

Hope this is helpful someday to me or others.