Click here to Skip to main content
15,882,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Recently I am making a UI asset for Unity. I used Unity 2020.1.0f1 for making and testing primarily. I now have a project in Unity 2021.1.3f1 and I want to use my UI asset. This asset is a unitypackage and contains 3 DLLs (1 C# DLL, 2 C++/CLI DLLs) with some sample element prefabs and sprites. The CLI DLLs are compiled with /clr:safe. When I import the asset, Unity compiles for a couple of seconds and then gives the error

First Error Message:

Could not load image dll-path due to Invalid Section Aligmnent 1000

Run the peverify utility against this for more information.

Second Error Message:

Loading assembly failed:

"dll-path" reason: File does not contain a valid CIL image

I have hid the DLL path for privacy reasons, you will see dll-path. The DLL appears in the Project window but if I try to add any MonoBehaviour contained in those DLLs, it does not show up in the Add Component menu.

NOTE: I am referencing UnityEngine.dll, UnityEditor.dll, UnityEngine.UI.dll and Unity.TextMeshPro.dll. All these references were linked when I compiled the DLL with Visual Studio 2019. Also Note that this asset works fine in Unity 2020.1.0f1 with a new project.

If I am right, I think that this error occurs because of the UnityEngine.dll and UnityEditor.dll version conflicting (or I don't know what) with newer version of the same DLL.

EDIT: I also tested with Unity 2020.3.8f1 which is the latest LTS release at the time of writing this question. I doesn't work in any Unity version except 2020.1.0f1 in which I initially made the DLLs.

If anyone knows, please help me because I am stuck in this situation for hours and I don't want to waste many days because of this error.

What I have tried:

I tried searching on the Internet and asking on various sites but no replies.

EDIT: I also tested with Unity 2020.3.8f1 which is the latest LTS release at the time of writing this question. I doesn't work in any Unity version except 2020.1.0f1 in which I initially made the DLLs.
Posted
Updated 20-May-21 9:20am
v2
Comments
[no name] 20-May-21 16:08pm    
Backward compatible may mean no code changes but you may still have to build and test your dll's in the Unity version you plan to use them with.
Member 15134456 21-May-21 0:02am    
@GerrySchmitz it is not backward compatible. I am making it with `2020.1.0f1` and testing it on `2020.3.8f1` and `2021.1.3f1`. Even after correct reference dll linking, I built it for `2021.1.3f1`. The error still persists.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900