silverlight with MVC error in VS2008
Last post 04-28-2008 1:19 PM by sebaigle. 16 replies.
Sort Posts:
04-25-2008 5:13 PM
silverlight with MVC error in VS2008

 Hi I am getting an error and I can't solve it.
Here is the deal:

1: I add an MVC project to my solution.
2: Then I add a silverlight application to the prject and ask me:
    Do you want to attach the silverlight to an existing web application and I select my web application there.
    This cause me than when I build my project a XAP file i created in a Client BIN Folder.
    Here comes the first problem:
    I can`t find the relation of my web application to de silverlight application in order to stop xap file to being recreated and created when I want hiting add     silverlight link in contextual menu of the project.
    Ok I dont have really problem with this but I hate I can't controll it.
3. Well the problem here.
    I run the application and works great with my MVC. But when I try to add my silverlight gives me and error.
    I drag and drop the xap file to my aspx design. and run and get this error:
   

Server Error in '/' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The server tag 'asp:Silverlight' is ambiguous. Please modify the associated registration that is causing ambiguity and pick a new tag prefix.

Source Error:

Line 3:  <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
Line 4:
Line 5: <%@ Register assembly="System.Web.Silverlight" namespace="System.Web.UI.SilverlightControls" tagprefix="asp" %>
Line 6:
Line 7: <asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">


Source File: /Views/Home/About.aspx    Line: 5


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

 

 

I dont know If I am added wrongly or what please help me I can`t do this.

 

Thank you very much

 

oohhh then when I get out the added silverlight component start giving me this error:
which I also dont understand:

[NullReferenceException: Object reference not set to an instance of an object.]
ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Documents and Settings\Administrador\Escritorio\Proyecto final\Src\BuscadorElPais\BuscadorElPais\Views\Shared\Site.Master:24
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +26
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2558


sebaigle

Joined on 04-25-2008
Posts 9
04-26-2008 2:17 AM
Re: silverlight with MVC error in VS2008

I am not sure how MVC works but my guess is that the Silverlight control requires ASP.NET AJAX 3.5, and I don't think MVC and AJAX will coexist.  But that's just a hunch.  I know MVC doesn't use the Page model which AJAX is somewhat dependent on.

