Unity3D sqlite multiple "System.Data.dll" problem - c#

I am trying to use sql-lite in my Unity3D project. In fact, I used it in the past now I am trying to update it.
Unity version and sql-lite version has changed since then.
Now I get an error like this;
error CS1703: Multiple assemblies with equivalent identity have been
imported: 'C:\Users[username]\Documents\Unity Games[your program
name]\Assets\System.Data.dll' and 'C:\Program
Files\Unity\Editor\Data\NetStandard\compat\2.0.0\shims\netfx\System.Data.dll'.
Remove one of the duplicate references.
As I understand from the message that, sqlite wants to use its own System.Data.dll file, but it has the same library name in .net. So this causes a conflict and unity throws an error.
I tried to delete the System.Data.dll and its meta filewhich is in Assets file, but did not work. I also tried to change the file name in Asset folder but nothing changed...
Do you have a solution for this problem? I have tried in both Unity 2018 and 2019 versions.
Additional info may help others: In the past I had a problem with sqlite in my games. I had handled the situation like putting or copying my data sqlite file (filename.sqlite as an example) into the folder:
C:\Users[username]\AppData\LocalLow\[app folder]\[app
name]\filename.sqlite
Because unity looks for the folder in script and that folder exists in windows which I mentioned above;
string filepath = Application.persistentDataPath + "/" +
"filename.sqlite";
This helped me to solve my problem in the past. Now I am stuck with a different problem...
Solution:
Here is the solution by the guied of Алексей Кудряшов and blending my sqlite package. Thanks to him for his suggestion.
1- I deleted all all Plugins, GoogleMobileAds, PlayServicesResolver etc.
2- I first installed my admob package back
3- I installed everything manually in the link;
SQLite4Unity
4- I installed sqlite package but while installing it, I select none and i installed only "Mono.Data.Sqlite" file. If you have it or if you find it you can manually add it into Asset folder of Unity3D. Also you may find it from;
SQLite web page
5- Then Console said me that there is a conflict in x86 and x64 folders for sqlite3.dll file so, I clicked the x86 folder, then clicked sqlite3.dll then in the inspector panel I disabled everything.
6- Then I imported "using SQLite4Unity3d;" for my data script.
7- I also imported "using Mono.Data.Sqlite;"
8- Then everything worked well.

Did you try to use another SQLite wrapper?
e.g. SQLite for unity
You can just remove your current SQLite plugin and replace it with this one.
Don't forget to re-launch unity and unity HUB, cuz unity will keep DLLs in the memory until it restarts.

Related

Multiple script and namespace errors on a previously working Unity project . Type or namespace name 'GUIColorOverride' could not be found

I had some unusual errors on a relatively small Unity project with six c# scripts written in Visual Studio. It was all working fine, and I came back to it after the weekend. Upon opening, there were 18 new errors which were preventing the code from compiling and I spent several hours trying to figure out what was going on.
The main errors were saying things like Type or namespace name 'GUIColorOverride' could not be found and associated script cannot be loaded, assign a valid script, even though they were linked and I could see the scripts had no errors in Visual Studio. I even did a full Unity uninstall and rebooted, then a clean install. This didn't fix it.
I tried a number of other things such as backing up the scripts from the assets folder and then deleting them. Opening the project and pasting them back in as 'clean' new scripts. This didn't work. I am using Unity's Cloud Collab so was even able to use this to go back to earlier pushes of the project (which had all worked). Nope.
Solved it! The issue was that the local Projects folder I had been using was connected to Google Backup and Sync. This messed with some of the files in some of the folders in PackageCache in Particular in the MyProject > Library > PackageCache > com.unity.timeline#1.2.13 > Editor > directory.
[FIX] To fix and prevent this from happening in future, I turned off Google Backup and Sync for my Unity Project(s), and am now exclusively using Unity Collab and Git. Using the specific errors that were showing in the Unity console, I located the exact path of the Unity-created files that were causing these errors in my broken project, and replaced them with the same files from a working project. This fixed all of the errors. There must have been some corrupted or partially synced files in these folders which caused Unity to have a tantrum. Hope that helps someone!
You should exclude these from the Backup!
Basically you can exclude anything that would also be excluded from git via e.g. this "official" .gitignore file for Unity projects.
Any file and folder listed here will be regenerated by Unity automatically and should not appear in any version control / Backup.
The entire Library folder in particular is part of it since its content changes quite rapidly and is recompiled every time you change a script, install/remove a package etc.
Checkout Unity Manual - Behind the Scenes for more information in detail
When backing up a project, or adding a project to a Version Control Repository, you should include the main Unity project folder, containing both the Assets
and ProjectSettings folders. All the information in these folders is crucial to the way Unity works. You should omit the Library and Temp folders for backup purposes.
To solve an already present issue with the Library folder you can most of the times fix it by simply closing Unity, deleting the entire Library folder via your file browser and opnening Unity again → Unity will rebuild the Library

