コード例 #1
0
ファイル: ProxyDomain.cs プロジェクト: Fernir/OnyxLib
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (m_onyxEntryPointImplementation == null)
     {
         return;
     }
     Logger.DebugFormat("[AR.UnloadAssembly] Disposing instance {0}...", m_onyxEntryPointImplementation);
     try
     {
         m_onyxEntryPointImplementation.Dispose();
         Logger.DebugFormat("[AR.UnloadAssembly] Successfully disposed", m_onyxEntryPointImplementation);
     }
     catch (Exception ex)
     {
         Logger.ErrorFormat("[AR.UnloadAssembly] Exception occurred during disposing {0} - {1}\r\n{2}", m_onyxEntryPointImplementation, ex.Message, ex.StackTrace);
     }
     m_onyxEntryPointImplementation = null;
 }
コード例 #2
0
ファイル: ProxyDomain.cs プロジェクト: Fernir/OnyxLib
        private void LoadAssembly(string _assemblyPath)
        {
            if (m_loadedAssembly != null)
            {
                throw new InvalidOperationException(String.Format("Assembly '{0}' already loaded in this domain, you cannot load any more assemblies", m_loadedAssembly));
            }
            Logger.DebugFormat("[AR.LoadAssembly] Loading {0} in AD '{1}'", _assemblyPath, AppDomain.CurrentDomain.FriendlyName);
            m_loadedAssembly = Assembly.LoadFrom(_assemblyPath);
            if (_assemblyPath == null)
            {
                throw new ArgumentNullException("_assemblyPath");
            }
            var entryPointType = m_loadedAssembly.GetTypes().FirstOrDefault(x => typeof(IOnyxEntryPoint).IsAssignableFrom(x));

            if (entryPointType == null)
            {
                throw new ApplicationException(String.Format("Could not find class, that implements {0} in {1}", typeof(IOnyxEntryPoint), m_loadedAssembly));
            }
            Logger.DebugFormat("[AR.LoadAssembly] Instantiating {1}.'{0}' in AD '{2}'", entryPointType.FullName, m_loadedAssembly, AppDomain.CurrentDomain.FriendlyName);
            m_onyxEntryPointImplementation = (IOnyxEntryPoint)Activator.CreateInstance(entryPointType);
        }