Loading DLLs with manifest for dependencies of dependencies - windows

My situation is:
A.dll depends on B.dll and C.dll
B.dll depends on C.dll
B.dll and C.dll are in a subfolder below the folder containing A.dll
B.dll and C.dll are inside an assembly (BCAssembly) with the following manifest:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="AssemblyBC" version="1.0.0.0"/>
<file name="B.dll"/>
<file name="C.dll"/>
</assembly>
A.dll depends on AssemblyBC via its manifest, defined in A.dll's code:
#pragma comment(linker, "/manifestdependency:\"name='AssemblyBC' version='1.0.0.0' type='win32'\"")
When I load A.dll, I get error code 126 ("Specified module could not be found"). I have confirmed via Process Monitor that A.dll uses the manifest to successfully find B.dll and C.dll, but B.dll cannot find C.dll. I tried adding a B.dll.manifest specifying a dependency on AssemblyBC, but this had no effect, perhaps because B.dll is inside AssemblyBC. How can I use manifests to make B.dll find C.dll?

Related

How to create my own custom nuget package for System.Data.SQLite to correctly include the interop dlls?

I want to create my own custom package for System.Data.SQLite. I have the all the dll's I need but I'm unsure how to structure it and create the nuspec for it.
Current folder structure of the dll's is this, whereabouts would I put the different interop dlls to have them copied correctly to the output and what do I need to add to the nuspec?
lib/net452
-> System.Data.SQLite.dll , System.Data.SQLite.Linq.dll, System.Data.SQLite.EF6.dll
Custom.SQLite.nuspec
Still have the default nuspec something like this atm
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Custom.SQLite.Name</id>
<version>1.0.0.0</version>
<authors>name</authors>
<owners>owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Desc</description>
<copyright>Copyright 2021</copyright>
</metadata>
</package>
SQLite.Interop.dll does not act as a lib assembly dll. That is not its role. And it should be a content file rather than a assembly dll. So it should not be packed as lib.
To create such custom nuget package, you should first pack System.Data.SQLite.dll, System.Data.SQLite.Linq.dll, System.Data.SQLite.EF6.dll as lib. See this document.
and then pack SQLite.Interop.dll as content.
Also, to make the content file be copied into the output folder of the main project when you install the nuget package, you have to use a <packages_id>.props or targets file to realize it.
1) create a file called <packages_id>.props into your class library project. And it should be the same name as your nuget package. In your side, it should be named as Custom.SQLite.Name.props. Otherwise, it will not work.
And then add these into the file:
<Project>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\content\x86\SQLite.Interop.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)..\content\x64\SQLite.Interop.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
2) use this nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Custom.SQLite.Name</id>
<version>1.0.0.0</version>
<authors>name</authors>
<owners>owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Desc</description>
<copyright>Copyright 2021</copyright>
</metadata>
<files>
<file src="System.Data.SQLite.dll" target="lib\net452" />
<file src="System.Data.SQLite.EF6.dll" target="lib\net452" />
<file src="System.Data.SQLite.Linq.dll" target="lib\net452" />
<file src="xxx\x86\SQLite.Interop.dll" target="content\x86" />
<file src="xxx\x64\SQLite.Interop.dll" target="content\x64" />
<file src="Custom.SQLite.Name.props" target="build" />
</files>
</package>
3) rebuild your lib project and then use nuget pack to pack the new version.
Before you use this new version, please uninstall the old one and delete all cache files under C:\Users\xxx\.nuget\packages\Custom.SQLite.Name and <solution_folder>\packages\Custom.SQLite.Name.1.0.0. Then, reinstall the new version.

External manifest seems to be unrecognized by Windows

I am using an external manifest for a very simple program I have written, program.exe. I have an external manifest, program.exe.1.manifest, in the same directory. These are the contents:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
manifestVersion="1.0"
>
<assemblyIdentity
name="TestC.Testos.TestEx"
processorArchitecture="amd64"
type="win32"
version="0.1.0.0"
/>
<description>TestTool</description>
<file
loadFrom="%homepath%\Desktop\source\payload.dll"
name="payload.dll"
/>
</assembly>
Now, the simple program simply calls LoadLibraryW(L"payload.dll"). The payload.dll is located in the Windows directory of the system, however, I am trying to load a version of payload.dll from a folder called source on my desktop. This works when I embed the manifest in the program directly, but does not when it is an external manifest. Why does an external manifest not work?

Using an external manifest to turn off Windows DPI scaling

I have a Java application on Windows that's launched through a packr exe. I need to turn off DPI scaling by default. I don't have control of the exe's generation.
My understanding is that I can do this by adding an external .manifest file, but it doesn't seem to work.
This is the manifest file, which I put at "Airships.exe.manifest" next to "Airships.exe".
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="Airships.exe"/>
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings
xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</asmv1:assembly>
Is there something incorrect about this manifest?
Does an external manifest actually work by default, or do I have to embed it into the .exe somehow?
NB this related question doesn't actually have an answer.

Cordova build on windows platform overrides appxmanifest file

I am using a different package name as configured in my config.xml for my windows platform target.
For example, this is my config.xml (here package name is the id element in the widget tag) in my root project folder:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="de.myapplication.mobile" version="1.1.1" ...>
And my package.phone.appxmanifest file in my windows platform folder (here the package name is the Name element in the Identity tag) contains for example this:
<Package ...>
<Identity Name="de.myWindowsApplication.mobile" Publisher="XXX" Version="1.0.0.0" />
</Package>
Now building my windows platform target with cordova build windows replaces the Name element string de.myWindowsApplication.mobile with the id element string de.myapplication.mobile from the config.xml.
(How) Can i prevent this?

My nupkg is incompatible with my Unified API app

I've made a NuGet package that has a lib/Xamarin.iOS10 folder with a dll inside it.
I've created a test project (an iOS unified API Single View App) and I try to add my package but I get this response:
Could not install package 'mypackage 1.0'. You are trying to install
this package into a project that targets 'Xamarin.iOS,Version=v1.0',
but the package does not contain any assembly references or content
files that are compatible with that framework. For more information,
contact the package author.
Extracting the file, I can verify that my dll is present.
This is the nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.8">
<id>MyPackage</id>
<version>1.0</version>
<title>My Package</title>
<authors>Kristian</authors>
<owners>Kristian</owners>
<developmentDependency>true</developmentDependency>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Experiment Package</description>
<summary />
<language>en-US</language>
<tags></tags>
<dependencies>
<dependency id="Fody" version="1.29.3"/>
</dependencies>
</metadata>
<files>
<file src="../MyPackage.XamarinIOS/bin/iPhone/Release/MyPackage.dll" target="lib/Xamarin.iOS10/MyPackage.dll" />
</files>
</package>
Is there anything else I need to do? I am not using the new project.json format for my package.. I am using Xamarin Studio version 5.9.8.
Shouldn't that be:
target="lib/xamarinios10/MyPackage.dll"
Instead of your Xamarin.iOS10 path?

Resources