We help IT Professionals succeed at work.

How do I print ActiveX type from .NET

870 Views
Last Modified: 2013-12-17
Ive written a program to dump out using .NET the objects in a crystal report.  This uses Crystals RDC ActiveX component.

Here is the problem.  When I dump an ActiveX object, I dont see the ActiveX type.  Here is what I see:

oFld.Field=System.__ComObject

Every Com object is seen as System.__ComObject.

How do I see the ActiveX type (which in this case might be IParameterField) of oFld.Field?

Im programming in C#.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CRAXDDRT;
 
namespace Dumper
{
    class Dumper
    {
        static void Main(string[] args)
        {
            Application crApp = new Application();
            Report report;
            report = crApp.OpenReport("c:\\Reports\CurrentAdmissions.rpt", 0);
            ProcessReport(report);
        }
 
        static void ProcessReport(IReport report) {
            foreach (Section section in report.Sections)
            {
                Console.WriteLine("Section Name=" + section.Name);
                if (section.ReportObjects.Count != 0)
                {
                    foreach (Object item in section.ReportObjects)
                    {
                        if (item is ITextObject)
                        {
 
                            ITextObject oTxt = (ITextObject)item;
                            Console.WriteLine("oTxt.BackColor=" + oTxt.BackColor);
                            Console.WriteLine("oTxt.BorderColor = " + oTxt.BorderColor);
                            Console.WriteLine("oTxt.BottomLineStyle = " + oTxt.BottomLineStyle);
                            Console.WriteLine("oTxt.CanGrow = " + oTxt.CanGrow);
                            Console.WriteLine("oTxt.CharacterSpacing = " + oTxt.CharacterSpacing);
                            Console.WriteLine("oTxt.CloseAtPageBreak = " + oTxt.CloseAtPageBreak);
                            //Console.WriteLine("oTxt.ConditionFormula = " + oTxt.ConditionFormula(0));
                            Console.WriteLine("oTxt.CssClass = " + oTxt.CssClass);
                            //Console.WriteLine("oTxt.FieldElements = " + oTxt.FieldElements.);
                            Console.WriteLine("oTxt.FirstLineIndent = " + oTxt.FirstLineIndent);
                            Console.WriteLine("oTxt.Font = " + oTxt.Font);
                            Console.WriteLine("oTxt.HasDropShadow = " + oTxt.HasDropShadow);
                            Console.WriteLine("oTxt.Height = " + oTxt.Height);
                            Console.WriteLine("oTxt.HorAlignment = " + oTxt.HorAlignment);
                            Console.WriteLine("oTxt.HyperlinkText = " + oTxt.HyperlinkText);
                            Console.WriteLine("oTxt.HyperlinkType = " + oTxt.HyperlinkType);
                            Console.WriteLine("oTxt.KeepTogether = " + oTxt.KeepTogether);
                            Console.WriteLine("oTxt.Kind = " + oTxt.Kind);
                            Console.WriteLine("oTxt.Left = " + oTxt.Left);
                            Console.WriteLine("oTxt.LeftIndent = " + oTxt.LeftIndent);
                            Console.WriteLine("oTxt.LeftLineStyle = " + oTxt.LeftLineStyle);
                            Console.WriteLine("oTxt.LineSpacing = " + oTxt.LineSpacing);
                            Console.WriteLine("oTxt.LineSpacingType = " + oTxt.LineSpacingType);
                            Console.WriteLine("oTxt.MaxNumberOfLines = " + oTxt.MaxNumberOfLines);
                            Console.WriteLine("oTxt.Name = " + oTxt.Name);
                            Console.WriteLine("oTxt.RightIndent = " + oTxt.RightIndent);
                            Console.WriteLine("oTxt.RightLineStyle = " + oTxt.RightLineStyle);
                            Console.WriteLine("oTxt.Suppress = " + oTxt.Suppress);
                            Console.WriteLine("oTxt.SuppressIfDuplicated = " + oTxt.SuppressIfDuplicated);
                            Console.WriteLine("oTxt.Text = " + oTxt.Text);
                            Console.WriteLine("oTxt.TextColor = " + oTxt.TextColor);
                            Console.WriteLine("oTxt.TextRotationAngle = " + oTxt.TextRotationAngle);
                            Console.WriteLine("oTxt.Top = " + oTxt.Top);
                            Console.WriteLine("oTxt.TopLineStyle = " + oTxt.TopLineStyle);
                            Console.WriteLine("oTxt.Width = " + oTxt.Width);
                            Console.WriteLine("oTxt.FieldElements=" + oTxt.FieldElements);
 
 
                        }
                        else if (item is IFieldObject)
                        {
                            IFieldObject oFld = (IFieldObject)item;
                            Console.WriteLine("oFld.Name = " + oFld.Name);
                            Console.WriteLine("oFld.Value = " + oFld.Value);
                            Console.WriteLine("oFld.AmPmType = " + oFld.AmPmType);
                            Console.WriteLine("oFld.AmString = " + oFld.AmString);
                            Console.WriteLine("oFld.BackColor = " + oFld.BackColor);
                            Console.WriteLine("oFld.BooleanOutputType = " + oFld.BooleanOutputType);
                            Console.WriteLine("oFld.BorderColor = " + oFld.BorderColor);
                            Console.WriteLine("oFld.BottomLineStyle = " + oFld.BottomLineStyle);
                            Console.WriteLine("oFld.CanGrow = " + oFld.CanGrow);
                            Console.WriteLine("oFld.CharacterSpacing = " + oFld.CharacterSpacing);
                            Console.WriteLine("oFld.CloseAtPageBreak = " + oFld.CloseAtPageBreak);
                            //Console.WriteLine("oFld.ConditionFormula = " + oFld.ConditionFormula(??));
                            Console.WriteLine("oFld.CssClass = " + oFld.CssClass);
                            Console.WriteLine("oFld.CurrencyPositionType = " + oFld.CurrencyPositionType);
                            Console.WriteLine("oFld.CurrencySymbol = " + oFld.CurrencySymbol);
                            Console.WriteLine("oFld.CurrencySymbolType = " + oFld.CurrencySymbolType);
                            Console.WriteLine("oFld.DateCalendarType = " + oFld.DateCalendarType);
                            Console.WriteLine("oFld.DateEraType = " + oFld.DateEraType);
                            Console.WriteLine("oFld.DateFirstSeparator = " + oFld.DateFirstSeparator);
                            Console.WriteLine("oFld.DateOrder="+oFld.DateOrder);
                            Console.WriteLine("oFld.DatePrefixSeparator="+oFld.DatePrefixSeparator);
                            Console.WriteLine("oFld.DateSecondSeparator="+oFld.DateSecondSeparator);
                            Console.WriteLine("oFld.DateSuffixSeparator="+oFld.DateSuffixSeparator);
                            Console.WriteLine("oFld.DateWindowsDefaultType="+oFld.DateWindowsDefaultType);
                            Console.WriteLine("oFld.DayType="+oFld.DayType);
                            Console.WriteLine("oFld.DecimalPlaces="+oFld.DecimalPlaces);
                            Console.WriteLine("oFld.DecimalSymbol="+oFld.DecimalSymbol);
                            Console.WriteLine("oFld.DisplayReverseSign="+oFld.DisplayReverseSign);
                            Console.WriteLine("oFld.EnableTightHorizontal="+oFld.EnableTightHorizontal);
                            Console.WriteLine("oFld.FirstLineIndent="+oFld.FirstLineIndent);
                            Console.WriteLine("oFld.Font="+oFld.Font);
                            Console.WriteLine("oFld.HasDropShadow="+oFld.HasDropShadow);
                            Console.WriteLine("oFld.Height="+oFld.Height);
                            Console.WriteLine("oFld.HorAlignment="+oFld.HorAlignment);
                            Console.WriteLine("oFld.HourMinuteSeparator="+oFld.HourMinuteSeparator);
                            Console.WriteLine("oFld.HourType="+oFld.HourType);
                            Console.WriteLine("oFld.HyperlinkText="+oFld.HyperlinkText);
                            Console.WriteLine("oFld.HyperlinkType="+oFld.HyperlinkType);
                            Console.WriteLine("oFld.KeepTogether="+oFld.KeepTogether);
                            Console.WriteLine("oFld.Kind="+oFld.Kind);
                            Console.WriteLine("oFld.LeadingDayPosition="+oFld.LeadingDayPosition);
                            Console.WriteLine("oFld.LeadingDaySeparator="+oFld.LeadingDaySeparator);
                            Console.WriteLine("oFld.LeadingDayType="+oFld.LeadingDayType);
                            Console.WriteLine("oFld.Left="+oFld.Left);
                            Console.WriteLine("oFld.LeftIndent="+oFld.LeftIndent);
                            Console.WriteLine("oFld.LeftLineStyle="+oFld.LeftLineStyle);
                            Console.WriteLine("oFld.LineSpacing="+oFld.LineSpacing);
                            Console.WriteLine("oFld.LineSpacingType="+oFld.LineSpacingType);
                            Console.WriteLine("oFld.MaxNumberOfLines="+oFld.MaxNumberOfLines);
                            Console.WriteLine("oFld.MinuteSecondSeparator="+oFld.MinuteSecondSeparator);
                            Console.WriteLine("oFld.MinuteType="+oFld.MinuteType);
                            Console.WriteLine("oFld.MonthType="+oFld.MonthType);
                            Console.WriteLine("oFld.Name="+oFld.Name);
                            Console.WriteLine("oFld.NegativeType="+oFld.NegativeType);
                            Console.WriteLine("oFld.NextValue="+oFld.NextValue);
                            Console.WriteLine("oFld.PmString="+oFld.PmString);
                            Console.WriteLine("oFld.PreviousValue="+oFld.PreviousValue);
                            Console.WriteLine("oFld.RightIndent="+oFld.RightIndent);
                            Console.WriteLine("oFld.RightLineStyle="+oFld.RightLineStyle);
                            Console.WriteLine("oFld.RoundingType="+oFld.RoundingType);
                            Console.WriteLine("oFld.SecondType="+oFld.SecondType);
                            Console.WriteLine("oFld.Suppress="+oFld.Suppress);
                            Console.WriteLine("oFld.SuppressIfDuplicated="+oFld.SuppressIfDuplicated);
                            Console.WriteLine("oFld.SuppressIfZero="+oFld.SuppressIfZero);
                            Console.WriteLine("oFld.TextColor="+oFld.TextColor);
                            Console.WriteLine("oFld.TextFormat="+oFld.TextFormat);
                            Console.WriteLine("oFld.TextRotationAngle="+oFld.TextRotationAngle);
                            Console.WriteLine("oFld.ThousandsSeparators="+oFld.ThousandsSeparators);
                            Console.WriteLine("oFld.ThousandSymbol="+oFld.ThousandSymbol);
                            Console.WriteLine("oFld.TimeBase="+oFld.TimeBase);
                            Console.WriteLine("oFld.Top="+oFld.Top);
                            Console.WriteLine("oFld.TopLineStyle="+oFld.TopLineStyle);
                            Console.WriteLine("oFld.UseLeadingZero="+oFld.UseLeadingZero);
                            Console.WriteLine("oFld.UseOneSymbolPerPage="+oFld.UseOneSymbolPerPage);
                            Console.WriteLine("oFld.UseSystemDefaults="+oFld.UseSystemDefaults);
                            Console.WriteLine("oFld.Value="+oFld.Value);
                            Console.WriteLine("oFld.Width="+oFld.Width);
                            Console.WriteLine("oFld.YearType="+oFld.YearType);
                            Console.WriteLine("oFld.ZeroValueString="+oFld.ZeroValueString);
                            Console.WriteLine("oFld.Field=" + oFld.Field);
 
 
                        }
                        else if (item is ILineObject)
                        {
                            ILineObject oLine = (ILineObject)item;
                            Console.WriteLine("oLine.Bottom = " + oLine.Bottom);
                            //Console.WriteLine("oLine.ConditionFormula = " + oLine.ConditionFormula);
                            Console.WriteLine("oLine.CssClass = " + oLine.CssClass);
                            //Console.WriteLine("oLine.EndSection = " + oLine.EndSection. ' structure...);
                            Console.WriteLine("oLine.ExtendToBottomOfSection = " + oLine.ExtendToBottomOfSection);
                            Console.WriteLine("oLine.Kind = " + oLine.Kind);
                            Console.WriteLine("oLine.Left = " + oLine.Left);
                            Console.WriteLine("oLine.LineColor = " + oLine.LineColor);
                            Console.WriteLine("oLine.LineStyle = " + oLine.LineStyle);
                            Console.WriteLine("oLine.LineThickness = " + oLine.LineThickness);
                            Console.WriteLine("oLine.Name = " + oLine.Name);
                            Console.WriteLine("oLine.Right = " + oLine.Right);
                            Console.WriteLine("oLine.Suppress = " + oLine.Suppress);
                            Console.WriteLine("oLine.Top = " + oLine.Top);
 
                        }
                        else if (item is ICROleObject)
                        {
                        }
                        else if (item is ISubreportObject)
                        {
                            ISubreportObject oSubReport = (ISubreportObject)item;
                            Console.WriteLine("oSubReport = " + oSubReport.Name);
                            IReport sr = oSubReport.OpenSubreport();
                            ProcessReport(sr);
                        }
                        else
                        {
                            Console.WriteLine("Unimplemented type: " + item);
                        }
 
                    }
 
                }
 
 
            }
        }
    }
}

Open in new window

Comment
Watch Question

Author

Commented:
I've increased the value of the question.
Test Developer/Validator
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
I programmed a DLL in VB.NET with this solution.  So I did not have full C# solution but the solution works.  The C# code calls the VB.NET DLL to print out the type.
Jens FiedererTest Developer/Validator

Commented:
Cool, multi-language development in action!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.