I’ve been working on a migration of code from VB5 to .Net. Due to the size of the project, I’ve been slowly migrating functionality over and using COM interop to call the new code from the old VB5 code base.
One little gotcha that I’ve stumbled across access to the Application.Current instance for the AppDomain. When called from VB5, Application.Current is null, and it’s read-only. Oh no!!
After a few minutes of play, it seems the fix is very simple.
if (Application.Current == null)
{
Application newApplication = new Application();
}
That’s it. Just create a new Application instance, and the Singleton Application.Current is now referencing the newly created application.
* Yes, VB5 apps still exist in the wild.
No comments:
Post a Comment