Error in C# file

  • Thread starter Thread starter Reshma Prabhu
  • Start date Start date
R

Reshma Prabhu

hello,
I am getting errors in the line

BindableAttribute myAttribute =
(BindableAttribute)attributes[typeof("Assembly text name, Version, Culture,
PublicKeyToken")];

The errors are

Type expected
Invalid expression term ']'
Invalid expression term ')'
; expected
; expected

The actual code is

using System;
using System.ComponentModel;
using System.Windows.Forms;

public class Form1: Form
{
protected TextBox textBox1;
protected void Method()
{
// Gets the attributes for the property.
AttributeCollection attributes =
TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
// Checks to see if the property is bindable.
// You must supply a valid fully qualified assembly name here.
BindableAttribute myAttribute =
(BindableAttribute)attributes[typeof("Assembly text name, Version, Culture,
PublicKeyToken")];
if(myAttribute.Bindable) {
// Insert code here.
}
}
}

Can any one help me out?

Thanks,
 
Reshma Prabhu said:
I am getting errors in the line

BindableAttribute myAttribute =
(BindableAttribute)attributes[typeof("Assembly text name, Version, Culture,
PublicKeyToken")];

Yes, I'm not surprised.

typeof(X) assumes that X itself is a type name, not a string containing
type information.

I *suspect* that Type.GetType is what you're after.
 
Back
Top