Vault completely unusable in VB6

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Justin Spindler
Posts: 8
Joined: Mon Jun 20, 2005 2:24 pm

Problem with Windows 2003 + VB6 + .NET Dialogs

Post by Justin Spindler » Mon Oct 31, 2005 4:22 pm

I have identified that the problem occurs when the Visual Basic 6.0 IDE attempts to display a .NET WinForm modally on Windows Server 2003 either as a plugin within the IDE or even when debugging a project. I don't have all of the details about this problem but it appears to be an incompatibility of sorts between the unmanaged message loop of Visual Basic 6.0 and the .NET dialogs. There is a workaround which will solve this problem from the .NET side.

Instead of showing the dialog in the current thread, create a new thread and set it's apartment level to single-threaded apartment. Have the current thread start this thread and then join to it until it returns. The second thread will then call the ShowDialog method of the WinForm. Because this occurs in a separate thread it will create it's own message pump. When ShowDialog returns, set a variable to the DialogResult value and return. When the current thread starts up again it can read the DialogResult and return it. Following is the C# code I used to workaround this problem in our own solutions:

Code: Select all

private volatile static Form dialog;
private volatile static DialogResult dialogResult;

public static DialogResult SafeShowDialog(Form dialog) {
    if(dialog == null) {
        return DialogResult.Cancel;
    }
    Common.dialog = dialog;
    Thread t = new Thread(new ThreadStart(SafeShowDialogThreadProc));
    t.ApartmentState = ApartmentState.STA;
    t.IsBackground = false;
    t.Start();
    t.Join();
    return dialogResult;
}

private static void SafeShowDialogThreadProc() {
    try {
        dialogResult = dialog.ShowDialog(OwnerForm);
    }
    catch(Exception ex) {
        dialogResult = DialogResult.Cancel;
        Application.OnThreadException(ex);
    }
}
Your mileage may vary with this code, but so far it seems to work for me.

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Post by lbauer » Mon Oct 31, 2005 4:33 pm

Thanks for the information. I'll mention this post in the VB 6 dialog bug.
Linda Bauer
SourceGear
Technical Support Manager

Justin Spindler
Posts: 8
Joined: Mon Jun 20, 2005 2:24 pm

Post by Justin Spindler » Mon Nov 14, 2005 6:52 pm

lbauer wrote:Thanks for the information. I'll mention this post in the VB 6 dialog bug.
I've found that this solution can sometimes cause other problems, particularly the dreaded "COM is busy" dialog. This isn't always the case.

On the server in which the Vault dialog is unusable from VB6, any attempt to call ShowDialog from within the VB6 IDE, whether it's the Vault client library or a project that I am debugging, the result is the same. The dialog is completely unusable. This is severely hampering debugging of new development since we're migrating portions of a large VB6 applications to .NET.

I have recently submitted an incident to Microsoft to attempt to track down this problem. Has SourceGear done the same? Could we compare notes? It's obviously a bug between VB6, Windows 2003 and .NET but it's really hard to pin down the exact causes as not every Windows 2003 machine I test on yields the same results.

Balthazor
Posts: 81
Joined: Fri Mar 11, 2005 4:10 pm
Location: Hartford, Wisconsin

Post by Balthazor » Tue Sep 19, 2006 8:37 am

Has this ever been resolved, or is there any kind of workaround? I have several users who are starting to complain about this issue now that we're beginning to migrate over to Windows 2003 Server for our workstations.

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Post by lbauer » Thu Sep 21, 2006 8:06 am

We have a bug logged, but no timeframe yet for a fix. We'll take another look at this to see what would be involved.

The workaround is to use the keyboard to tab through the dialog commands and press "Enter" when the appropriate command has focus.
Linda Bauer
SourceGear
Technical Support Manager

Balthazor
Posts: 81
Joined: Fri Mar 11, 2005 4:10 pm
Location: Hartford, Wisconsin

Post by Balthazor » Thu Sep 21, 2006 8:15 am

Ok, thanks. It doesn't seem to be a huge problem or anything, since like you said, we can just tab to whatever we need. I just figured I'd check on it, since a couple folks brought it up to me.

luther_miller
Posts: 56
Joined: Wed Apr 28, 2004 3:28 pm
Location: San Francisco, CA
Contact:

workaround doesn't work for me

Post by luther_miller » Thu Sep 21, 2006 12:11 pm

Just started a project that includes some VB6 development on a Windows 2003 server and stumbled up this bug.
When the Vault login form opens up, I can only type in the user name box, and when I TAB though, the only other controls that get focus are the command buttons. I can't type in any other box (including password).
This is 3.1.9.
Is there another workaround?

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Post by lbauer » Mon Sep 25, 2006 4:07 pm

Yes, there is another workaround. This bug is related to some changes Microsoft made to a build of .NET 1.1 SP1 for Windows 2003 Server. The dialog works properly if the the .NET 2.0 framework is loaded for IDE integration.

Here's the workaround:

1. If it's not already there, install .NET 2.0 on the Windows Server 2003 machine.

2. make a copy of the VaultGUIClient.exe.config (in the Vault GUI Client directory) and rename it "VB6.exe.config."

Copy the VB6.exe.config into the same directory as VB6.exe and enter runtime information so that the first part of the file looks like this:

Code: Select all

<?xml version="1.0"?> 
<configuration> 
<startup> 
<supportedRuntime version="v2.0.50727"/> 
<requiredRuntime version="v2.0.50727" safemode="true"/> 
</startup> 
</configuration>
You should now be able to type and use the mouse in the connection dialog.
Linda Bauer
SourceGear
Technical Support Manager

Balthazor
Posts: 81
Joined: Fri Mar 11, 2005 4:10 pm
Location: Hartford, Wisconsin

Post by Balthazor » Wed Sep 27, 2006 12:34 pm

That works great! You have my thanks.

luther_miller
Posts: 56
Joined: Wed Apr 28, 2004 3:28 pm
Location: San Francisco, CA
Contact:

works great

Post by luther_miller » Wed Sep 27, 2006 3:23 pm

Thanks!

Post Reply