473,404 Members | 2,179 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,404 software developers and data experts.

Add custom attributes to ServicedComponent

Hi,

is it possible to use custom context-attributes with serviced components?

[AttributeUsage(AttributeTargets.Class)]
public class Logging : ContextAttribute
{
public Logging() {...}
public override void GetPropertiesForNewContext(IConstructionCallMessag e
ctorMsg) {...}
}

[Logging]
public class LogMe : ServicedComponent
{

}

Thanks in advance,

Stefan
Jul 21 '05 #1
5 1368
Hi Stefan,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know if it is possible to
use customer context-attributes with classes that inherit from
ServicedComponent. If there is any misunderstanding, please feel free to
let me know.

As far as I know, this is possible. I have checked the code you have
provided. Generally, it's correct. However, none of the ContextAttribute
constructors accept 0 arguments. Here I made a little change to your code.
HTH.

[AttributeUsage(AttributeTargets.Class)]
public class Logging : ContextAttribute
{
public Logging(string name) : base(name)
{}
public override void GetPropertiesForNewContext(IConstructionCallMessag e
ctorMsg) {}
}

[Logging("newname")]
public class LogMe : ServicedComponent
{

}

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #2
Hi Kevin,

thanks for your prompt answer. Unfortunately there was a little
misunderstanding.

The attribute-instance itself is created, but GetPropertiesForNewContext
isn't called (which happens when i use the same attribute, but derive my
LogMe-Class from ContextBoundObject).

Precisely my question should have been: Is it possible to use
ContextAttributes with ServicedComponents to intercept function calls?
(ContextAttribute, IContextProperty, IMessageSink)

Thanks,

Stefan

"Kevin Yu [MSFT]" wrote:
Hi Stefan,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know if it is possible to
use customer context-attributes with classes that inherit from
ServicedComponent. If there is any misunderstanding, please feel free to
let me know.

As far as I know, this is possible. I have checked the code you have
provided. Generally, it's correct. However, none of the ContextAttribute
constructors accept 0 arguments. Here I made a little change to your code.
HTH.

[AttributeUsage(AttributeTargets.Class)]
public class Logging : ContextAttribute
{
public Logging(string name) : base(name)
{}
public override void GetPropertiesForNewContext(IConstructionCallMessag e
ctorMsg) {}
}

[Logging("newname")]
public class LogMe : ServicedComponent
{

}

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #3
Hi Stefan,

Do you mean that you need ContextAttributes to affect LogMe class in the
GetPropertiesForNewContext call? I think we cannot do that. Because
attributes are used to provide information for classes passively. It cannot
do anything actively on the applied classes. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #4
Hi Kevin,

our plan is to optimize our application architecture by introducing a kind
of aspect orientation. we've succeeded in intercepting function calls as
described in
http://msdn.microsoft.com/msdnmag/is...T/default.aspx.

Because some of our programms depend on EnterpriseServices we're now
evaluating wether the above mentioned technique is applicable for
ServicedComponents?

Thanks in advance,

Stefan
Jul 21 '05 #5
Hi Stefan,

According to the article, presently, .NET contexts and interception are
undocumented aspects of .NET. So it's not supported.

However, if this can apply to all classes to .NET framework, it can be used
on ServicedComponent. But IMO, I don't recommend to do so, because if it
fails, there is few resources for us to find for help.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Doug Holland | last post by:
Often you see code where an empty interface is used to indicate something about the class that realizes it. In the .NET world this can be done with custom attributes too, so which is better: ...
3
by: xAvailx | last post by:
I apologize ahead of time for the long post... Background: Working on a CRM type custom application. The application is for an event management company. The company will provide the application...
8
by: nicolas.sanguinetti | last post by:
Hi, I want to add custom attributes to my xhtml documents to use with my DOM scripts. For example, I want to have some tags -say, the <h1>- have an attribute and a . The thing is that I also...
1
by: Bret Pehrson | last post by:
I've converted a non-trivial C++ library to managed, and get the following unhelpful linker error: Assignment.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are...
3
by: Edward Diener | last post by:
I understand the syntax of custom attributes, but I have no idea what they are supposed to do. Anyone care to give me a clue as to their functionality ?
1
by: Tamas Demjen | last post by:
I started to experiment with VC++ 2005 Beta1. So far everything went fine, and already have a working project, but soon I realized that the compiler was ancient (not supporting half of the C++/CLI...
3
by: Mark R. Dawson | last post by:
Hi all, I am trying to get custom attributes from a property. I can do this if I pass in the name of the property i.e. "Name" to the reflection methods, but if I pass in set_Name which is what...
2
by: prabhupr | last post by:
Hi Folks I was reading this article (http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on "Custom Attribute", written by Bipin. The only thing I did not understand in this article...
5
by: =?Utf-8?B?cGFnYXRlcw==?= | last post by:
Hello All, I am sure that I am just overlooking something, but here's something I can't quite get right... I want to be able to get the value of a parameter of an unknown custom attribute at...
1
camel
by: camel | last post by:
Apologies if foolish question, but I somewhat expected Custom Attributes (i.e. inheriting from System.Attribute) decorating class properties to come through via WSDL to the proxy the same as...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.