Code Generation for property 'xxx' failed

S

slawrence

Hi

I am getting an error "Code generation for property 'SubCategoryId' failed.
Error was 'Property accessor 'SubCategoryId' on object 'yyy.zzz' threw the
following exception: 'Object reference not set to an instance of an
object.'' after porting my code from V1.1 to V2.0.

The class yyy is a class that has nothing in it except a contructor and is
derived from a MyGeneration generated class of a View in my SQL database.

The error pops up when I display a UserControl that has another Control that
is derived from TreeView and contains this zzz class. SubCategoryId is a
property of the View but the accessor looks like this

namespace yyy
{
class zzz
{
...
public virtual string SubCategoryId
{
get { return base.Getstring(ColumnNames.SubCategoryId); }
set { base.Setstring(ColumnNames.SubCategory, value); }
}
}
}

base.GetInt is defined as:

protected int Getint(string columnName)
{
return (int)_dataRow[columnName];
}

Clearly at design time _dataRow will be null but why would this property be
called and what code is VS2005 trying to generate that would use this
property?

Any ideas?

Thanks
Steven
 
J

Joanna Carter [TeamB]

"slawrence" <[email protected]> a écrit dans le message de (e-mail address removed)...

| class zzz
| {
| ...
| public virtual string SubCategoryId
| {
| get { return base.Getstring(ColumnNames.SubCategoryId); }
| set { base.Setstring(ColumnNames.SubCategory, value); }
| }
| }
| }
|
| base.GetInt is defined as:
|
| protected int Getint(string columnName)
| {
| return (int)_dataRow[columnName];
| }

You are not showing zzz as inheriting from anything, could this be a typo or
the casue of the problem ?

Also, if your base methods are not overridden in this class, then you do not
need the base keyword as the fact that they are protected (at least) should
allow zzz to see them.

Joanna
 
S

slawrence

Yes it is a typo.. it should read

class zzz : SqlClientEntity
{
<as below>
}

the rest of the code is generated automatically from MyGeneration code
generator.This code works fine in VS2003 and works in 2005 but causes the
error in the designer.

Steven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top