Azure functions fail when creating a blank/empty project in an existing solution

I upgrade to Visual Studio 2017 15.8.1 and am having issues creating an Azure function project. The project I am trying to create is through the template wizard, just a new V1 empty function project.
I receive the following error, which seems to be .net core related.
NETSDK1004 Assets file '\obj\project.assets.json' not
found. Run a NuGet package restore to generate this
file. FunctionApp1 C:\Program Files\dotnet\sdk\2.1.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 198
Run a NuGet package restore to generate this file.
But my project file states:
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<AzureFunctionsVersion>v1</AzureFunctionsVersion>
</PropertyGroup>
Just to be clear, I do want a 4.6.1 project, not a core one.
I have looked at other answers to this issue but none resolve it. Package reinstall, dotnet restore etc. I get more errors if I select a different template (e.g. HTTP Trigger)
Any ideas?
I thought I had a solution to reboot, then open %temp% and delete all the temporary files in that folder. Then reboot again for good measure and it worked from a blank / empty project, but as soon as I try include this in another solution or move the project it fails.
Seems I have it working now and I'll leave this here in case anyone else has the same.
I did try many many things to resolve, but I believe the crux of my fix was to reboot, then open %temp% and delete all the temporary files in that folder. Then I rebooted again for good measure and it worked from a blank / empty project.
Well that wasted a chunk of my day. I had created a repo in git which had a space in the name. When cloned I ended up with an encoded view of the repo - i.e. a %20 for the space, which appeared in the folder path. Since this was just some demo work I had left it as is instead of tidying it up to a clean namespace.
Turns out if you have a %20 or some other encoded value in your path you will get the NETSDK1004 error. I hope this answer saves someone else some time!

What happened to all my references?

Scenario: I have 14 projects (each in their own folder in TFS) with an additional folder named AllSolutions to contain all of them. Note not everyone on the team needs all 14 projects this is why I put the AllSolution.sln in its own folder.
The Allsolutions.sln was just upgraded to Nuget 2.0 and it compiles fine! So far so good.
I also have sub-solutions (that contain only those projects they need). These solutions are contained in the root folder shown below as ...Framework...
Problem
Any of the sub-solutions I load show this (whether they have one or more projects) all show missing assemblies:
I suspect that my AllSolutions.sln gobbled them up. Perhaps I need to move all these solutions to the AllSolutions folder? BTW there is nothing that shows up in the output window when I open these sub-solutions.
If I open/edit any of the Proj files this is what I see.
Notice that the Nuget work put in hint paths at the AllSolutions folder.. Do I have to put in Hint paths for all of these and why?
In NuGet 2.0 or in the packages.config world, there is a package folder per solution. The issue you are seeing is due to this. NuGet 2.0 inserts a hint path during package install in the project file pointing to this location. You would need to resolve the relative location for this to work. You can also choose to use the repository path property in NuGet.config to provide a common location for the packages folder. This should solve your problem.
Instead of upgrading to NuGet 2.0, if you are using Visual Studio 2015 and above, I would recommend that you consider moving to project.json. In the porject.json world, you can have a global packages folder and your project file is not modified during package install. For more information on this, check out the wiki entry here

