Is there a sample (anywhere) of using LoadPackagedLibrary() in a C# project ? See http://msdn.microsoft.com/en-us/library/windows/desktop/hh447159(v=vs.85).aspx
I'm doing a DCA, and need to see if I can access functionality packaged in an existing DLL.
This DLL gets installed in Windows\System32 by our installer, so can we use LoadLibrary()?
Or should we convert the C# sample we started with to a C++ sample ?
We're in the exploratory phase of the project, so we started with CameraCaptureUICS sample, and are adding a section to go see if we can twiddle some bits in our hardware using the DLLs we already have.
Thanks in advance for a speedy answer !Friday, March 09, 2012 10:10 PM
No you cannot use LoadPackagedLibrary to load a DLL from the system dir. This is true in C# and C++ - the choice of programming language is mostly immaterial for this discussion. The DLL search order for Metro style apps (via LoadPackagedLibrary) covers the binaries alongside the app executable, in the package graph and modules already loaded.
Ashish Shetty, Program Manager, Microsoft | http://nerddawg.blogspot.comFriday, March 09, 2012 10:21 PM
Thanks. Followon question. We used a C++ app (ThreadPool) to test out LoadPackagedLibrary(). Linking is OK and we have this in package.appxmanifest:
<Dependencies> <PackageDependency Name="vcsAPIShared.dll"> </PackageDependency> </Dependencies>
Now the problem is deployment. What are we doing wrong here ? The documentation on LoadPackagedLibrary() isn't quite clear on this.
2>Error : DEP0700 : Registration of the app in the layout folder "C:\Users\jbu.000\Documents\Samples\Thread pool sample\C++\Release\ThreadPoolSampleCPP\AppX" failed.
2>Cannot install package Microsoft.SDKSamples.ThreadPool.CPP because this package depends on another package which could not be found. This package requires minimum version 0.0.0.0 of framework vcsAPIShared.dll published by any publisher to install. Add the framework in order to install the package that depends on the framework.Monday, March 19, 2012 9:23 PM
Where does vcsAPIShared.dll live? Is it in Windows\system32 directory? If yes, then you are out of luck: Your package can depend only on other packages - see the error "because this package depends on another package which could not be found". It can use few selected OS DLLs and that's it. OS will not allow anything else to be loaded (incl. your machine-wide installed applications, or assemblies installed in GAC).
The idea is that Metro application should be self-contained and will be prevented to load anything outside itself which is not part of Win8.
You can include the DLL as part of your Metro application.
I hope I didn't misunderstand your question,
-KarelTuesday, March 20, 2012 4:05 PMModerator
I've tried to add the DLL to the Metro app itself, following what little I can find. I've added the DLL to the solution, and right-clicked it and set Content property to True:
<CustomBuild Include="vcsAPIShared.dll"> <FileType>Document</FileType> </CustomBuild>
I get the same error messages.
I tried a Custom Build script to copy it to the directory where all the build items are, and it does get copied there.
I get the same error messages.
NOW WHAT ?Tuesday, March 20, 2012 4:24 PM
I'm experiencing the same issue here and unable to ship a dll with my project.
For example, I would like to use d3dcompiler_44.dll which is redistributable (and required when you need to perform some reflection on shaders bytecode)
@Karel, the dll is part of the solution and is tagged as "Content" and "Copy If Newer", and is not loaded from system directory but from the deployed package itself through the use of LoadPackagedLibrary. This error while deploying is cryptic: "because this package depends on another package which could not be found. This package requires minimum version 0.0.0.0 of framework MYPRIVATEDLL.dll published by any publisher to install. Add the framework in order to install the package that depends on the framework."
Could you please tell us how to resolve this, as this is quite important to ship private native dlls.
Saturday, April 07, 2012 10:10 AM
- Edited by Alexandre MutelMVP Saturday, April 07, 2012 10:11 AM