Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1752
  • Last Modified:

How to handle exception "Error rendering control" at designMode in Visual Studio?

I have created a custom control which is doing exactly as it should, but for some reason is showing an exception in designmode.

Error rendering control - MyControl
An unhandled exception has occured.
TagPrefix:MyControl could not be set on property 'MyProperty'.

This grey block only appears in DesignMode when using the custom control. All works fine at run time.

The grey block appears when modifying a property of type "List Of" in the property window. But again it does not cripple anything at run time.

I would like to 'handle' this exception, but where is it being generated. I assumed it would be on the render sub of the control, but my attempts have failed. Any insight would be appreciated.
  • 3
1 Solution
Do you do any overloading of constructors or anything like that?  It is tough without seeing the code as to why it might be complaining.  usually it is due to variables that need to be initialized or something like that.
OnthraxAuthor Commented:
Yes as the control is inheriting a basevalidator I need to override/overload various subs.

Posting code is a little tricky as it is weaved into a greater whole. I could try to create a new control and only put in the classes and such that cause the exception.

This will take some time, so I will only do this if you really want to put some time into checking out the code.. Please let me know..

Cheers :)
OnthraxAuthor Commented:
I really need this resolved so I went ahead and ripped everything I could. This is the most basic as I can get it.

I have uploaded the control here:

If you create a new webpage and drag the control onto the page, you will see the [Custom validator] tag.
You can change all properties without any problems except for the properties 'Failure' and 'Success'. If you click on the elypses and press the ADD button, the gray box will appear in visual studio. If you add a few and run the page, source will look like this:

    <cc1:ServerControl1 ID="ServerControl11" runat="server">
            <cc1:Effect Input1="asd" Input2="sdf" Input3="fds" />
            <cc1:Effect Input1="fds" Input2="sdf" Input3="sdf" />
            <cc1:Effect Input1="ss" Input2="dd" Input3="ff" />

And the code will execute fine. The issue only presents itself in visual studio..

Hope you can find the problem. Thanks in advance! :)
OnthraxAuthor Commented:
I have finally figured it out. Cost me over 8 hours, but at least I got it fixed.

Error was caused by the property of type 'List Of' not being readonly.

In case you had already taken a look, thanks for trying. If not, thanks for your attempt.

Cheers :)

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now