.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Using Reflection to get System.ComponentModel.DisplayName or Description

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :Windows Application
I have a class and on the properties I have assigned the attributes System.ComponentModel.DisplayName and System.ComponentModel.Description.  Using reflection I can't seem to retrieve these attribute values.  How can I do this?

View Complete Post

More Related Resource Links

System.ComponentModel.DescriptionAttribute not showing up in REST service

I am trying to set the description for a REST WCF service, but it doesn't seem to be working. Code is: [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]     [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]     [WebDispatchFormatterConfiguration("application/xml")]     [WebDispatchFormatterMimeType(typeof(WcfRestContrib.ServiceModel.Dispatcher.Formatters.PoxDataContract), "application/xml", "text/xml")]     [WebDispatchFormatterMimeType(typeof(WcfRestContrib.ServiceModel.Dispatcher.Formatters.DataContractJson), "application/json")]     [WebDispatchFormatterMimeType(typeof(WcfRestContrib.ServiceModel.Dispatcher.Formatters.FormUrlEncoded), "application/x-www-form-urlencoded")]     public class PublicAppointmentSchedulerSvc : IPublicAppointmentScheduler     {         IPublicAppointmentScheduler impl = new PublicAppointmentScheduler();         [WebDispatchFormatter]         [Description("Immediate or callback contact request")]         [WebInvoke(UriTemplate = "InitiateContact", Method = Verbs.Post)]  &n

System.ComponentModel.Win32Exception: The operation completed successfully

Hi,      I'm calling a .Net 1.1 Infragistics calender windows control (32 bit) from a html page (old code) in Windows 2008 Server R2 (with WOW64) . This control was working on all operating systems including Windows 7 and when loaded in Windows 2008 Server R2 it throws up the exception given below. I'm able to load the control sometimes, say 5% successful (only the first time when I load the application) and the remaining 95% it throws up the exception dialog box (sometimes it happens when I load the application for the first time too). Not sure whether this is the right forum, if it's not please direct me to the right forum. -------------------------------------------------------------------------------------------------------------------- See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.ComponentModel.Win32Exception: The operation completed successfully    at System.Drawing.BufferedGraphicsContext.CreateCompatibleDIB(IntPtr hdc, IntPtr hpal, Int32 ulWidth, Int32 ulHeight, IntPtr& ppvBits)    at System.Drawing.BufferedGraphicsContext.CreateBuffer(IntPtr src, Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)    at System.Drawing.BufferedGraphicsContext.AllocBuffer(Graphics targetGraphics, IntPtr target

System.Reflection: How to use the name of fields within classes to get the values?

Hey there, I have  a class defiend as follows:public class VisitorStat { public int? PageViews { get; set; } public int? Visits { get; set; } public int? Visitors { get; set; } ... } At some point in my program, I need to gather the  Visitor stats and create a report table.List<VisitorStat> visitorStats = GetVisitorStats(startDate, endDate);   My issue is this: Because there are many rows in the table, rather than hard coding the name for each row as: "PageViews", "Visits", "Visitors"... I want a way to use the name of the fields in the class to create the Row name and insert the appropriate values. I found out about System.Reflection and wrote the following:  Type type = typeof(VisitorStat); // Get type pointer FieldInfo[] fields = type.GetFields(); // Obtain all fields //Start creating a row for each field in the class foreach (var field in fields) // Loop through fields { object temp = field.GetValue(null); //The first cell in the Row contains the name of the field Cell Col2Row1 = new Cell(new Paragraph(field.Name)); PdfTable.AddCell(Col2Row1); //for item returned when calling the function to get t

Code in an event handler not working when used with system reflection.

