Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / Проблема с TypeConvertor и InstanceDescriptor / 1 сообщений из 1, страница 1 из 1
25.02.2013, 15:57
    #38165025
tual
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Проблема с TypeConvertor и InstanceDescriptor
Сообщение об ошибке в аттаче.

Есть юзерконтрол для ВинФормс. Он засунут в dll.
Создаю новый ВинФормс проект (.NET4) и кидаю контрол на форму. Тут все ок.
А потом если скомпилить проект, или даже просто закрыть студию, выдается сообщение об ошибке из скриншота.

Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
public sealed class MarginsFConverter : ExpandableObjectConverter

...
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
		{
			if (destinationType == typeof(InstanceDescriptor))
			{
				return true;
			}
			return base.CanConvertTo(context, destinationType);
		}

public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
		{
			if (destinationType == null)
			{
				throw new ArgumentNullException("destinationType");
			}
			if ((destinationType == typeof(string)) && (value is MarginsF))
			{
				MarginsF margins1 = (MarginsF) value;
				if (culture == null)
				{
					culture = CultureInfo.CurrentCulture;
				}
				string text1 = culture.TextInfo.ListSeparator + " ";
				TypeConverter converter1 = TypeDescriptor.GetConverter(typeof(float));
				string[] textArray1 = new string[4];
				int num1 = 0;
				
				textArray1[num1++] = converter1.ConvertToString(context, culture, margins1.Left);
				textArray1[num1++] = converter1.ConvertToString(context, culture, margins1.Right);
				textArray1[num1++] = converter1.ConvertToString(context, culture, margins1.Top);
				textArray1[num1++] = converter1.ConvertToString(context, culture, margins1.Bottom);
				return string.Join(text1, textArray1);
			}

            if ((destinationType == typeof(InstanceDescriptor)))
            {
                if (value is MarginsF)
                {
                    MarginsF margins2 = (MarginsF)value;
                    Type[] typeArray1 = new Type[4] { typeof(float), typeof(float), typeof(float), typeof(float) };
                    ConstructorInfo info1 = typeof(MarginsF).GetConstructor(typeArray1);
                    if (info1 != null)
                    {
                        object[] objArray1 = new object[4] { margins2.Left, margins2.Right, margins2.Top, margins2.Bottom };
                        return new InstanceDescriptor(info1, objArray1);
                    }
                }
                else
                {
                    Type[] typeArray1 = new Type[4] { typeof(float), typeof(float), typeof(float), typeof(float) };
                    ConstructorInfo info1 = typeof(MarginsF).GetConstructor(typeArray1);
                    return new InstanceDescriptor(info1, null, false);
                }
            }

		    return base.ConvertTo(context, culture, value, destinationType);
		}



Такая ошибка вылетает только 1 раз, когда я добавляю контрол с тулбара. Если сбилдить 2ой раз, то ошибки уже нет.
Читал, что это проблемы студии, но может ей помочь можно как-то.
...
Рейтинг: 0 / 0
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / Проблема с TypeConvertor и InstanceDescriptor / 1 сообщений из 1, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]