473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Code Generation for property 'xxx' failed

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

Jun 7 '06 #1
2 3775
"slawrence" <st****@metagenerics.co.za> a écrit dans le message de news:
Oj**************@TK2MSFTNGP05.phx.gbl...

| 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

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jun 7 '06 #2
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

"Joanna Carter [TeamB]" <jo****@not.for.spam> wrote in message
news:uf*************@TK2MSFTNGP02.phx.gbl...
"slawrence" <st****@metagenerics.co.za> a écrit dans le message de news:
Oj**************@TK2MSFTNGP05.phx.gbl...

| 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

--
Joanna Carter [TeamB]
Consultant Software Engineer

Jun 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
8
by: Max M | last post by:
Yesterday there was an article on Slashdot: http://books.slashdot.org/article.pl?sid=03/09/04/1415210&mode=flat&tid=108&tid=126&tid=156 It is about automatic code generation. I got interrested...
0
by: Rasmus Fogh | last post by:
Someone raised the question of automatic code generation a few weeks back. And yes, we (CCPN) are using automatic Python code generation in a major way. Basically we are making data models in...
3
by: tsteinke | last post by:
I am trying to make a Component that is aware of the Form that it is added to. I noticed that when you drop a MainMenu onto a form the designer generates the code. this.Menu = this.mainMenu1; ...
0
by: Pablo | last post by:
Hi, I am create my own control and I have the next error: Error Creating Control: 'xxx1' could no be set on property 'XXX' Class Code (Header):
0
by: slawrence | last post by:
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...
0
by: steve.kaye | last post by:
I'm writing a control which contains a collection of Column objects which needs to be written to InitializeComponent() by the designer. I've created a collection object (ColumnCollection) derived...
1
by: Don | last post by:
I'm getting the following exception displayed in the task list at design time for my project: "Code generation for property 'Controls' failed. Error was: 'Object reference not set to an...
0
zybernau
by: zybernau | last post by:
We have migrated the project source code from 1.1 frame work to 2.0 frame work now i am working in vs 2005 , while in designing mode ahen doing some changes to the control there's one message...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.