Unity3D removing project references in MonoDevelop

I am trying to use Mono.Data.Sqlite in my Assembly-CSharp-firstpass project. In MonoDevellop, I right click on the project, edit references, and add Mono.Data.Sqlite to the references. If I build from Mono, everything goes smoothly and and no errors are produced.
When I move back to Unity3D, I always get the error saying that Mono.Data.Sqlite cannot be found. If I then close Unity + Mono and reopen both, the reference to Mono.Data.Sqlite is gone!
Anyone know what is going on?
So after further Googling and Doc reading:
Unity3D rebuilds the project files every time something changes in the Scene/Assets. This means that the added references were being reset and they couldn't be found by Unity.
The solution is to find the needed DLLs (Mono.Data.Sqlite in my case) and copy them to the Asset folder of the project.
If you want access to the DLLs you'll want to put them into a folder called "Plugins" in your Assets folder - Plugins are loaded first, so dotnet assemblies in plugins will be avaiable to you when you want to write code against them.

EmguCV 64-bit build runtime error

I am running into issues building an existing 32-bit EmguCV (Version 2.3) into 64-bit using .net 4.0 and VS2010 on a W7/x64 OS. I have purchased a commercial license, if that matters and downloaded from the links provided in the receipt.
The error is
System.TypeInitializationException was unhandled
Message=The type initializer for 'Emgu.CV.CvInvoke' threw an exception.
Source=Emgu.CV
TypeName=Emgu.CV.CvInvoke
I followed the instructions provided in this article. In fact I used the samples projects in the article and they build fine with V2.2, but when I replace with V2.3 binaries (both emgu and opencv), run into the error.
Has anyone successfully built an Emgu (Version 2.3.x) x64 project? Please provide some guidance.
The cause of this error (should anyone else run into the same problem) is that the program cannot access opencv_imgproc231.dll or opencv_core231.dll even though they are present in the output "bin" directory.
There are two solutions:
Add them to the project and set their properties to copy always as they are EMGU's two key files.
If step 1 doesn't work, replace the current key files in the bin folder with new copies.
If both methods fail then there may be a problem with the build, so download a new copy of EMGU from Sourceforge and try again. The error will later be incorporated within an technical article in order to provide a clearer explanation of how to solve it.
Cheers,
Chris
No need to add them to the project; VS will not let you. Simply open FaceRecognizer.cs
at public static partial class CvInvoke and change:
[DllImport(CvInvoke.EXTERN_LIBRARY, CallingConvention = CvInvoke.CvCallingConvention)]
to:
[DllImport(Emgu.CV.CvInvoke.EXTERN_LIBRARY, CallingConvention = Emgu.CV.CvInvoke.CvCallingConvention)]
Ensure you change all of them.
First test this way: open a sample project from emgu cv installaiton directory and run it. for example, open hello world example and try to run it. if sample projects run with out problem then the installation is correct.
For emgu cv sample projects, value of Output Path option in Build settings of the project is set to '..\..\
bin'. To fix your project problem, open the project in visual studio and set value of Output Path option to 'C:\Emgu\emgucv 2.9\bin'. Try to run the project. It must run with success.
Now, set back the value of Output Path option to bin\Debug\. Then, add all DLL files in the 'C:\Emgu\emgucv 2.9\bin' folder to your project using ADD -> Existing Item menu. similarly, add all DLL files in the 'C:\Emgu\emgucv 2.9\bin\x64' folder to your project using ADD -> Existing Item menu. Now, go to properties window and set Copy to Output Directory option of all dll files to Copy Always. Finally, in the Configuration Manager window, create a new configuration for x64 platform.
Good Luck

Categories

Resources