#include "stdafx.h"
// needed for CorBindToRuntimeEx
#include <mscoree.h>
// include the tlb for mscorlib for access to the default AppDomain through
COM Interop
#import <mscorlib.tlb> raw_interfaces_only
high_property_prefixes("_get","_put","_putref")
using namespace mscorlib;
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2)
{
printf("Usage: SvrHost <Managed Exe> [Arguments for Managed Exe]\n");
return 0;
}
ICorRuntimeHost *pCLR = NULL;
// Initialize the CLR. Specify the Server build
HRESULT hr = CorBindToRuntimeEx(
L"v1.1.4322",
L"svr",
NULL,
CLSID_CorRuntimeHost,
IID_ICorRuntimeHost,
(PVOID*) &pCLR);
assert(SUCCEEDED(hr));
// Start the CLR
pCLR->Start();
// Get a pointer to the default AppDomain
_AppDomain *pDefaultDomain = NULL;
IUnknown *pAppDomainPunk = NULL;
hr = pCLR->GetDefaultDomain(&pAppDomainPunk);
assert(pAppDomainPunk);
hr = pAppDomainPunk->QueryInterface(__uuidof(_AppDomain), (PVOID*)
&pDefaultDomain);
assert(pDefaultDomain);
// get the name of the exe to run
long retCode = 0;
BSTR asmName = SysAllocString(argv[1]);
// Collect the command line arguments to the managed exe
SAFEARRAY *psa = NULL;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = (argc - 2);
psa = SafeArrayCreate(VT_BSTR, 1, rgsabound);
assert(psa);
for (int i = 2; i < argc; i++)
{
long idx[1];
idx[0] = i-2;
SafeArrayPutElement(psa, idx, SysAllocString(argv[i])); }
// Run the managed exe in the default AppDomain
hr = pDefaultDomain->ExecuteAssembly_3(asmName, NULL, psa, &retCode);
// clean up
SafeArrayDestroy(psa);
SysFreeString(asmName);
pAppDomainPunk->Release();
pDefaultDomain->Release();
_tprintf(L"\nReturn Code: %d\n", retCode);
return retCode;
}
"Ryan Stevens" <ryan.s...@solidstore.co.uk> wrote in message
news:#5rXej8H...@TK2MSFTNGP10.phx.gbl...
Does version 1.1 allow you to specify which GC to try?
"Steven Pratschner [MS]" <stev...@online.microsoft.com> wrote in message
news:%23nx5kl9...@TK2MSFTNGP11.phx.gbl...
"Ryan Stevens" <ryan.s...@solidstore.co.uk> wrote in message news:<OSwhSuDI...@TK2MSFTNGP11.phx.gbl>...
Tim
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
--------------------
>From: pla...@hemisphere.bm (Patrice Lafond)
>Newsgroups: microsoft.public.dotnet.framework.clr
>Subject: Re: Server vs Workstation GC
>Date: 18 Jun 2003 07:44:17 -0700
>Organization: http://groups.google.com/
>Lines: 146
>Message-ID: <b5c60337.0306...@posting.google.com>
>References: <#5rXej8H...@TK2MSFTNGP10.phx.gbl>
<#nx5kl9H...@TK2MSFTNGP11.phx.gbl>
<OSwhSuDI...@TK2MSFTNGP11.phx.gbl>
>NNTP-Posting-Host: 209.27.58.82
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1055947457 15786 127.0.0.1 (18 Jun 2003
14:44:17 GMT)
>X-Complaints-To: groups...@google.com
>NNTP-Posting-Date: 18 Jun 2003 14:44:17 GMT
>Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newshosting.com!news-xf
er1.atl.newshosting.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.
net!prodigy.com!prodigy.com!pd2nf1so.cg.shawcable.net!residential.shaw.ca!sn
-xit-03!sn-xit-01!sn-xit-08!sn-xit-09!supernews.com!postnews1.google.com!not
-for-mail
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.clr:7047
>X-Tomcat-NG: microsoft.public.dotnet.framework.clr