locked
A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)

    Question

  • I'm writing a c++ winrt component wrapper for a native c library and trying to load my component in a c# windows store app and getting the mentioned error. Here's the complete exception.

    System.IO.FileLoadException: A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)
       at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
       at Spotify.SessionConfig..ctor()
       at Jukebox.MainPage.initSessionButton_Click(Object sender, RoutedEventArgs e)

    I can't see to figure out what to look for. Anyone have any ideas on what to check?

    https://spotifywinrt.codeplex.com/SourceControl/latest

    Friday, June 6, 2014 2:42 AM

All replies

  • Is the library valid for Windows Store apps?

    If you simplify the scenario can you load the library directly rather than via the component?

    Are you including the library in your appx package?

    Beyond that, look for lower level errors. Make sure you do native debugging. If the library attempts to load but fails then turn on loader snaps to get more information about why.

    Friday, June 6, 2014 6:00 PM
    Moderator
  • I've seen mention of including the library in the appx package. The way I have it setup is a single solution with two projects. One is definitely a valid windows store app c#, the other is a c++ winrt component. I used the built-in templates. I did rename stuff along the way and I know what can lead to problems. 

    I'm wondering if there's something I need to do in my c# app other than reference the c++ project? I didn't see anything in the IDE (Visual Studio) when editing the manifest that lead me to believe that it would make any difference. Do I need to manually edit the manifest for the c# app to explicitly reference the component? 

    Friday, June 6, 2014 7:17 PM
  • I created a new solution and started adding in pieces until I repeated this problem. A new solution with with a c# store app and a c++ winrt component works ok. When I add in a reference to an unmanaged 3rd party .dll in the c++ winrt component is when I run into this problem.
    Saturday, June 7, 2014 12:46 PM
  • Did you check the questions I asked in my previous post about your unmanaged library?

    It will need to be included in the appx package (otherwise it can't be loaded since it doesn't exist) and it will need to be valid for a Windows Store app (otherwise it won't pass certification and it may or may not work side-loaded).

    Saturday, June 7, 2014 7:40 PM
    Moderator
  • By "in the appx package", I'm assuming you mean it exists in the output directory? bin\x86\Debug\AppX\. It does. The dependency dll is not a valid wnidows store app, it's simply an unamanaged/native x86 dll. Is it not possible to reference such a .dll?

    I was under the impression that you could build a c++/winrt component that wraps native code and expose that to windows store apps written in other languages like javascript and c#.

    Monday, June 9, 2014 11:25 PM
  • You can call a native library so long as it uses only valid API for Windows Store apps. See Win32 and COM APIs  .

    Yes, that is what I meant by "in the appx package". The library needs to be deployed in the appx package to be usable at runtime.

    To further diagnose this you will need to debug to see why it isn't loading. What errors did you see when you debugged the loading with loader snaps enabled?

    --Rob

    Tuesday, June 10, 2014 11:08 PM
    Moderator