VB6 dll in ASP.NET and hosting on IIs

Friday 15 July 2016

VB6 dll in ASP.NET and hosting on IIs

I have developed a asp.net project, due to some specific purpose it is required to use a VB6 Dll. I have to host the application on IIS. Now it is required to create the object of the Dll from code behind page. Since  VB6 dll is not same as .Net Dll, So to use a VB6 Dll within a web application we have to performed the following steps
1.    We have to put the VB6 Dll within the Windows folder, For 32bit machine put the Dll to system32 folder and for 64bit machine put this on sysWOW64 folder
2.   Now open the command prompt in administrator mode and write regsvr32 "Path of the Dll" example: regsvr32 "C:\Windows\SysWOW64\a.DLL"

3.    Now open your Project on visual studio right click on "Bin" Folder and click on add reference. Now within COM Dll (Learn more about COM)listed left side of the windows select your Dll (Fro example a.dll).With out registry it will not shown on com dll.
1.    From code behind file of visual studio You can create object of the Dll. Example : Dim obj As New a.FunctionName()
2.    Since it is a 32bit Dll so to host the application we first change the corresponding application pool to enable 32 bit for 64 bit machine. and if it is a 32 bit machine then there is no problem.


Note : Since we are hosting a application on 64bit machine but running the application as 32 bit so the virtual memory of the application will use 4GB but if we host our application as enable 32 bit application as false on 64 bit machine then the virtual memory of the application will use 64GB. So it is batter to avoid such a case where you have to run your application as enable 32 bit mode.