Hi, I am presently writing an application that uses an MDI form with a ToolStrip on it. I have the need to build the menu items dynamically using an XML file. The format of the XML file is as follows: <ContextMenu EventHandlerHost="vFrmPDUsetup"> <!-- These styles will be applied to the menu items. Individual menu item styles can be override by defining as an attibute to the specific menu item, see below --> <Style> <MenuStripBackColour>Transparent</MenuStripBackColour> <BackColour></BackColour> <ForeColour>Chartreuse</ForeColour> <BackImage></BackImage> <!-- Must exist in Images folder --> <FontName>Tahoma</FontName> <FontSize>10</FontSize> <FontStyle>Bold</FontStyle> </Style> <!-- Attributes: Key = Resource Key name in resource file Image = image to display before text, image must exist in Images folder BackImage = background image, image must exist in Images folder BackColour = background colour as colour name ForeColour = foreground colour as colour name FontSize = size of font as value Seperator = add a menu seperator OnClick = click event pointing to the event handler method which must be defined as the MenuItem_ + <attibute value> &



[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
    public bool AddProduct(int Id, Guid UserId, string Priimek)
        // Create a new ProductRow instance
        Northwind.tbl_zaposleniDataTable products = new Northwind.tbl_zaposleniDataTable();
        Northwind.tbl_zaposleniRow product = products.Newtbl_zaposleniRow();

        product.ID = Id;

        if (Priimek == null) product.SetPriimekNull(); else product.Priimek = Priimek.Value;
        // Add the new product
        int rowsAffected = Adapter.Update(products);

        // Return true if precisely one row was inserted, otherwise false
        return rowsAffected == 1;


Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0117: 'string' does not contain a definition for 'Value'

Source Error:

Line 92: 
Line 93: 
Line 94:         i

System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary Error

I have a WCF service that is using the SharePoint object model to query a list.  (I need my recurrence events.)

I have a Silverlight application referencing that service to display it using a datagrid.

Without referencing the sharepoint object model, everything works fine (test data).  Once I start using the SPsite, SPweb, I receive:
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30618)
Timestamp: Mon, 21 Sep 2009 01:29:39 UTC
Message: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
   at CalendarSVCApplication.TestDataRef.GetTestDataCompletedEventArgs.get_Result()
   at CalendarSVCApplication.MainPage.AnonymousMethod1(Object s, GetTestDataCompletedEventArgs args)
   at CalendarSVCApplication.MainPage._Lambda$__1(Object s, GetTestDataCompletedEventArgs args)
   at CalendarSVCApplication.TestDataRef.TestData1Client.OnGetTestDataCompleted(Object state)
Line: 1
Char: 1
Code: 0
URI: http:/

System.ComponentModel.PropertyChangedEventHandler not handling the event



I'm working in a wpf app that is binding controls to a class that implements INotifyPropertyChanged. I'm trying to track when there are changes to the underlying object by setting a flag whenever a property is changed. To do so, I wired up an event handler to the PropertyChanged event of the class like so:

_facilityLogic.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(facilityLogic_PropertyChanged);


public void facilityLogic_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
Can anyone tell me why this event handler never gets called? The event is firing, but SetIsChanged() never gets called.

using System.Reflection to saving to database


Hello guy!


I am having challenges saving multiple row to my database using reflection. Each time I cmd.ExecuteNonQuery(), I get the message 'The variable name '@referenceID' has already been declared. Variable names must be unique within a query batch or stored procedure.'

What should i do to resolve this?

Getting System.Reflection.TargetInvocationException while trying to change the AD password of an use



I'm having this problem and I'm not able to solve this for a while now. The scenario is like any user of my web apps can change their application password and the corresponding Server AD ID password from the application itself. I'm using .NET 3.5 framework and was came to know that by using the namespace called

System.DirectoryServices.AccountManagement  we can do any AD ID manupulation by writing C# code. I've written the below code to change the AD password of the user.

#region SetUserDomainPassword for setting the new password as domain password

private bool SetUserDomainPassword(string strUserId, string strNewPassword)


bool blnflag = false;



UserPrincipal oUserPrincipal = GetUser(strUserId);


blnflag = true;

return blnflag;



catch (Exception ex)


ExceptionPolicy.HandleException(ex, "EPolicy");

return blnflag;




#region GetUser for getting the user info

public UserPrincipal GetUser(string sUserName)


PrincipalContext oPrincipalContext = GetPrincipalContext();

UserPrincipal oUserPrincipal =

UserPrincipal.FindByIdentity(oPrincipalContext, sUserName);

Getting System.Reflection.TargetInvocationException while trying to change the AD password from GUI



