-5
           MyProject.MyForms.m_FormBeingCreated.Add(typeof(T), null);
                try
                {
                    try
                    {
                        result = Activator.CreateInstance<T>();
                        return result;
                    }
                    object arg_96_0;
                    TargetInvocationException expr_9B = arg_96_0 as TargetInvocationException;
                    int arg_B8_0;
                    if (expr_9B == null)
                    {
                        arg_B8_0 = 0;
                    }
                    else
                    {
                        TargetInvocationException ex = expr_9B;
                        ProjectData.SetProjectError(expr_9B);
                        arg_B8_0 = (((ex.InnerException != null) > false) ? 1 : 0);
                    } 
                        endfilter(arg_B8_0);
                }
                finally
                {
                    MyProject.MyForms.m_FormBeingCreated.Remove(typeof(T));
                }
            }
            result = Instance;
            return result;
        }

/// What have i done wrong?

Keep getting errors about: Expected catch or finally @object arg_96_0;

Operator '>' cannot be applied to operands of type 'bool' and 'bool' @ex.InnerException !=null)

The name 'endfilter' does not exist in the current context. @endfilter(arg_B8_0);

Jeroen Vannevel
  • 43,651
  • 22
  • 107
  • 170
user3059135
  • 1
  • 1
  • 1
  • 1
    Did you read the docs on Try/Catch? – MikeSmithDev Dec 02 '13 at 22:19
  • 6
    how can a bool be bigger than a bool? – Jeroen Vannevel Dec 02 '13 at 22:19
  • 1
    Those error texts are really clear! What is your question? One `try` has no `catch` or `finally`. One greater-than sign tries to compare two Boolean expressions. And one identfier `endfilter` does not exist in the context; could be a casing issue (is it `endFilter` or `EndFilter`?). – Jeppe Stig Nielsen Dec 02 '13 at 22:19
  • 2
    @JeroenVannevel - well, `Bool` has one bigger letter than `bool`. That has to be it! – admdrew Dec 02 '13 at 22:20
  • This is a bit crazy, I inherited some code that has the same code from above. The above is not hand written code. I looks like it was created by some kind of generator. Mine has the same code, but arg and expr number are different. The class is decorated with: [StandardModule, HideModuleName, GeneratedCode("MyTemplate", "8.0.0.0")] This syntax must have compiled at one point... or maybe it got mutated by some kind of generator before compilation? – Tolga Sep 30 '20 at 20:30

1 Answers1

3

Your first problem is with this line of code

arg_B8_0 = (((ex.InnerException != null) > false) ? 1 : 0);

In C# a boolean cannot be greater than or less than, so try changing that to

arg_B8_0 = (((ex.InnerException != null) != false) ? 1 : 0);

Also, as pointed out by Jeroen and others in comments, this piece of code is not very clean and is doing some evaluations it doesn't need to do.

arg_BB_0 = ex.InnerException != null ? 1 : 0;

This is a much better way to write the expression and achieve the same goal.

Your next issue is that all try statements must be accompanied by a catch or finally statement. Try reading this article on MSDN about proper use of try-catch blocks.

As far as getting an error that says endfilter doesn't exist in the current context, this means that you need to check the scope of where endfilter is declared. endfilter is probably not declared where it accessible in the current scope. MSDN can again be helpful here, This is a good place to get started understanding scope.

Leon Newswanger
  • 617
  • 1
  • 5
  • 17