473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 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 1805
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: subramanian100in | last post by:
I have tried the following in VC++ 2005 Express Edition and g++ in Linux. Consider the class class my_complex { public: my_complex(double r, double i = 10.0) : re(r), im(i) { }...
2
by: subramanian100in | last post by:
Consider the program #include <iostream> using namespace std; void fn(const char * str, char x = 'Y') { cout << "from fn(const char *, char) - " << str << endl; return;
4
by: abendstund | last post by:
Hi, I have the following code and trouble with ambiguity due to operator overloading.. The code is also at http://paste.nn-d.de/441 snip>>
7
by: abendstund | last post by:
Hi, I have the following code and trouble with ambiguity due to operator overloading.. The code is also at http://paste.nn-d.de/441 snip>>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.