I'm having this problem and I'm not able to solve this for a while now. The scenario is like any user of my web apps can change their application password and the corresponding Server AD ID password from the application itself. I'm using .NET 3.5 framework and was came to know that by using the namespace called

System.DirectoryServices.AccountManagement  we can do any AD ID manupulation by writing C# code. I've written the below code to change the AD password of the user.



SetUserDomainPassword for setting the new password as domain password


private bool SetUserDomainPassword(st

Odd Behavior in System.Reflection.Emit APIs (.NET Framework 3.5 SP1)

I've noticed an issue during generation of a dynamic assembly to a secondary app domain. The code I'm using to start the assembly looks fairly typical, but it somehow allows the dynamic assembly to be loaded twice into the targeted app domain.

string assemblyName = "MyAssembly";
string moduleName = "MyAssembly.dll";
string typeName = "MyType";
AssemblyName assemblyFullName = new AssemblyName(assemblyName);
AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyFullName, AssemblyBuilderAccess.Run);
ModuleBuilder module = assemblyBuilder.DefineDynamicModule(moduleName);
Upon further inspection, I used code to print the list of assemblies actually loaded into the current app domain (that was how I first noticed the issue above). Also, I inspected the condition of the domain using the AssemblyLoad event, and it confirmed that the assembly was loaded twice. Using that approach, I was able to step into the event handler for each load of the dynamic assembly on the AssemblyBuilder and ModuleBuilder lin

The service 'System.Workflow.ComponentModel.Design.IMemberCreationService' must be installed for t

I am getting this error

One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.

The service 'System.Workflow.ComponentModel.Design.IMemberCreationService' must be installed for this operation to succeed. Ensure that this service is available.


at System.Workflow.ComponentModel.Design.NamePropertyDescriptor.SetValue(Object component, Object value)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager m

The service 'System.Workflow.ComponentModel.Design.IIdentifierCreationService' must be installed f



I am trying to workthrough "Microsoft Workflow Foundation Tutorials".


I am creating workflow in VS 2008 by adding simple class with .vb extension and getting this error in designer view.

"The service 'System.Workflow.ComponentModel.Design.IIdentifierCreationService' must be installed for this operation to succeed. Ensure that this service is available."


Please guide what to do?

Should System.ComponentModel.Container() be used in a Custom Control


I have developed a simple custom control which is effectively a custom button with a timer, derived from Control. I am unsure of using "components = new System.ComponentModel.Container()". Since the control uses a timer, should it be added to the components container? i.e. components.Add(timer); ? If so, how is it disposed, components.Dispose() is only called if Dispose(true) is called, which i dont? Or should i have a destructor ~MyComponent() which calls timer.Dispose().

In short, when do you use a "components = new Container()" and "components.Add()" in a custom control.

Also, if my control uses Graphics, Brush & Pen objects, should Dispose() be called on them and if so where. In the deconstructor? Or do you leave it up to the garbage collector?


System.ComponentModel and distributed applications



I've just been told about how good .NET is with a broker model for distributed applications. However, I haven't found anything, only a couple of sentences about the component model and how objects can be called from different processes and possibly network places.

So, is this it? I haven't seen any books or articles about System.ComponentModel and the objects therein.

Does anybody have any ideas of how to learn to work with System.ComponentModel?

Lots of Greetings!


System.Reflection.TargetException: Object does not match target type.

 public override void SyncChanges()
        if (WebPartToEdit != null)
            for (int i = 0; i < ColorPickerProperties.Count; i++)
                if (ColorPickerProperties[i] !=null)
                    PropertyInfo info = (PropertyInfo)ColorPickerProperties[i];
                    object val = info.GetValue(WebPartToEdit, null);
                    if ( val!=null)
                        txtCollection[i].Text = val.ToString();

System Development Life Cycle

The Systems Development Life Cycle (SDLC) is a conceptual model used in project management that describes the stages involved in an information system development project from an initial feasibility study through maintenance of the completed application. Various SDLC methodologies have been developed to guide the processes involved including the waterfall model (the original SDLC method), rapid application development (RAD), joint application development (JAD), the fountain model and the spiral model. Mostly, several models are combined into some sort of hybrid methodology
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend