Link to home
Start Free TrialLog in
Avatar of DreamMaster
DreamMaster

asked on

Cannot convert control (works fine on localhost though)

Hi Experts,

I'm having a problem with difference between my online environment and my localhost.

I have compiled my application and uploaded it when it worked on my localhost..Everything works, except for one thing and I cannot figure out why it doesn't work. In my eventlog it tells me the following:

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 4/4/2007 8:31:56 AM
Event time (UTC): 4/4/2007 6:31:56 AM
Event ID: 86822a16ffc04af7ae3afd8ea39b789d
Event sequence: 31
Event occurrence: 2
Event detail code: 0
 
Application information:
    Application domain: /LM/W3SVC/1994679262/Root-30-128201417561093750
    Trust level: Medium
    Application Virtual Path: /
    Application Path: D:\www\globalstate.nl\www\
    Machine name: SERVER2
 
Process information:
    Process ID: 2428
    Process name: w3wp.exe
    Account name: NT AUTHORITY\NETWORK SERVICE
 
Exception information:
    Exception type: InvalidCastException
    Exception message: Unable to cast object of type 'ASP.controls_formulieren_controlshowformulier_ascx' to type 'ControlShowFormulier'.
 
Request information:
    Request URL: http://www.globalstate.nl/arachna.aspx?id=386&lng=1 
    Request path: /arachna.aspx
    User host address: 192.168.1.64
    User:  
    Is authenticated: False
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE
 
Thread information:
    Thread ID: 5
    Thread account name: NT AUTHORITY\NETWORK SERVICE
    Is impersonating: False
    Stack trace:    at ControlArticle.Page_Load(Object obj, EventArgs e)
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Where "Unable to cast object of type 'ASP.controls_formulieren_controlshowformulier_ascx' to type 'ControlShowFormulier'. " is obviously the thing to look for.

In my ControlArticle.ascx.vb, I check in the Page_Load function, which control needs to be added to my page depending on a templateID.

Dim control As ControlShowFormulier = LoadControl("~/controls/formulieren/ControlShowFormulier.ascx")
placeHolderModule.Controls.Add(control)

That's all I do and it works for every other control, but this one is feeling obnoxious for some reason. Anyone got any idea why this could happen and better yet...how I could fix it?

Thanks in advance,
Regards,
Max.
ASKER CERTIFIED SOLUTION
Avatar of jinn_hnnl
jinn_hnnl
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DreamMaster
DreamMaster

ASKER

Hi jinn...

Well...I have it solved in a way that doesn't make a hint of sense to me at all. I've changed from a compiled version to just using the source as I have it on my local machine. That works flawlessly.

I have the <%@ Register... tag at the ascx file (remember it was in a control)

I've seen similar things before, and it proved to be a matter of changing a small thing, allowing the site to be recompiled and suddenly it would work, this however would be with a main control. Sometimes even commenting out a line would work..then calling it (it won't work as suspected) but it works...uncommenting that line...eh voila it works again as normal.

I still have no idea why these bugs are happening, but I'm pretty sure they have nothing to do with the actual coding.

Thanks!
Regards,
Max.
I think I should ask to get this question PAQ'ed...unless you disagree jinn.. :)

Regards,
Max.
GJ, Max,

I am pretty sure you are not the only one experiences this kind of problem. In any way that matter, if problem's caused by actual coding or not. It's nice to have some solutions to try (and ppl may add another explaination to it)

Aww, you can ask to get this question PAQ of course ^^.

Greeting,

JINNY ^^
I can wait for a while as well. :) Like you said it's nice to see different reasons why this would happen.

Just hope I won't forget about the question though.. ;)

Regards,
Max.
I have found that these kind of compilation issues are not so much problems with coding, however more a problem in Visual Studio / ASP.NET. Check out Scott Gu's blog about it..he recently made a post about this and other compilation problems.

http://weblogs.asp.net/scottgu/archive/2007/04/11/public-hotfix-patch-available-for-asp-net-compilation-issues.aspx

Jinn, thanks for your help, this question might be usefull for others as well, so I have PAQ'ed it now. :)

Regards,
Max.
Ohh,

I have read the blog, it is really helpful. Since I don't have this kind of problem, but I found something interesting to play with. (I might even experience it later).

Sometime I got that (after complied successfully several time), what I did was closing all the opening file (even solution file). Then reopen it and complie again. It's sounds weird but helps.

Thank for the credit, too Master Max. ^^ (I think my solution wasn't really helpful,)

JINN ^^