Re: CompositeControl fails to display in Design view



apologies, should have read your description in more detail

Philvb wrote:
Hi MC,
Yes, if you follow the instructions then that is how you can debug the designer.
Phil

"MC" wrote:

I have no problem with the Custom Control, It works fine in the browser, It is the design time experience that is not working.

Can you debug the designer in Visual Studio?

Philvb wrote:
Hi MC,
the message you are getting here is from your logic in the rendering of the control at a guess i'd say that an object hasn't been instanciated.
But here's how i debug ALL my custom controls in real time.

In Order to debug a Custom Control you need to Start ANOTHER copy of Visual Studio along side your existing one,and pointing it to a test website.
This can be done by

Going To The Controls Project Properties and Selecting The Debug Tab then set the start action to `Start External Program` and set the box next to it to the location of devenv.exe from the correct folder of program files.

i am using orcas beta2 here and this path is: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe


Now set the Command Line Arguments to: /Command File.OpenWebsite TheTestingWebSite.sln

Now The Final Step Is To Enter The FULL Path of Your SOLUTION FILE in the Working Directory text box.

Just press F5 to start your debugging Adventure...

hope this helps
Wbr
Phil

"MC" wrote:

I'm getting the following error messages when I view my ComposisteControl in design time mode.

"Error Rendering Control - <My Control Name>"
"An unhandled exception has occurred
Object reference not set to an instance of an object"

The Control is as follows: -

public class TrackedAd : CompositeControl
{
public SqlDataSource sdsAds = new SqlDataSource();
public System.Web.UI.WebControls.AdRotator adRot = new System.Web.UI.WebControls.AdRotator();

private string _Target = "_blank";
private int _SponsorId = -1;

[Description("The Browser Target for the Attribute"), TypeConverterAttribute(typeof(TargetConverter))]
public string Target
{
get { return _Target; }
set { _Target = value; }
}

public int SponsorId
{
get { return _SponsorId; }
set { _SponsorId = value; }
}

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Page.RegisterRequiresControlState(this);
}

protected override object SaveControlState()
{
object[] state = { base.SaveControlState(), _Target, _SponsorId };
return state;

}

protected override void LoadControlState(object state)
{
if (state != null)
{
object[] stateTmp = (object[])state;
base.LoadControlState(stateTmp[0]);
_Target = (string)stateTmp[1];
_SponsorId = (int)stateTmp[2];
}
}

protected override void CreateChildControls()
{
sdsAds.ConnectionString = ConfigurationManager.ConnectionStrings["RedsSponsors"].ConnectionString;
sdsAds.ProviderName = ConfigurationManager.ConnectionStrings["RedsSponsors"].ProviderName;
sdsAds.SelectCommand = string.Format("SELECT '{0}'+iif(ImageName<>null,ImageName,'../transp.gif') AS ImageUrl, CompanyName AS AlternateText, URL AS NavigateUrl, Impressions, Clicks FROM Sponsors WHERE Id={1}", Utils.SponsorsImageBase, SponsorId);
sdsAds.ID = "sdsAds";

adRot.AdCreated += new AdCreatedEventHandler(this_AdCreated);
adRot.DataSourceID = "sdsAds";
adRot.Target = Target;

Controls.Add(sdsAds);
Controls.Add(adRot);
}

protected void this_AdCreated(object sender, AdCreatedEventArgs e)
{
SponsorsUtils.IncrementAdvertStat("CompanyName", "Impressions", e.AlternateText);
if (e.NavigateUrl != "")
{
e.NavigateUrl = string.Format("~/Adverts/AdvertHandler.ashx?Url={0}", Page.Server.UrlEncode(e.NavigateUrl));
}
}
}

What is wrong? I thought by using compositecontrol I would not have to worry about designtime?

.



Relevant Pages

  • Re: CompositeControl fails to display in Design view
    ... Can you debug the designer in Visual Studio? ... In Order to debug a Custom Control you need to Start ANOTHER copy of Visual ... protected override void LoadControlState ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: CompositeControl fails to display in Design view
    ... if you follow the instructions then that is how you can debug the designer. ... the message you are getting here is from your logic in the rendering of the control at a guess i'd say that an object hasn't been instanciated. ... [Description("The Browser Target for the Attribute"), ... protected override void LoadControlState ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: PB 5.0: Image only boots 99%
    ... When booting the debug version with the AMD Geode x86 image ... When booting the debug version (on target) with the x86 image exactly the ... The Windows CE logo is shown with the ... The progress bar is only 2% filled up and then ...
    (microsoft.public.windowsce.platbuilder)
  • Re: CompositeControl fails to display in Design view
    ... protected override void CreateChildControls() ... I then view the page with the broken control on it and nothing happens? ... if you follow the instructions then that is how you can debug the designer. ... It is the design time experience that is not working. ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: Need Help in Debugging StandAlone WInCE 6.0 App using PB/VS 20
    ... Virtual Miniport Driver, VMINI, in the OS. ... Builder to also appear as a network adapter to the Windows CE OS. ... I've spent the past 3 days trying to get VS 2005 to allow me to debug ... I have solid connectivity with my target via KITL debugging, ...
    (microsoft.public.windowsce.app.development)

Quantcast