Thursday, January 06, 2011

Asking to Install Silverlight 4 when it’s already installed with Visual Studio 2010

Asking to Install Silverlight 4 when it's already installed with Visual Studio 2010
Check one thing in your system


1) Make sure Microsoft Silverlight is enabled on internet explorer. 
Go to IE à Tools à Internet optionsà on the programs tab click on "manage add ons" button and check for Microsoft Silverlight 4 is Enable.
Still if you are not able to solve this please uninstall all Silverlight components and install in proper way, follow the installation instruction in http://www.microsoft.com/getsilverlight/Get-Started/Install/Default.aspx
2) If you don't have time to do this so, still you can test your application by using Silverlight enable browser.
  • Go to the Project à right click à go to Property page
  • Go to the Silverlight page and click on the "Enable running application out of the Browser
  • Now run your application using Visual Studio 2010
3) Make sure you are running silverlight App on 32 bit Browser, Because  Silverlight App does not works on 64 Bit IE Browsers.
  
I Solve this issue in following way, It is not the solution but its works for me


When I create application first time and run, it giving me pop up for Silverlight installation..
Now go to project properties --> Silverlight Tab and just Check and Uncheck again (so no change) on the 
"Enable running application out of browser" check box and close this window with Save or without saving now run the application (press F5), it works fine. 


Make sure your startup project set as SilverlightApplication NOT SilverlightApplication.Web


I tested this with
  • SilverLight 4 
  • IE Browser 8/9 32bit (this issue  not comes in other browser like Chrome, Mozilla etc.)
  • Visual Studio 2010
  • Window 7 as OS
Finally Finally I got the solution for this .....................
  1. Make sure you are not running IE 64 bit, because silverlight 4.0 and less  does not support IE 64 bit, Silverlight 5.0 and above support this
  2. Now if you are using IE 32 bit then Add your application URL as a Trusted site, try following option

Go to IE --> Internet Options -->  Security --> Trusted sites --> Sites --> Add

  • Add you site URL
  • Uncheck "Require server verification (https:) for all sites in this zone"

That's it, you are good to go.

Attempting to access a service in a cross-domain way without a proper cross-domain policy in place......

Error: Attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute.
I resolved this issue by placing "ClientAccessPolicy.xml" into Web service location "C:/inetpup/MyService" folder.
Go ahead and create one "ClientAccessPolicy.xml" file with following content and save into your service location folder in "C:/inetpup/
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
       <cross-domain-access>
              <policy>
                     <allow-from http-request-headers="SOAPAction">
                           <domain uri="*"/>
                     </allow-from>
                     <grant-to>
                           <resource path="/" include-subpaths="true" />
                     </grant-to>
              </policy>
       </cross-domain-access>
</access-policy>

In some cases you may have place one more file "crossdomain.xml"

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

Monday, January 03, 2011

CS0135: 'Model' conflicts with the declaration 'System.Web.Mvc.ViewPage.Model'

CS0135: 'Model' conflicts with the declarationSystem.Web.Mvc.ViewPage<TModel>.Model
After spending couple of hours I found the solution, before my try I tried all the option suggested on internet like: add the namespace with the class which you are using
Inherits="System.Web.Mvc.ViewPage<Attachment>"  and add a
<%@ Import namespace="MyProject.Models" %> Or
Inherits="System.Web.Mvc.ViewPage< MyProject.Models.Attachment>" 

But for me problem was different, the problem was
Cause
I used validation control (ValidationMessageFor) to and passed wrong parameter with "=>" expression like:
Line -1: <%= Html.ValidationMessageFor(Model => Model.Employee)%></div>

Line -2: <% Html.RenderPartial("Attachment", Model ); %> 
Because of Line -1: mistake Line -2: was giving error "CS0135: 'Model' conflicts with the declaration 'System.Web.Mvc.ViewPage<TModel>.Model"
Solution
I correct above line like below
<%= Html.ValidationMessageFor(Employee=> Model.Employee)%></div>

<% Html.RenderPartial("Attachment", Model ); %>
It was very stupid mistake but its took longer time to analyzed, Now my page is working fine.

Saturday, January 01, 2011

ASP.NET MVC 2 common problems while develope a View

ASP.NET MVC 2 common problems and solutions
While working with MVC2 with ASP.Net, I faced couples of problem while developing the View form, some of those are below
1)      Multiple submit button on the same page
2)      How to make Default Button
3)      How to add Image on the Submit Button
4)      Validation Control on ASP.Net MVC 2
5)      How to add Image with the validation message
After spending couple of hours I got good links where you get all these solution
How to put multiple submit button on the same page
When you have one web page having couples of action then you need multiple buttons on the same page and each button has different ResultAction, Find solution here
How to make Default Button in ASP.Net MVC View
When you have multiple button and out of that you want to make one button as default, Find solution here
How Image button works like page Submit button in ASP.Net MVC View
When you have a requirement to put Image on the page submit button and have multiple submit button on same page. The main problem is Image button will not work like Submit button then how to put image on the submit button. I tied following solution and it works for me , Find solution here
Validation Control on ASP.Net MVC 2
When you have to implements validation control in your ASP.Net MVC 2 web form then I found very good article about this, How to use validation control in ASP.Net MVC 2, Find Solution here
Add image with validation message
You have validation message and with the validation message your requirement to add Image (like: alert, explanation image etc.), then you can find the solution from here