(If this has answered your question, please "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 2 Workshop
May 12-14, 2008 - Atlanta, GA
May 28-30, 2008 - San Francisco, CA
http://www.silverlight-tour.com

swildermuth

Joined on 10-13-2003
Atlanta, GA
Posts 1,058
04-26-2008 10:32 AM
Re: Re: silverlight with MVC error in VS2008

 thank you very much for your answer.
But can anyone the procedure in Visual Studio 2008 which is the most automatic to insert and xaml from an silverlight application into an *.aspx


With MVC should be the same but what I am doing I seems not to be the right thing

sebaigle

Joined on 04-25-2008
Posts 9
04-26-2008 1:14 PM
Re: Re: Re: silverlight with MVC error in VS2008

You might consider using Silverlight.js or object tags instead of the silverlight control.

(If this has answered your question, please "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 2 Workshop
May 12-14, 2008 - Atlanta, GA
May 28-30, 2008 - San Francisco, CA
http://www.silverlight-tour.com

swildermuth

Joined on 10-13-2003
Atlanta, GA
Posts 1,058
04-26-2008 1:47 PM
Re: Re: Re: Re: silverlight with MVC error in VS2008

Thanks again for your answer.
CAn you help me or explain how to do that you said I am new to silverlight and It seems I am having problems adding on silverlight project to an aspx.

 

Thanks again 

sebaigle

Joined on 04-25-2008
Posts 9
04-27-2008 1:53 AM
Re: Re: Re: Re: Re: silverlight with MVC error in VS2008

I show how to use the Silvelright.js in this Silvelright 1.0 video but it applies to Silverlight 2 as well:

http://silverlight.net/learn/learnvideo.aspx?video=209

(If this has answered your question, please "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 2 Workshop
May 12-14, 2008 - Atlanta, GA
May 28-30, 2008 - San Francisco, CA
http://www.silverlight-tour.com

swildermuth

Joined on 10-13-2003
Atlanta, GA
Posts 1,058
04-27-2008 8:29 PM
Re: Re: Re: Re: Re: silverlight with MVC error in VS2008

 Thanks again for your answer again but I still having the error.
May be I can give you my code if anyone want, I have no problem may be it is easier this way.

Anyway I should re make my question:

I have 3.5 web page default.aspx
Then I have a silverlight project that has a Page.xaml file, when I add this project Visual Studio 2008 I been asked several options and I select Link this Silverlight control into an existing website and I unchecked the generate testpage and make a start up page.

What I want to do is that this Page.xaml is shown in my Default.aspx and I can't. I dont know how to do it.
And xap file is regenerated every time I rebuilt my project.
What I have to do to do this simple thing.
Sorry for not understanding previous help but I am new to silverlight and I dont really understan how to accomplish this.

 
How is the most modern or best way on doing this.

Thanks
 

sebaigle

Joined on 04-25-2008
Posts 9
04-27-2008 9:15 PM
Re: silverlight with MVC error in VS2008

sebaigle:
Parser Error Message: The server tag 'asp:Silverlight' is ambiguous. Please modify the associated registration that is causing ambiguity and pick a new tag prefix.
 

Hello,

I think i know this error. In Silverlight, System.Web.Extensions (Version=3.5.0.0)  is referenced by default. but In ASP.NET extension project or other project, we may use System.Web.Extensions (Version=3.6.0.0). So, when we add asp:Silverlight control to ASP.NET project, we got this error. Because The server tag 'asp:Silverlight' is ambiguous.

What thing you should do is that ~

1)  Check the "Register" tag in your aspx page.

 <%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>

We should have the code above in aspx page that you use asp:Silverlight control. If you have duplicated code or other different code, just remove those codes and replace the code that I gave you above.

then, check whether it solve your problem or not.

2) Check the assemblies in web.config

<compilation debug="true">
            <assemblies>
                <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            </assemblies>
        </compilation>

Please check the assemblies in web.config of ASP.NET project. If you got System.Web.Extension (version 3.6.0.0) in this list, please remove it.

3) Check the control in web.config

<pages>
            <controls>
                <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </controls>
        </pages>

If you have version 3.6.0.0 in web.config, please remove them..

Please let me know the result..  

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Joined on 09-16-2005
Singapore
Posts 2,021
04-27-2008 10:30 PM
Re: Re: silverlight with MVC error in VS2008

 Thanks you very much for your help. It seems we are on the way but I get a different error now:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0433: The type 'System.Web.UI.SilverlightControls.Silverlight' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.6.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\7ed8edff\783ba126\assembly\dl3\e2ecee35\00ce32b0_6079c801\System.Web.Silverlight.DLL'

Source Error:


Line 12: <p>
Line 13: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
Line 14: <asp:Silverlight ID="Silverlight1" runat="server" Height="480px"
Line 15: Source="~/ClientBin/Buscar.xap" Version="2.0" Width="640px" />
Line 16: </p>

Source File: c:\Documents and Settings\Administrador\Escritorio\Proyecto final\Src\BuscadorElPais\BuscadorElPais\Views\Home\About.aspx    Line: 14

 
I insert silverlight into aspx this way:
Drag and drop xap file into aspx designer.
Is that ok ?¿?¿?.
Doing what you said I get this error.
I would appreciate if you can help me again.

 

sebaigle

Joined on 04-25-2008
Posts 9
04-28-2008 2:25 AM
Re: Re: silverlight with MVC error in VS2008

Hi:

  Does it work if you select "Add a new Web to the solution for hosting the control" and run the test page? If it works please try to replace your current web.config with the auto-generated one.

Regards

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Allen Chen – MSFT

Joined on 03-16-2007
Posts 717
04-28-2008 2:47 AM
Re: Re: silverlight with MVC error in VS2008

Hi,

 

