At my wits end - UNABLE TO LOAD CONTROL

Topics: Controls
Dec 8, 2008 at 12:05 AM
Ok I downloaded blog engine 1.4.5 source so I could use it as my development base. Then I created a new usercontrol that would allow me to embed Vimeo videos by specifying the fallowing ...

[usercontrol: /User controls/CBXVimeo.ascx ClipID=1423640]

Everything works just fine with the blog engine 1.4.5 source but as soon as I copy the user control to my actual site (that is also running blog engine 1.4.5)  I keep getting "ERROR - UNABLE TO LOAD CONTROL : /user controls/CBXVimeo.ascx ClipID=1423640"
Also my actual site is also on my local machine at localhost:8080 and I am trying to get it working before I copy my localhost site to my godaddy hosting account.

I tried clearing the browser cache in firefox, ie, and chrome and that did not help. I also tried using CacheManager availible at  http://www.aspalliance.com/CacheManager/default.aspx That too did not help.

This is not the first time I have encountered this error and have been able to track down previous errors but I can't get this working.  Is there any other reason that could cause a "ERROR - UNABLE TO LOAD CONTROL" error that I may be over looking. I have multiple usercontrols and extentions that I have made and all of them are running and working fine but this one simple Vimeo usercontrol just refuses to work! And I am out of ideas. I can't figure out why all my other usercontrols and extentions that are similarly written are working perfectly but this one user control is giving me such a hard time. 

I am using the fallowing command line in a batch file to run and test my localhost site  ...

"C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.EXE" /port:8080 /path:"C:\Documents and Settings\Dean\My Documents\Visual Studio 2005\WebSites\CreatedbyX - BlogEngine.NET"

I am using visual studio 2008 to run the Blogengine 1.4.5 source site. I have tried restarting my computer, stopping and starting the asp.net development server, but nothing seems to work.

So if anyone can suggest any ideas that I may not have tried yet or if you can get the usercontrol working on your site let me know because as I said I am out of ideas for what I need to do to resolve this issue.





... The ascx markup is as fallows ...

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CBXVimeo.ascx.cs" Inherits="CBXVimeo" %>
<asp:Literal ID="litMedia" runat="server"></asp:Literal>

