Showing posts with label VS2010. Show all posts
Showing posts with label VS2010. Show all posts

Monday, 2 December 2024

How to Create a Generic Method to Get the Enum Description in C#

        public static SelectList GetSelectListForEnumWithDescription(Type enumType)
        {
            var list = new List<Object>();
            Array enumValues = Enum.GetValues(enumType);
         
            foreach (Enum enumValue in enumValues)
            {
                list.Add(new
                              {
                                 ID = (int)Enum.Parse(enumType, enumValue.ToString()),
                                 Value = GetEnumDescription(enumValue)});
                               }
              return new SelectList(list, "ID", "Value");
        }

        public static string GetEnumDescription(Enum value)
        {

            FieldInfo fi = value.GetType().GetField(value.ToString());

            DescriptionAttribute[] attributes =
                (DescriptionAttribute[]) fi.GetCustomAttributes(typeof (DescriptionAttribute), false);

            if (attributes != null && attributes.Length > 0)

                return attributes[0].Description;

            else return value.ToString();
        }
    }

Tuesday, 11 March 2014

MetadataException: Unable to load the specified metadata resource in Visual Studio 2012 or in Entity Frame work

When ever you are getting this error , just be sure that this property was bind in you Entity Framework.

Just open your  .edmx file , go to the properties and then set the property of the "Metadata Artifact Processing"  to "Embed in Output Assembly". That's all your problem is fixed.


Friday, 11 January 2013

Error n(e.g. 8 or 12)Files has invalid value "<<<<<<< .mine". Illegal characters in path.

I got some peculiar error after taking the update of the solution  from SVN.
So in order to fix it i tried a lot of way but unable to find out the issue as it doesn't show the file where  .>>>>>>>>>>>>>>>>> mine or .<<<<<<<<<<<< mine exists. After a through review i find out that it is due to the different version of the files in the respective folder where .obj folder is there.


So, in order to fix this issue, just go to the respective folder and delete the version-ed file names or delete the old ones and rename the latest file to the original one.

The other approach is simply delete the /obj folder in each project that is complaining and re-compile.

This error is caused by the Subversion "Resolved..." function.

Enjoy !