sebaigle:
Compiler Error Message: CS0433: The type 'System.Web.UI.SilverlightControls.Silverlight' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.6.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\7ed8edff\783ba126\assembly\dl3\e2ecee35\00ce32b0_6079c801\System.Web.Silverlight.DLL'

#1. Can you do the following steps?

- Please close the VS 2008.

- Clear Temporary ASP.NET Files

- Re-open the project.

- Please try to re-build and run the project. Let me know the result. 

#2. Can you check whether you have referenced System.Web.Silverlight.DLL or not? If you have referenced it in your project, let me know which version you are using. If you are using version 3.6, please remove it and add the version 3.5.
 

#3. Go to assemblies (Type "assembly" in Run) Please check how many version of System.Web.Extension you have.

 


(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Joined on 09-16-2005
Singapore
Posts 2,021
04-28-2008 10:35 AM
Re: Re: silverlight with MVC error in VS2008

#1  didn't work

#2 System.Web.Silverlight.DLL is version 2.0.5.0

But I now remove System.Web.Extension 3.6.0.0 of my referenced dll in my MVC web application and do't compile anymore.
I try to add 3.5.0.0 and dont compile and try to find 3.6.0.0 to add again and leave everything like it was but I couldn't found this dll.

#3 I have 2 versions of the dll 3.5.0.0 and 3.6.0.0

 Thanks very much for your help I think we are almost near the solution. How I continue now.
Thank you very much

sebaigle

Joined on 04-25-2008
Posts 9
04-28-2008 12:02 PM
Re: Re: silverlight with MVC error in VS2008
Hello,

sebaigle:
But I now remove System.Web.Extension 3.6.0.0 of my referenced dll in my MVC web application and do't compile anymore.
I try to add 3.5.0.0 and dont compile and try to find 3.6.0.0 to add agai

I have tried the following steps and it works.

#1)  Reset everything as default.  (We will use 3.6.0.0 version this time.)

#2)  Remove "System.Web.Silverlight.dll" from the reference of MVC project.

#3)  Remove this from aspx.

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>

#4. Rebuild the application.

#5. Run it on the browser. It will work.

Hope it helps. :)
 

 

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Joined on 09-16-2005
Singapore
Posts 2,021
04-28-2008 12:06 PM
Re: Re: silverlight with MVC error in VS2008

Hey man,

I created the sample for you. You may download the sample from this link http://michaelsync.net/demo/MvcApplicationWithSL2.zip 

Thanks for asking this question. I learnt something today. :)  

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Joined on 09-16-2005
Singapore
Posts 2,021
04-28-2008 12:17 PM
Re: Re: silverlight with MVC error in VS2008

Thanks again.
But what I couldn ' t do is to add the xap file or Page.xaml to Views/Home/About.aspx
How I do this ?

 Do u know how to do this ?? And when you add the silverlight application and select Link this Silverlight control into an exisiting website unchecked every option marked.

I hope you can follow my steps.


Thanks again
 

sebaigle

Joined on 04-25-2008
Posts 9
04-28-2008 12:24 PM
Marked as Answer
Re: Re: silverlight with MVC error in VS2008

sebaigle:

Thanks again.
But what I couldn ' t do is to add the xap file or Page.xaml to Views/Home/About.aspx
How I do this ?

 Do u know how to do this ??

 

It's simple. Just add form, ScriptManager and asp:Silverlight control in About.aspx.

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="MvcApplication1.Views.Home.About" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

    <h2>Todo: Company information</h2>
    <form id="form1" runat="server" style="height:100%;">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div  style="height:100%;">
            <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/SilverlightApplication1.xap" Version="2.0" Width="100%" Height="100%" />
        </div>
    </form>

</asp:Content>

Set default.aspx page as a startup page. And run the application. Go to About Page.

Hope it helps.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Joined on 09-16-2005
Singapore
Posts 2,021
04-28-2008 1:19 PM
Re: Re: Re: silverlight with MVC error in VS2008

Great man with this and the deleting of assemblies in web.config I can fix my issue.

Thanks a lot. 

sebaigle

Joined on 04-25-2008
Posts 9