How do you reset or reimport, plugins, in Unity / Mac? - xcode

Get a Unity project with a native low-level plugin .. Mac version.
Make a small change in the Xcode plugin project, and build.
You now have the new plugin library in the Unity project.
If you "Build" again, the final Mac app of course now contains the new library - no problem.
However .....
if you hit Play in the Editor,
it does not pick up the change in the library.
In fact it seems:
Every time you change a library in Unity, you must restart Unity!
Everything has been tried, "Reimport all assets", AssetDatabase.Refresh, renaming, etc etc. It seems you literally must restart Unity.
What's the deal on this?
More information on this:
It would seem that mac shared libraries/bundles cannot be unloaded. Article:
https://docstore.mik.ua/orelly/unix3/mac/ch05_03.htm
Apparently this was fixed in 10.5:
https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dlclose.3.html
Maybe Unity could solve this now. At their usual pace it should happen anytime around 2035.

Sadly it comes down to you can't do anything about it.
As per .net's DLL handling DLL's cannot be unloaded individually without closing the application domain. And while Unity picks up the changes done to the DLL the old version is kept in memory and used at runtime in the editor. A "funny" thing you can do to see this in action is by deleting the native plugin from within the editor. Confirm that you want to delete the file. The file will dissapear from the inspector. However if you right click the folder and refresh (ctrl+r) you will see that the file gets reconstructed (this also happens when hitting "re-import all", as the application domain isn't closed, despite unity restarting).
When building the application it will however use the locally stored file, and not the memory stored file. Hence the plugin being updated on the build.
There is no way to unload an individual assembly without unloading all of the application domains that contain it. Even if the assembly goes out of scope, the actual assembly file will remain loaded until all application domains that contain it are unloaded.
source
This has been a problem for some time now, and people have made attempts for work arounds and/or fixes, but as far as I am aware the "work arounds" that exist now are for windows only. here are some links to discussions about it.
"Unload a plugin"
"Reloading native plugins"
I suppose something that could be done is writing a wrapper that automatically restarts Unity when the dll has been edited... Although this won't solve the issue it'll atleast make it somewhat less of a hassle.

Related

Visual Studio: No symbols have been loaded for this project

Yes, I've seen this previous question here and none of the solutions have worked.
On Visual Studio Community 2019 I was debugging a project that I've been working on for years. I have a common library project, that I've built, that I use on multiple solutions - one web, one exe.
In working on the EXE solution, which is one windows app project + about half a dozen other custom libraries, I was debugging along without issue. Changed a bit of code and then started another debugging cycle and suddenly symbols couldn't be loaded for one of the libraries.
If I look in the output folder, the PDB file for the library IS there. If I look in the Debugging Windows... Modules, the library does NOT show up.
If I load up the web project which also uses this library, it debugs fine and the module shows up in the modules window.
I've tried everything in the thread I've referenced above. I've also tried:
Build, Clean, rebuild, in all sorts of different orders - the PDB is ALWAYS there.
Removing and readding references to the project from the EXE
Creating a whole new solution
Going to a different PC entirely - one that I knew was working yesterday - grabbing my latest code, and still the same problem.
Reverting back to several different old branches of code, on BOTH the new machine and the old machine, same issue.
Installing VS updates
Repairing VS
Checking my GAC to make sure there was nothing for these libraries in there
Played with every project setting I could find
Cursing and praying to the programming Gods
I have no clue what to do next. Obviously this one specific project is not loading the DLL, but I can't figure out any possible reason why. The only thing that changed between a successful debug and the missing symbols error was me changing a few lines of code and clicking Run again. (And I even removed the code changes and it still failed.)
I just don't understand what could have caused this, for this singular library, on this single solution.
To anyone who finds this later, I've solved the problem and my code is debugging fine again.
And I have zero clue about what changed, why it started working, or if I even did anything at all. I came back to it the next day, systematically started working through various tests, and suddenly everything was fine - though I didn't do anything differently than the day before.
These are the times that try men's souls.

Need to always reload project in Xcode for it to function

I've built a couple dozen projects in Xcode and only one of them experiences this strange issue.
Every time I load Xcode to resume work on the project, Xcode auto-loads the project (good) but in an unusable state (bad). It appears this way:
The project name is grayed out, with no disclosure triangle. I cannot access any of its contents, and trying to build it fails immediately with no error message other than "Build Word Practice: Failed" as you see in the screenshot.
But if I close the project and reload it, it functions fine. The only oddity about when it loads this way is that it appears with all its disclosure triangles closed, and I have to manually "disclose" the contents of all the folders in the list each time:
I have had this issue with all recent versions of Xcode, up to and including the current version, 11.5.
The project does not use any features that are not present in other similar projects I've written that behave fine. So it would seem to be a matter of corruption… but besides deleting derived data and doing a clean build (which I've done), I can't think of any other steps to take.
I would include code here, but short of including the whole project (and I doubt that would help), I wouldn't know what to include.
Any ideas?

All project references have yellow triangles every time solution is loaded

