回复 4楼iceman的帖子
ADCreateDomain.exe.config没有这个文件啊,
AppDomain^ newDomain = AppDomain::CreateDomain( "MyDomain", adevidence, domaininfo );我得到的newDomain 属性值倒是error的,我是再mfc中添加的- BOOL Ctest_for_csharp_dllApp::InitInstance()
- {
- // InitCommonControlsEx() is required on Windows XP if an application
- // manifest specifies use of ComCtl32.dll version 6 or later to enable
- // visual styles. Otherwise, any window creation will fail.
- INITCOMMONCONTROLSEX InitCtrls;
- InitCtrls.dwSize = sizeof(InitCtrls);
- // Set this to include all the common control classes you want to use
- // in your application.
- InitCtrls.dwICC = ICC_WIN95_CLASSES;
- InitCommonControlsEx(&InitCtrls);
- CWinAppEx::InitInstance();
- AfxEnableControlContainer();
- // Standard initialization
- // If you are not using these features and wish to reduce the size
- // of your final executable, you should remove from the following
- // the specific initialization routines you do not need
- // Change the registry key under which our settings are stored
- // TODO: You should modify this string to be something appropriate
- // such as the name of your company or organization
- SetRegistryKey(_T("Local AppWizard-Generated Applications"));
- AppDomainSetup^ domaininfo = gcnew AppDomainSetup;
- domaininfo->ApplicationBase = System::Environment::CurrentDirectory;
- domaininfo->ConfigurationFile = System::Environment::CurrentDirectory + "\\ADCreateDomain.exe.config";
- domaininfo->ApplicationName = "test_for_csharp_dll";
- domaininfo->LicenseFile = System::Environment::CurrentDirectory + "\\licenses.txt";
- //Create evidence for new appdomain.
- Evidence^ baseEvidence = AppDomain::CurrentDomain->Evidence;
- Evidence^ adevidence = gcnew Evidence( baseEvidence );
- //Add the zone and url information to restrict permissions assigned to the appdomain.
- adevidence->AddHost( gcnew Url( "http://www.example.com" ) );
- adevidence->AddHost( gcnew Zone( SecurityZone::Internet ) );
- // Create the application domain.
- AppDomain^ newDomain = AppDomain::CreateDomain( "MyDomain", adevidence, domaininfo );
-
- // Write out the application domain information.
- Console::WriteLine( "Host domain: {0}", AppDomain::CurrentDomain->FriendlyName );
- Console::WriteLine( "child domain: {0}", newDomain->FriendlyName );
- Console::WriteLine();
- Console::WriteLine( "Application base is: {0}", newDomain->SetupInformation->ApplicationBase );
- Console::WriteLine( "Configuration file is: {0}", newDomain->SetupInformation->ConfigurationFile );
- Console::WriteLine( "Application name is: {0}", newDomain->SetupInformation->ApplicationName );
- Console::WriteLine( "License file is: {0}", newDomain->SetupInformation->LicenseFile );
- IEnumerator^ newevidenceenum = newDomain->Evidence->GetEnumerator();
- while ( newevidenceenum->MoveNext() )
- Console::WriteLine( newevidenceenum->Current );
- Ctest_for_csharp_dllDlg dlg;
- m_pMainWnd = &dlg;
- INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
- // TODO: Place code here to handle when the dialog is
- // dismissed with OK
- }
- else if (nResponse == IDCANCEL)
- {
- // TODO: Place code here to handle when the dialog is
- // dismissed with Cancel
- }
- AppDomain::Unload( newDomain );
- // Since the dialog has been closed, return FALSE so that we exit the
- // application, rather than start the application's message pump.
- return FALSE;
- }
复制代码 |