Error while attempting to open an online session

Apr 26, 2013 at 9:01 PM
Edited Apr 26, 2013 at 9:22 PM
I can't seem to figure out what this exception is trying to tell me:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
My code looks like:
    public class DismConnection : IDisposable
        public DismConnection()

        public void GetFeature(string featureName)
            using (DismSession session = DismApi.OpenOnlineSession())
                var featureInfo = DismApi.GetFeatureInfo(session, featureName);

        #region Implementation of IDisposable

        public void Dispose()

I call it this way:
            using (var dismConnection = new DismConnection())
It throws this exception when I call OpenOnlineSession. Any ideas?

EDIT: After logging was enabled, found this is the issue:
2013-04-26 13:18:21, Error DISM API: PID=16104 TID=14108 Running the DISM API online under WoW64 is not supported - DismOpenSessionInternal(hr:0x8007000b)
Why would it not support 64bit?
Apr 27, 2013 at 4:38 PM
I was able to run your sample just fine unless I specifically built it for x86 and ran it on my 64-bit machine. As long as I built using Any CPU or x64 it would work.

Are you building with Any CPU? It appears that if you build x86, the DismApi will throw an exception when run on a 64-bit machine. You can build x64 and x86 as long as you only run x64 on 64-bit machines.

When you build Any CPU, the .NET CLR automatically picks the correct DismApi.dll to load. However, when you specify a processor architecture, the .NET CLR picks the exact DismApi.dll from C:\Windows\SysWOW64 or C:\Windows\System32.
Apr 27, 2013 at 6:11 PM
Yep, that is precisely what I had found out last night. I compile x86 as a product requirement and need to be able to run on both x86 and x64. On top of that I need to be able to run on different languages - hence why I'm switching to an API framework instead of just using dism.exe and parsing the output. I'm finding that I may have to package these DISM API libraries with the installer as well to ease installation for the user.

Your library is definitely useful and I thank you for your help on this! I'll be devising a solution over the week - just got to figure out the best way to do it.
Apr 29, 2013 at 4:11 PM
Hi Jose,

So I'm unable to run when I'm in 'Any CPU' mode under a 64 bit OS.

I'm curious, how did you go about intalling DISM API? I read in your other post:

That you had apparently have your files in 'Dismapi.dll should be in your %WINDIR%\System32 directory so the wrapper should be able to locate it.'

I downloaded the Windows Assessment and Deployment Kit (Windows ADK) from here:

When it installed, the DISM API dll's were placed here:

C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools

There is a 64 bit version under amd64 directory and x86 version under x86 folder. Since this isn't in the path (I could have placed it in the path) I had to copy the amd64 files to the bin where I compile. Where are your API dll's placed? Are they in your windows system32 directory? If so, did you manually move/copy them there? Which ones are you using?

Thanks for taking your time to read this!
Apr 30, 2013 at 4:48 PM
The WAIK is one way to get it but it is installed with my version of Windows 8.

C:\Windows>dir dismapi.dll /s /b

What OS are you developing on?
Apr 30, 2013 at 4:52 PM
I'm on Windows 7.
Apr 30, 2013 at 6:25 PM
Well that's interesting, I had assumed DismApi.dll was on Windows 7 as well but its not. I'll look into getting my wrapper to have the DismApi dlls included and load properly.

For now you can unblock yourself by using the DLLs from the WAIK.

Sorry for the trouble!
Apr 30, 2013 at 6:34 PM
No problem at all Jose. Your work is very much appreciated.

Is the DLLs in WAIK different than those in the ADK?
May 1, 2013 at 6:25 AM
So it looks like the Windows ADK is required for this to work. The WAIK is for Windows 7 but the Windows ADK supports Windows up to version 8.


Runtime Requirements
DISM API binary files. The DISM API files are available in all Windows® 8 operating systems. You can also run DISM API applications on any Windows operating system that is supported by the Windows ADK. You must install the Windows ADK in order to run DISM API applications on these operating systems. For more information about supported operating systems, see the Windows® Assessment and Deployment Kit (Windows ADK) Technical Reference.

Does this seem reasonable to make people install the Windows ADK to use DismApi and my managed wrapper? I'm worried if I'm allowed to distribute the binaries. Plus for Windows 8 the binaries are already there.
May 2, 2013 at 3:24 PM
Yeah I'm worried about the distribution of those binaries as well. I don't think there is much you can do on your side. Thank you for taking the time to look into this though.
May 2, 2013 at 7:00 PM
Okay I'll at least put a note on my project page so people with Windows 7 and below know they need the Windows ADK. Let me know if you have any other issues.