Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Server vs Workstation GC

21 views
Skip to first unread message

Ryan Stevens

unread,
May 21, 2003, 2:43:39 PM5/21/03
to
Will a Windows Service exe written in C# use the Server or Workstation
version? Do I have to write a runtime host?


Steven Pratschner [MS]

unread,
May 21, 2003, 4:42:21 PM5/21/03
to
Exe's always use the workstation. As you suggest, you must write a small
runtime host that loads the svr build and launches your app. Here's a
sample c++ app that I've been using. By the way, remember that the server
build will only be loaded on multi-proc machines - even if you specify "svr"
you'll get "wks" on uniproc.

#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...

Ryan Stevens

unread,
May 22, 2003, 4:24:46 AM5/22/03
to
Is it recommended that I run my C# service exe like this?

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...

Patrice Lafond

unread,
Jun 18, 2003, 10:44:17 AM6/18/03
to
Hmmm, good question, any comment on that?

"Ryan Stevens" <ryan.s...@solidstore.co.uk> wrote in message news:<OSwhSuDI...@TK2MSFTNGP11.phx.gbl>...

Tim Kurtzman

unread,
Jun 27, 2003, 6:28:09 PM6/27/03
to
There isn't any new functionality introduced in v1.1 that makes the
selection of the GC any easier or harder. If you want to use the server
build on v1.1, Steven's code example is the way to go.

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

0 new messages