Hi. I'm developing an addon for a Unity-based game. The addon is written in C#, class library. Since the game takes some time to launch, I'm trying to reload my DLL at runtime, doing this will help me save time by not having to wait for the loading screen. I've already got a similar result using AppDomains but I found that some methods were throwing exceptions and the cause is communication between AppDomains. It seems like to use AppDomains the classes need to be serializable or inherit from a certain class, but I don't have access to the game's source code, so I can't change some things. So I am trying to reload an assembly in the same AppDomain, but changing its name, as it is not possible to reload another assembly in the same AppDomain if another one is already loaded. The problem is I can't generate random assembly name each build. See below what I tried to do:
In my .csproj, I included these three lines of code:
<PropertyGroup> <MyNewGuid>$([System.DateTime]::Now.ToString("HHmmss"))</MyNewGuid> </PropertyGroup>
And in the AssemblyName property I put something like this:
As you can see, it will include the current time in the assembly name, but sometimes when I click to build the solution, it includes an old time. Looks like Visual Studio is caching and not running the code in the MyNewGuid property every time.
How can I generate random assembly name every build every time?