C++/CLI control null exceptions

D

dragonslayer008

Hello group,

I'm making a custom control in C++/CLI. The control builds fine. To
test the control, I made a C# Forms application. On the Toolbox, I
right clicked and chose "Choose Items". I then browsed for my control
DLL and added it. The custom control now shows up in the toolbox. I
then drag this control onto the form.

I then get exceptions about null objects. I don't get this. How can
I get exceptions when the program isn't even running? Some of the
objects will be null until I "new" them...
 
S

Sheng Jiang[MVP]

Your control failed to load in Visual Studio
Set Visual Studio as your debug target to debug this problem.
 
C

Carl Daniel [VC++ MVP]

Hello group,

I'm making a custom control in C++/CLI. The control builds fine. To
test the control, I made a C# Forms application. On the Toolbox, I
right clicked and chose "Choose Items". I then browsed for my control
DLL and added it. The custom control now shows up in the toolbox. I
then drag this control onto the form.

I then get exceptions about null objects. I don't get this. How can
I get exceptions when the program isn't even running? Some of the
objects will be null until I "new" them...

The program IS running... but the program, in this case, is Visual Studio
itself.

The forms designer instantiates your control with the default constructor
and then interrogates all of the properties using reflection.. You need to
make sure that all properties of your control are readable on a
default-constructed instance of your class or you won't be able to use it in
the designer.

-cd
 

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