microsoft / Windows-Containers

Welcome to our Windows Containers GitHub community! Ask questions, report bugs, and suggest features -- let's work together.
MIT License
422 stars 64 forks source link

regsvr32 fails when registering DAO350.DLL #460

Closed gaelxcowi closed 5 months ago

gaelxcowi commented 9 months ago

As stated, I am unable to register the DAO350.DLL using the regsvr32 tool with the exit code 5.

An exmaple on how I am trying to register it:

$process = Start-Process "regsvr32" -ArgumentList "/s "C:\Program Files (x86)\Common Files\Microsoft Shared\DAO\DAO350.DLL"" -PassThru -Wait; $process.ExitCode and as mentioned I am getting the exit code 5.

Container images that I have tried to run with:

mcr.microsoft.com/windows:ltsc2019
mcr.microsoft.com/windows/server:ltsc2020

I have tried a few things:

Removing the UAC using the following:

Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0

Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorUser -Value 0

Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -Value 0

Running in isolation using:

--isolation=hyperv

Running using different account, specifically:

--user "NT Authority\System"

Taking ownership to ContainerAdministrator of the registry nodes and subnodes, as suggested in this blog:

https://rnd-solutions.net/2017/05/09/resolve-dao350-dll-registration-issue/

Checking the dependency using dependency walker.

Not sure what I can try more :/ One weird thing, is that I can see that the registry key entry is added once I run the command to:

HKEY_CLASSES_ROOT\TypeLib{00025E01-0000-0000-C000-000000000046}\4.0

with the correct values, etc. but the process still returns an exit code 5.

When trying to run Add-Type of the said .DLL I have the following errors, so maybe some missing dependencies?

Add-Type : c:\Users\Administrator\AppData\Local\Temp\q1ro04mp\q1ro04mp.0.cs(1) : Unexpected character '' c:\Users\Administrator\AppData\Local\Temp\q1ro04mp\q1ro04mp.0.cs(1) : >>> C:\Program Files (x86)\Common Files\microsoft shared\DAO\DAO350.DLL At line:1 char:1

Another approach:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\> whoami
nt authority\system

# Install Microsoft Data Access Objects - from here https://archive.org/details/microsoft-data-access-objects-dao-3.5
PS C:\> $process = Start-Process ".\DAO\SETUP.EXE" -Wait -PassThru; $process.ExitCode
0

# Confirm that Dao2535.tlb is present
PS C:\> cd 'C:\Program Files (x86)\Common Files\microsoft shared\DAO\'; ls
    Directory: C:\Program Files (x86)\Common Files\microsoft shared\DAO
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        12/5/1996  12:00 AM          73184 Dao2535.tlb
-a----        12/2/1996   6:44 PM         582144 dao350.dll
-a----        9/15/2018   9:29 AM         610304 dao360.dll

# Start CMD
PS C:\Program Files (x86)\Common Files\microsoft shared\DAO> cmd
Microsoft Windows [Version 10.0.17763.5329]
(c) 2018 Microsoft Corporation. All rights reserved.

# Run regsvr in the local folder
C:\Program Files (x86)\Common Files\microsoft shared\DAO>start /wait regsvr32 /s dao350.dll

# Error level
C:\Program Files (x86)\Common Files\microsoft shared\DAO>echo %errorlevel%
5
ntrappe-msft commented 9 months ago

We'll have our senior engineer take a look at this. There might be a delay in repro'ing the bug but we'll let you know as soon as we can. (Internal 🔖 48876322).

rameshr-msft commented 6 months ago

Hi gaelxcowi,

Thanks for reaching out. I understand that you are running into issues with registering dao350.dll. Does Dao360.dll for your scenarios? I found that it comes with the servercore and windows container SKUs and is already registered. I ran a basic test and was able to create a database and insert/query data using "DAO.DBEngine.36".

There was no redistributable that I could find to install dao350.dll , I think it's not supported anymore (https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-basic-6/visual-basic-6-support-policy#runtime-definition ).

I followed the steps below (with dao350.dll extracted from the installer you linked to) and registered dao350.dll successfully, without the error you reported.

My host is running: OS Name: Microsoft Windows 11 Enterprise OS Version: 10.0.22631 N/A Build 22631

I created an image with a Dockerfile that registers dao350.dll and verified that the component is registered in a container created from the image.

// // docker file to copy and register dao350.dll //

escape=`

FROM mcr.microsoft.com/windows/servercore:ltsc2022

WORKDIR "C:\Program Files (x86)\Common Files\Microsoft Shared\DAO" COPY ./dao350.dll ./ COPY ./Dao2535.tlb ./ RUN C:\windows\SysWOW64\regsvr32.exe /s "C:\Program Files (x86)\Common Files\Microsoft Shared\DAO\dao350.dll"

// // docker build command //

docker build -t dao350 -f Dockerfile350 .

// // docker build output //

Sending build context to Docker daemon 4.346MB Step 1/5 : FROM mcr.microsoft.com/windows/servercore:ltsc2022 ---> e64ba0f4256b Step 2/5 : WORKDIR "C:\Program Files (x86)\Common Files\Microsoft Shared\DAO" ---> Running in 6f3eb380054b ---> Removed intermediate container 6f3eb380054b ---> 093c53b4f8a6 Step 3/5 : COPY ./dao350.dll ./ ---> b1e8002be8aa Step 4/5 : COPY ./Dao2535.tlb ./ ---> 5f57e20ac55b Step 5/5 : RUN C:\windows\SysWOW64\regsvr32.exe /s "C:\Program Files (x86)\Common Files\Microsoft Shared\DAO\dao350.dll" ---> Running in c165a9e74126 ---> Removed intermediate container c165a9e74126 ---> 0eb75e0942f8 Successfully built 0eb75e0942f8 Successfully tagged dao350:latest

// // docker images //

C:>docker images REPOSITORY TAG IMAGE ID CREATED SIZE dao350 latest 0eb75e0942f8 About a minute ago 4.52GB // // container //

docker run -it dao350:latest c:\windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe

I couldn't do the same test with dao350 as I did with dao360, because it needs dependencies and a license key that I don't have. But I checked that the component is registered and can be found inside the container.

PS C:\Program Files (x86)\Common Files\Microsoft Shared\DAO> New-Object -ComObject "DAO.DBEngine.35" New-Object : Creating an instance of the COM component with CLSID {00000010-0000-0010-8000-00AA006D2EA4} from the IClassFactory failed due to the following error: 80040112 Class is not licensed for use (Exception from HRESULT: 0x80040112).

rameshr-msft commented 5 months ago

@gaelxcowi -- checking back with you to see if the dockerfile above worked for you.

gaelxcowi commented 5 months ago

Hey @rameshr-msft sorry, did have the possibility to try out, as we have moved from that approach. If I have the opportunity, will still give it a try to see if it worked.

rameshr-msft commented 5 months ago

Hi @gaelxcowi , are you still using containers? Just curious if you found a different workaround.

gaelxcowi commented 5 months ago

hey @rameshr-msft - I have tried again following the docker file that you have showen and it indeed seems to complete the registration succesfully - I will need to trace back to figure out what I was doing wrong.

And yes we have moved to another approach - not really workaround, but realized that a lot of modules of the software that we needed to install which are not needed for our usecase anyway, so we stripped it down to the core components which do not have a dependency on dao350.

In any case thank you so much for the great investigation!