... the code is as fallows ...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class CBXVimeo : System.Web.UI.UserControl
{
    private int clipid;
    private int videoWidth = 640;
    private int videoHeight = 360;

    public int ClipID
    {
        get { return clipid; }
        set { clipid = value; }
    }

    public int Width
    {
        get { return videoWidth; }
        set { videoWidth = value; }
    }

    public int Height
    {
        get { return videoHeight; }
        set { videoHeight = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        this.litMedia.Text = this.GetHTML(this.clipid, this.videoWidth, this.videoHeight);
    }

    public string GetHTML(int id, int pWidth, int pHeight)
    {
        string data = "<object width=\"{WIDTH}\" height=\"{HEIGHT}\">" +
                      "<param name=\"allowfullscreen\" value=\"true\" />" +
                      "<param name=\"allowscriptaccess\" value=\"always\" />" +
                      "<param name=\"movie\" value=\"http://vimeo.com/moogaloop.swf?clip_id={CLIPID}&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=01AAEA&amp;fullscreen=1\" />" +
                      "<embed src=\"http://vimeo.com/moogaloop.swf?clip_id={CLIPID}&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=01AAEA&amp;fullscreen=1\"" +
                      "   type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\"" +
                      " width=\"{WIDTH}\" height=\"{HEIGHT}\"></embed></object><br />";

        data = data.Replace("{CLIPID}", id.ToString());
        data = data.Replace("{WIDTH}", pWidth.ToString());
        data = data.Replace("{HEIGHT}", pHeight.ToString());

        return data;
    }
}



Dec 8, 2008 at 11:38 AM
Edited Dec 9, 2008 at 7:49 PM
I changed
[usercontrol: /User controls/CBXVimeo.ascx ClipID=1423640]
 to 
[usercontrol: ~/User controls/CBXVimeo.ascx ClipID=1423640]
and it loads up just fine.


 

Dec 8, 2008 at 12:36 PM
Yes I forgot to mention that in my initial post (adding the ~ char to the beginning of ~/user controls/....) I also tried that and it did not work for me.
Dec 8, 2008 at 12:49 PM
Edited Dec 8, 2008 at 12:55 PM
My blog is on Windows 2008 .NET 3.5 integrated pipeline mode and in the root of the site. My test blog is on Windows Vista/VS 2008 .NET 3.5 in the Local IIS. It worked in both. What is your setup? I have a W2K3 server I can try it on also.

Edit: Forgot to mention; I am running 1.4.5.12
Dec 9, 2008 at 10:27 PM
I have done everything I can think of and it is not working. So I gave in and decided to forgo the usercontrol for now. I have a vimeo extension that I used to inject the vimeo usercontrol via  [usercontrol ...  But I have modified it to now perform the same functionality that the usercontrol was indended for. The code for the extention is provided below for anyone to use.

It is not what I wanted, but it will have to do for now. Idealy I would have liked to have the extention inject the usercontrol so that I can choose weather or not to use the extention or the usercontrol as well as having a usercontrol that could be used in other asp.net apps but it's like I said I give up.

You may have won this battle you infernal machine, but you shal not win the war! hahaha :P

Thanks for your help.

The code for the vimeo extention is as fallows ...

#region Using

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Net;
using BlogEngine.Core;
using BlogEngine.Core.Web.Controls;

#endregion

[Extension("Embeds a vimeo video.", "1.0", "Createdbyx.com")]
public class CBXVimeoExt
{
    public CBXVimeoExt()
    {
        Post.Serving += new EventHandler<ServingEventArgs>(Serving);
        Page.Serving += new EventHandler<ServingEventArgs>(Serving);
    }

    private void Serving(object sender, ServingEventArgs e)
    {
        while (e.Body.Contains("[VIMEO:"))
        {
            int startPos = e.Body.IndexOf("[VIMEO:");
            int endPos = e.Body.IndexOf("]", startPos + 7);
            if (startPos != -1 && endPos != -1 && endPos >= startPos)
            {
                string clipid = e.Body.Substring(startPos + 7, endPos - (startPos + 7));
                int idValue;
                string uc = string.Empty;

                if (!int.TryParse(clipid, out idValue))
                {
                    uc = "ERROR: Could not parse Vimeo ClipID";
                }
                else
                {
                    uc = GetHTML(idValue, 640, 340);
                    // string uc = "[usercontrol: /user controls/CBXVimeo.ascx " + (clipid == string.Empty ? string.Empty : "ClipID=" + clipid) + "]";
                    e.Body = e.Body.Remove(startPos, (endPos + 1) - startPos);
                    e.Body = e.Body.Insert(startPos, uc);
                }
            }
        }
    }

    public string GetHTML(int id, int pWidth, int pHeight)
    {
        string data = "<object width=\"{WIDTH}\" height=\"{HEIGHT}\">" +
                      "<param name=\"allowfullscreen\" value=\"true\" />" +
                      "<param name=\"allowscriptaccess\" value=\"always\" />" +
                      "<param name=\"movie\" value=\"http://vimeo.com/moogaloop.swf?clip_id={CLIPID}&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=01AAEA&amp;fullscreen=1\" />" +
                      "<embed src=\"http://vimeo.com/moogaloop.swf?clip_id={CLIPID}&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=01AAEA&amp;fullscreen=1\"" +
                      "   type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\"" +
                      " width=\"{WIDTH}\" height=\"{HEIGHT}\"></embed></object><br />";

        data = data.Replace("{CLIPID}", id.ToString());
        data = data.Replace("{WIDTH}", pWidth.ToString());
        data = data.Replace("{HEIGHT}", pHeight.ToString());

        return data;
    }

}

Mar 30, 2009 at 4:29 AM
Edited Mar 30, 2009 at 10:51 PM
This is an edit of the original message, ignore it. Initially I posted something that I thought would be an explanation but I dug through the code and tested only to find out my post was wrong.