All my project (from the same solution) references are marked with a yellow triangle. The projects are all set to the same .NET version (4.5.1). The error log says:
The project 'CommonLibrary' cannot be referenced.
A way to temporarily fix the issue is to either:
Remove and re-add the references
Right click and choose Add Service Reference and immediatelly cancel.
However, the triangles come back every time I start the solution.
The solution is build successfully regardless or the issue. The real issue is that Resharper acts like the references don't exist.
Another thing that might be relevant is that I have 2 projects that are supposed to be unloaded but they become active every time I load the solution.
Any idea what to do with the issue?
I had similar issues and it usually comes down to the Target Framework (Project>Properties>Application). I was working on a solution using .NET 4.6 and for some reason the default framework for new projects have a different target (in my case it was 4.5.2). So make sure you check all your project at the very least have the same target framework.
Do the following:
In vs choose: tools->options->resharper->options-> general-> click the clear caches button.
then close all your opened tabs and shut down vs2013.
finally, start vs2013 again.
Let me know if that worked for you.
Try switching to managed compatibility mode in VS2013
you can do that by going to tools->options..->General tab and check the Use managed compatibility mode
I had the same thing happen but didn't suspect the 24 warnings I was getting was related to this error: Error 1 Unable to locate the .Net framework aspnet_merge.exe tool on path '~\Photo Archive\Main\etc\tools'. You need to set the msbuild property 'AspnetMergeToolPath' to the folder containing this tool. ODOT.PhotoArchive.Web
Trying to set the MS build property led to a lot of research just to find out WHICH property to set. So, Agent Ransack to the rescue -- searched my drive for the most recent version of the tool and copied it to the directory Visual Studio was complaining about.
Rebuilt the project with the idea of clearing the error but then the 24 warnings also disappeared.
FYI -- this is an MVC project which will replace a classic asp project. This might be peculiar to MVC projects.
At any rate, there was a lot of chasing snipes before this was finally tried. So, where this is happening, try handling any errors no matter how remote the possibility is they're related to the issue.
I had the same problem as you can see in this picture.
Its reason was the hidden folder. I had hidden the folder containing the project files. I got rid of this problem by unchecking the hidden attribute of the root folder containing the project files and restarting the visual studio.
Check it once, you might have checked the folder to be hidden.

Weird Visual Studio 2010 Behavior - not copying dlls to bin

I hope someone else has encountered this because its driving me batty.
I recently got a new laptop so I've been setting up my Visual Studio solutions (VS2010 with .NET 4.0) that I saved off my old machine. One of them is a simple console app that I use to simulate some things for testing. It references 2 assemblies that I have in another solution that I am working on now. This used to all work fine as expected but ever since moving to the new machine I get the dreaded "The type or namespace name 'YourAssembly' could not be found (are you missing a using directive or an assembly reference?" error message. The references are clearly shown in the Visual Studio but when the project builds it does not copy them to the bin directory which explains the message. Initially I was just referencing the dlls the way I would any 3rd party dll but I even tried removing that and including the project files in my solution and referencing them that way and still it fails. I've verified that the dlls have their 'Copy Local' property set to true and they do. Its really bizarre because the project references several other dlls that are just 3rd party assemblies (for example NLog, GData, etc) and those all copy over fine but not these two for some strange reason.
Here's one more piece of oddness. If I add some code to the console app that references my assemblies it says it can't find it. If I then re-add the assemblies to the references, the error disappears until I try to build it again and then it returns. Is this a VS bug or what? I've never seen this kind of odd behavior before.
thanks
One case that I have seen that caused the problems you are talking about:
Including references to dlls that are built in-house, linked to a specific version of the dll. Get a new copy of the dll (with a different version number) and the build breaks.
The solution in this case is to set the DLL reference property Specific Version to false. The version of the dll is ignored (in my case, it is safe to ignore it), and the build works properly.
I've also had weird errors like this where the NTFS permissions were set on the old file with an old login, but the new machine didn't like the old permissions.
Also, sometimes the old .sln or .csproj file refers to an odd file path that you can't seem to edit from within VStudio. Try opening those files with notepad and make sure the paths aren't broken. You can usually edit and save with fixed paths and things will work again.
Hans had the answer above but I was unable to find that post through searches so hopefully if you stumble upon this question I can save you several hours of frustration.
For some bizarre reason the 'Target Framework' was defaulting to ".NET Framework 4 - Client Profile" in the project properties. I double checked and it seems to do that whenever I create a new console app. It must be version related thing in VS because I hadn't encountered this issue previously in 2010.
To fix:
Right click on your project, choose properties
Under the main Application tab, set the Target Framework to be your framework of choice but NOT one of the 'Client Profile' options
Save and build as normal

I've been asked to deploy, but I cant make the magic happen

I've added a couple of lines to a file, let's say it builds to be foo.dll. It's part of more then one dll file, but it's the core dll. What I did was that I added a couple of lines so it should add some log data to the database. It should not affect any other files what so ever.
So i tried to deploy it. We don't have the magical one click deploy, we are just copying the right files to the right place.
So now, since i have a change in foo.dll, i thought for myself that i just could copy foo.dll and the server would be happy.
I was wrong. Browsing the website i now get "Generic Errors", dont know what that is. I've also tried to copy all the new dll files (4 i total) but that did not solve the problem either.
The error it gives are
Http Error 404.0 not found
Module: ISS Web Core
Notification: MapRequestHandler
Handler: Static File
Error Code: 0x80070002
replacing the new foo.dll with the old one solves the problem. and i've tried to restart the webserver. :-(
I asume you have "published" and not just "compiled" your Web?
You also need to take care off the "Solution Configurations": Debug and Release.
In a normal publish process you would change the configuration to release and publish your project into another folder.
After you have done that you just need to collect the desired files and upload them.
Keep in mind that you need the newest version of you web project. Maybe there are some changes online that your local project hasn'T. This would cause such problems.
We don't have the magical one click deploy
Why not? It's not magic, and it's pretty easy to set up. Get any continuous integration software (I would recommend BuildMaster since I am a developer for it and it's free now) and you'll never have this problem again.

Resources