471,315 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,315 software developers and data experts.

Ambiguity with ContextID in entprise services.

Can't ace in how client and server component contexts correspons with
each other.
Server-side (entperiseServices) component is always created in context.
But I'd like to create serverside component in *client context*, and
therefore contextID of the client and server should be the same. For
unknown reasons, I got different context ID (albeit sync options are
the same)

Who can clarify this and say how to create server side component in
client context?

I use such code for client

static void Main(string[] args)
{
// Define context attributes
ServiceConfig config = new ServiceConfig();
config.Synchronization = SynchronizationOption.Required;

// Create client context
ServiceDomain.Enter(config);
// Show client context ID
Console.WriteLine(ContextUtil.ContextId.ToString() );

// Create server side component
Class1 cl = new Class1();
// Show server side component's contextID
Console.WriteLine(cl.State());
}

Code for server component

[EventTrackingEnabled]
[Synchronization(SynchronizationOption.Required)]
public class Class1: ServicedComponent
{
public Class1()
{
}

public string State()
{
return "Activity: " + ContextUtil.ActivityId.ToString() + "
Context: " + ContextUtil.ContextId.ToString() + " Instance: " +
ContextUtil.ApplicationInstanceId.ToString();
}

Jan 5 '06 #1
3 1741
Michael,

Just curious, are you registering this as in process or out of process?
If it is out of process, then the context is always going to be different.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Michael Nemtsev" <la*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Can't ace in how client and server component contexts correspons with
each other.
Server-side (entperiseServices) component is always created in context.
But I'd like to create serverside component in *client context*, and
therefore contextID of the client and server should be the same. For
unknown reasons, I got different context ID (albeit sync options are
the same)

Who can clarify this and say how to create server side component in
client context?

I use such code for client

static void Main(string[] args)
{
// Define context attributes
ServiceConfig config = new ServiceConfig();
config.Synchronization = SynchronizationOption.Required;

// Create client context
ServiceDomain.Enter(config);
// Show client context ID
Console.WriteLine(ContextUtil.ContextId.ToString() );

// Create server side component
Class1 cl = new Class1();
// Show server side component's contextID
Console.WriteLine(cl.State());
}

Code for server component

[EventTrackingEnabled]
[Synchronization(SynchronizationOption.Required)]
public class Class1: ServicedComponent
{
public Class1()
{
}

public string State()
{
return "Activity: " + ContextUtil.ActivityId.ToString() + "
Context: " + ContextUtil.ContextId.ToString() + " Instance: " +
ContextUtil.ApplicationInstanceId.ToString();
}

Jan 5 '06 #2
I use ActivationOption.Library - that's why I'm so confused.
PS: I use FW 2.0

Could u try by yourself? What's your results? The same contextID?

Jan 5 '06 #3
Interestingly, using attibute [MustRunInClientContext] gives an error
"Unhandled Exception: System.Runtime.InteropServices.COMException
(0x80004024): The specified activation could not occur in the client
context as specified. (Exception from HRESULT: 0x80004024)"

Scrutinizing options of my component in ComponentServices Browser I've
noted that in Activation tab I have option
"Don't force activation context" is checked ON. After checking ON "Must
be activated in caller context" instead - all works fine, the contexts
ID are the same.

Nickolas, could u make this clear?
PS: Is it possible to turn on this feature by attibute?
PPS: Aren't "MustRunInClientContext" and "Must be activated in caller
context" the same?

Jan 5 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.