How to dockerize an ASP.NET Web Forms that uses Visual Basic 6 (COM) libraries
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
asp.net, web forms, visual basic 6, vb6, com objects, com library, sqlserver, windows, docker
You should be comfortable with ASP.NET Web Forms, .NET Framework 4.8, The COM Library, SQL Server on Windows and have some knowledge of Docker for Windows and Powershell
Please ensure that you have installed:
- .NET Framework 4.8 Developer Pack
- Docker Desktop on Windows
- PowerShell on Windows
- VS Code
- SQL Server 2019 Express or SQL Server 2019 Developer on Windows
- SQL Server Management Studio (SSMS)
I also recomend to Install Visual Studio Community
And of course, if you want to open, edit and build Visual Basic 6 libraries, you will have to need your own user licence of Microsoft Visual Studio 6. If you need more information about how to install Visual Basic Studio 6 on Windows 10 machine, please follow Giorgio Brausi's article Installing Visual Basic/Studio 6 on Windows 10
Although I've uploaded the rest of the components you'll need in the output directory of this repository, you can also find them at:
- Service Pack 6 for Visual Basic 6.0: Run-Time Redistribution Pack (vbrun60sp6.exe)
- Microsoft ActiveX Data Objects 6.1 Library (C:\Program Files (x86)\Common Files\System\ado\msado15.dll)
- Microsoft OLE DB Driver for SQL Server (SQLOLEDB.1 provider)
Clone the repository into your local machine
git clone https://github.com/jporcarn/docker.git aspnetvb6
In the output folder, you can find the rest of the components. Go ahead and install them all in your local machine in case you want to build and test this solution locally. You'll also need them installed in your machine in case you want to build your own solution.
Restore AdventureWorksLT2019 sample database. You can use the .bak file to restore your sample database to your SQL Server instance
Open powershell or cmd in the folder where you've cloned the repository (eg.: aspnetvb6) and register AdventureWorksLT.dll COM library. In vb6-logic folder you shoud find AdventureWorksLT.dll already built.
C:\Windows\syswow64\regsvr32.exe ./vb6-logic/bin/AdventureWorksLT.dll
Start Visual Studio or VS Code and open the web-app.sln solution placed in the web-app folder.
Change the connection string to match your Sql Server. You can use Integrated Security when deploying in local server.
<configuration>
<connectionStrings>
<add name="AdventureWorksLT2019" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=AdventureWorksLT2019;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Restore Nuget packeges
Build the solution
Open Visual Studio and start debugging web-app.csproj project using IIS Express.
Your preferred browser should start on https://localhost:port hosted in IIS Express.
On landing page click on Customers button.
A list with all customer's should appear.
If something went wrong, the error message should be shown just below the Customer's button.
To be able to connect to your local SqlServer from Docker container you'll have to change the connection string and enable SqlServer authentication.
Open Web.config file and change the connection string. Put down your IP address, port and enable SqlServer authentication.
<configuration>
<connectionStrings>
<add name="AdventureWorksLT2019" connectionString="Data Source=[YOUR HOST IP]\SQLEXPRESS,1433;Initial Catalog=AdventureWorksLT2019;User ID=sa;Password=[SA PASSWORD];" />
</connectionStrings>
</configuration>
Publish the web-app.csproj to output/app.publish folder. FolderProfile.pubxml
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>True</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>..\..\output\app.publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
</PropertyGroup>
</Project>
Open Powershell and run the following commands
docker image build --tag aspnetvb6 .
docker container run --detach --publish 80 aspnetvb6
docker ps
docker inspect [container id]
Copy the IP address of the docker container and open a new window in your browser.
Paste the container's IP address and now the landing page should be loaded from the docker container.
On conainer's landing page, click on Customers button.
A list with all customer's should appear.
- .NET Framework 4.8 Developer Pack
- Service Pack 6 for Visual Basic 6.0: Run-Time Redistribution Pack
- Docker Desktop on Windows
- Josep Porcar - Initial work - Docker
See also contributors.
This project is licensed under the MIT License - see the LICENSE.md file for details