Исправлен вылет при выгрузке модуля

This commit is contained in:
Kernell 2015-12-03 02:40:12 +03:00
parent ade2e99586
commit 2b20afcb59
4 changed files with 16 additions and 4 deletions

View File

@ -40,6 +40,11 @@ CMonoDomain::~CMonoDomain( void )
this->m_ClassPool.clear();
if( this->m_pDomain )
{
mono_domain_finalize( this->m_pDomain, 2000 );
}
this->m_pDomain = nullptr;
this->m_pMonoAssembly = nullptr;
@ -96,7 +101,7 @@ bool CMonoDomain::Start( void )
string sClass ( "Program" );
this->m_pMonoAssembly = this->OpenAssembly( sPath.c_str() );
if( !this->m_pMonoAssembly )
{
g_pModuleManager->ErrorPrintf( "failed to open assembly '%s.dll'\n", this->m_strName.c_str() );

View File

@ -23,8 +23,6 @@ CMonoInterface::CMonoInterface( void )
this->m_pMonoDomain = mono_jit_init_version( "Mono Root", "v4.0.30319" );
mono_domain_set_config( this->m_pMonoDomain, "mods/deathmatch/", "mods/deathmatch/mono/etc/mono/4.5/machine.config" );
CMonoFunctions::AddInternals();
this->m_pGC = new CMonoGC;
@ -48,3 +46,10 @@ CMonoDomain* CMonoInterface::CreateAppdomain( CResource* pResource, char* szName
return nullptr;
}
void CMonoInterface::SetDomain( MonoDomain* pDomain, bool bForce )
{
mono_domain_set( pDomain != nullptr ? pDomain : this->m_pMonoDomain, bForce );
mono_domain_set_config( pDomain != nullptr ? pDomain : this->m_pMonoDomain, "mods/deathmatch/", "mods/deathmatch/mono/etc/mono/4.5/machine.config" );
}

View File

@ -32,6 +32,8 @@ public:
CMonoDomain* CreateAppdomain ( CResource* pResource, char* szName, char* szConfig );
void SetDomain ( MonoDomain* pDomain = nullptr, bool bForce = false );
CMonoGC* GetGC ( void ) { return this->m_pGC; }
#pragma region Static methods

View File

@ -27,7 +27,7 @@ CResource::~CResource( void )
this->GetMono()->GetGC()->Collect( this->GetMono()->GetGC()->GetMaxGeneration() );
mono_domain_set( mono_get_root_domain(), true );
this->GetMono()->SetDomain( nullptr, true );
g_pResourceManager->RemoveFromList( this );