Skip to content

Add initial VB6 tests#8253

Closed
JeremyKuhne wants to merge 2 commits into
dotnet:mainfrom
JeremyKuhne:vb6test
Closed

Add initial VB6 tests#8253
JeremyKuhne wants to merge 2 commits into
dotnet:mainfrom
JeremyKuhne:vb6test

Conversation

@JeremyKuhne
Copy link
Copy Markdown
Member

@JeremyKuhne JeremyKuhne commented Nov 23, 2022

Adds a really simple VB6 control to write tests against.

Adds utility code for handling COM classes straight from their host assembly.

Add a simple DynamicAxHost class to utilize these ComClass wrappers.

Also skip needless throwing and catching exceptions from the connection cookie setup in AxHost.

Note that I've renamed the control from .ocx to .vb6 to avoid having it accidentally picked up by anything.

Microsoft Reviewers: Open in CodeFlow

Adds a really simple VB6 control to write tests against.

Adds utility code for handling COM classes straight from their host assembly.

Add a simple DynamicAxHost class to utilize these ComClass wrappers.

Also skip needless throwing and catching exceptions from the connection cookie setup in AxHost.

Note that I've renamed the control from .ocx to .vb6 to avoid having it accidentally picked up by anything.
@JeremyKuhne JeremyKuhne requested a review from a team as a code owner November 23, 2022 00:39
@ghost ghost assigned JeremyKuhne Nov 23, 2022
lonitra
lonitra previously approved these changes Nov 23, 2022
Copy link
Copy Markdown
Member

@lonitra lonitra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JeremyKuhne
Copy link
Copy Markdown
Member Author

Well, this is failing spectacularly. Trying to narrow it down.

It looks like ISpecifyPropertyPages on the VB control might be corrupting the runtime state?

Fiddled with a few things to see if I could get the problem to stop occurring. Made the ComClassFactory use an AgileReference, experimented quite a bit with the ISpecifyPropertyPages reference.
@JeremyKuhne
Copy link
Copy Markdown
Member Author

@AaronRobinsonMSFT this is where my question came from. I'm screwing up the runtime somewhere, and that could entirely be an artifact of me directly instantiating a VB control from LoadLibrary.

Things work in isolation, but something is getting corrupted and I'm struggling to narrow the culprit down. I don't know if it is my direct usage of DllGetClassObject or some side effect of invoking the various interfaces on the object I'm getting back. I keep chasing red herrings sadly.

The reason I was trying to go this route was to avoid registering COM controls for tests (not a great idea for CI, if it is even allowed). It seemed like a relatively straightforward workaround. I can't figure out the activation contexts to understand if I can go that route.

@JeremyKuhne
Copy link
Copy Markdown
Member Author

@AaronRobinsonMSFT apparently it isn't my hack to create it directly. I've registered and used CoCreateInstance and I still get the corruption.

@AaronRobinsonMSFT
Copy link
Copy Markdown
Member

Things work in isolation, but something is getting corrupted and I'm struggling to narrow the culprit down.
I've registered and used CoCreateInstance and I still get the corruption.

Do we have a DMP? Can I reproduce this locally? I'll take a look later today and reach out offline.

Note that I've renamed the control from .ocx to .vb6 to avoid having it accidentally picked up by anything.

I'd also check in the actual VB code as well. Just having a binary blob isn't all that helpful. Perhaps it is already checked in somewhere?

@JeremyKuhne
Copy link
Copy Markdown
Member Author

JeremyKuhne commented Nov 23, 2022

Do we have a DMP? Can I reproduce this locally? I'll take a look later today and reach out offline.

It can be reproduced locally. With this branch run the following from the root:

build -platform x86 -test /p:TargetArchitecture=x86

The test run will abort with no details. You can tell it aborted as you will get a .log statement in the spew instead of an .html with actual results:

XUnit : error : Tests failed: C:\Users\jkuhne\source\repos\winforms\artifacts\log\Debug\System.Windows.Forms.Tests_net8.0_x86.log [net8.0|x86] [C:\Users\jkuhne\source\
repos\winforms\src\System.Windows.Forms\tests\UnitTests\System.Windows.Forms.Tests.csproj]

In VS (use start-vs.cmd) you can get it to repro by setting the Processor Architecture for Any CPU Projects to x86 in the Test menu and selecting all of the tests in System.Windows.Forms.Tests except for the System.Windows.Forms.Tests and running them. I've never been able to capture it as it AVs or OOMs (with plenty of memory left).

image

I will check in the code eventually. Was trying to get a better handle on the project structure to know what I should include. It is an ActiveX Control project with a text box and a button that sets the text in the text box when clicked. Just dragged and dropped and set a click handler through the UI.

public class AxHostVisualBasic6Tests
{
[WinFormsFact]
public void AxHost_SimpleControl_Create()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason to run this as a unit test and not as UI integration test? The latter are run serially.

@JeremyKuhne
Copy link
Copy Markdown
Member Author

This fails in the same way on .NET 7. :/

@AaronRobinsonMSFT
Copy link
Copy Markdown
Member

@JeremyKuhne Is it worth checking how this behaves on .NET Framework in the current test harness? I'd like to know how much effort I should put into looking into this as it is very hard to untangle these sorts of bugs when they only occur in while running in a process with many threads, the VB6 runtime just wasn't designed for that environment.

@JeremyKuhne
Copy link
Copy Markdown
Member Author

Is it worth checking how this behaves on .NET Framework in the current test harness?

@AaronRobinsonMSFT I'll keep trying to narrow down a repro for it. These tests are all on the same thread- which is what worries me a bit. It's quite possible it is some side effect of us never quite doing the COM right (thinking of how we don't handle casting to base interfaces for example). I'll keep you posted.

@JeremyKuhne
Copy link
Copy Markdown
Member Author

This was merged disabled in #8322.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants