C# assembly and dll files are not being loaded.

I have recently tried adding In App Purchase into my Unity project. Unfortunately, it didn’t show in the Components drop down menu. I could use the option to create IAP Button and perform code-less IAP configuration but it wasn’t there in the menu. So I decided to configure IAP through script. But the script too throws some errors. The error goes like this:

“Assembly ‘Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll’ will not be loaded due to errors: Reference has errors ‘Stores’.”

Four errors just like the above one shows up for Assembly-CSharp.dll, Editor.dll and Assembly-CSharp-firstpass.dll

And then this one: “Assembly ‘Assets/Plugins/UnityPurchasing/Bin/Stores.dll’ will not be loaded due to errors: Unable to resolve reference ‘UnityEngine.UI’. Is the assembly missing or incompatible with the current platform? Reference validation can be disabled in the Plugin Inspector.”

I have tried re-installing In App Purchase package.

I have tried changing the API from .NET Standard 2.0 to .NET 4.x (and did the vice versa and still did not work)

Downgrading unity project isn’t really a good idea but anyways I gave it a try but it just added to the already existing errors.

Upgrading to newer Unity version (alpha version) didn’t help.

The error occurs whenever I initialize the ConfigurationBuilder referring StandardPurchasingModule.

The worst part is that I am unable to use my scripts after writing the ConfigurationBuilder initialization code. Unity asks me to fix any compiler errors and assign a valid script. I have searched for the answer for so long. I am really stuck in here. Please help.

I’m guessing you’re using Unity 2019.2 or higher.

Unity 2019.2 has a major breaking change. The Unity UI library moved from UnityEngine.UI.dll as part of the core Unity installation to Unity.ugui.dll as an optional install through the Package Manager.

DLLs compiled in 2019.1 or earlier that reference UnityEngine.UI are not compatible with Unity 2019.2+.

To resolve this issue, you will need to get the original script files or DLLs that are compiled for 2019.2+.

I recommend the following steps:

  • Just to be sure: Make a backup, now. (So close Unity and backup your project folder)
  • Now just try to reimport the packages folder in your project (right click-> reimport)
  • if that didn’t help try reimporting all assets
  • if this still doesn’t work, make sure meta files are enabled in the editor project settings. Now close Unity, delete the Library folder in your project folder and open the project again.