コード例 #1
0
        private static Dictionary <string, Assembly> assemblyPathsReverse; // ToLower version of the path for lookups

        internal static void Initialize(AssemblyContextRef reference)
        {
            Debug.Assert(!initialized);

            initialized = true;
            Reference   = reference;

            if (AssemblyContext.IsCoreCLR && !reference.IsInvalid)
            {
                // No need to remove these events, they will be cleared up when the unload is called on the context
                AssemblyContextProxy.AddUnloadingEvent(reference, onUnloading);
                AssemblyContextProxy.AddUnloadingResolving(reference, onResolving);

                assemblyPaths        = new Dictionary <Assembly, string>();
                assemblyPathsReverse = new Dictionary <string, Assembly>();
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            AppDomain.CurrentDomain.AssemblyLoad    += CurrentDomain_AssemblyLoad;
        }
コード例 #2
0
ファイル: EntryPoint.cs プロジェクト: zwywilliam/USharp
        public static int DllMain(string arg)
        {
            try
            {
                Args args = new Args(arg);

                if (!SharedRuntimeState.Initialized)
                {
                    SharedRuntimeState.Initialize((IntPtr)args.GetInt64("RuntimeState"));

                    AssemblyContextRef currentContext;
                    AssemblyContextRef.TryParse(args.GetString("AssemblyContext"), out currentContext);
                    AssemblyContext.Initialize(currentContext);
                    CurrentAssemblyContext.Initialize(currentContext);
                }

                if (args.GetBool("Preloading"))
                {
                    Preloading = true;
                    IntPtr address = (IntPtr)args.GetInt64("RegisterFuncs");
                    if (address != IntPtr.Zero)
                    {
                        NativeFunctions.RegisterFunctions(address);
                        Preloaded = true;
                    }
                    Preloading = false;
                    return(0);
                }
                else
                {
                    unsafe
                    {
                        SharedRuntimeState.Instance->ActiveRuntime = SharedRuntimeState.CurrentRuntime;
                    }

                    DateTime beginUnload = default(DateTime);
                    TimeSpan beginReload = DateTime.Now.TimeOfDay;

                    bool isReloading = false;
                    using (var timing = HotReload.Timing.Create(HotReload.Timing.TotalLoadTime))
                    {
                        using (var subTiming = HotReload.Timing.Create(HotReload.Timing.DataStore_Load))
                        {
                            // If this is a hot-reload then set up the data store
                            HotReload.Data = HotReload.DataStore.Load(SharedRuntimeState.GetHotReloadData());
                            beginUnload    = HotReload.Data.BeginUnloadTime;
                        }

                        HotReload.IsReloading = args.GetBool("Reloading");
                        isReloading           = HotReload.IsReloading;

                        IntPtr address = (IntPtr)args.GetInt64("RegisterFuncs");
                        if (address != IntPtr.Zero)
                        {
                            NativeFunctions.RegisterFunctions(address);
                        }
                    }

                    SharedRuntimeState.SetHotReloadAssemblyPaths(HotReloadAssemblyPaths);

                    TimeSpan endTime = DateTime.Now.TimeOfDay;
                    FMessage.Log("BeginReload: " + beginReload + " (BeginUnload-BeginReload: " + (beginReload - beginUnload.TimeOfDay) + ")");
                    FMessage.Log("EndReload: " + endTime + " (BeginUnload-EndReload: " + (endTime - beginUnload.TimeOfDay) + ")");
                    HotReload.Timing.Print(isReloading);
                    HotReload.Timing.PrintAll();
                    return(0);
                }
            }
            catch (Exception e)
            {
                string exceptionStr = "Entry point exception (UnrealEngine.Runtime): " + e;
                if (SharedRuntimeState.Initialized)
                {
                    SharedRuntimeState.LogError(exceptionStr);
                    SharedRuntimeState.MessageBox(exceptionStr, "Error");
                }
                return(1005);// AssemblyLoaderError.Exception
            }
        }