Getting Dllnotfound exception with a native reference within Xamarin.iOS project

Woody Master 1 Reputation point
2021-08-10T12:52:12.21+00:00

Using XCode I created 12 identical frameworks, only their names are different (each deriving from its respective XCode project name).

Following this guideline

embedded-frameworks

I embedded one of the frameworks into a Xamarin.ios project as a native reference.

Using [DllImport("Framework", EntryPoint = "Functionname")] I am able to access any of the 12 frameworks in both, Debug and Release mode and on both, Simulator and device. So far, so good.

BUT, when adding all of the 12 frameworks to the Xamarin.ios project strange things start to happen during the run on a device (the Simulator is somehow not affected!): only a couple of the frameworks can be accessed (normally 4), the rest throws a Dllnotfound exception. And even more: depending on the sequence of adding a framework to the Xamarin.ios project it may be accessed or throw the exception(!) For example if I start the adding process with one of the 8 "bad" frameworks from a former build process, this one will no longer be bad and can be beautifully accessed - in return one of the accessible frameworks from a former build process will then throw Dllnotfound. To clarify, the 12 frameworks all have the same inner life, only different names and different entry point names, the rest is completely identical, hence interchangeable.

My first thought was a limit in number or size of embedded frameworks that was established for Xamarin projects?? In my case the app's total size with 12 frameworks is around 110 Mb in Debug mode. By the way: the debugger's answer with "dllnotfound" is exactly the same as if the respective framework was never embedded in the app's bundle...

My next thought was a possible symbol collision between the frameworks: But these are not static libraries using "Internal__" with a huge pool of all symbols together, but a strictly separated set of frameworks with different names (container system). Furthermore, a symbol collision would lead to an error during build, not during run...

Another thought was about my free provisioning profile: maybe with a paid developer account there is no limit for the number of frameworks to be embedded?? That would explain, why it's always working on the Sim...

Some more things I have tried and all potential combinations of them as well (though without success so far):

Using different versions of XCode to build the frameworks (version 8 and 11)

Using different versions of Visual Studio for Mac to build the calling program (2017 and 2019)

Using different versions of deployment on a device (iOS 10.3 and 13.2)

Using the option "smart link" for the native reference in Visual Studio

Using the option "force load" for the native reference in Visual Studio

Using additionally the option to specify linker flags in "additional mtouch arguments" for the native reference in Visual Studio

Using the setting "Link all assemblies" in Visual Studio

Am I missing something in my process, in my setup or in my idea? Any help would be appreciated after so much time of investigation. Thanks:-)

Developer technologies | .NET | Xamarin
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.