У меня есть следующий объект Com:Reflection для COM-объекта
public interface ParagraphFormat2 : _IMsoDispObj
{
[DispId(2)]
MsoParagraphAlignment Alignment { get; set; }
[DispId(1610743808)]
object Application { get; }
[DispId(3)]
MsoBaselineAlignment BaselineAlignment { get; set; }
[DispId(4)]
BulletFormat2 Bullet { get; }
}
Мне нужно установить Пули собственность, поэтому я утомительно использовать отражение, но неудачно: - первый попробовать:
PropertyInfo prop = typeof(Microsoft.Office.Core.ParagraphFormat2)
.GetProperty("Bullet", BindingFlags.Public |
BindingFlags.Instance |
BindingFlags.GetProperty);
if (null != prop && prop.CanWrite)
{
prop.SetValue(objParagraphFormat, bullet, null);
}
Вторая попытка:
typeof(Microsoft.Office.Core.ParagraphFormat2)
.GetField("Bullet", BindingFlags.PutDispProperty |
BindingFlags.PutRefDispProperty)
.SetValue(objParagraphFormat, new object[] { bullet });
Любые идеи, как это можно сделать?
Ну, «ParagraphFormat2» также доступен для чтения, поэтому я не понимаю, что PrtToStructure здесь не помогает. – rol