Author Topic: Silverlight - Fix "AG_E_NETWORK_ERROR" cross domain policy  (Read 2173 times)


  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Silverlight - Fix "AG_E_NETWORK_ERROR" cross domain policy
« on: December 16, 2011, 02:05:45 pm »
Having the following code in Silverlight application and then if you are testing it on your local machine, it would popup the error message "AG_E_NETWORK_ERROR".

However if the same code is deployed on, then it would work fine.

To solve this error,
1. Make sure you are not crossing any domain.
2. Make sure the URL is typed correctly.
3. Make sure the file type is supported or good. For example, if you have .bmp file, it might not work for no reason. If you convert the same bitmap image to .jpg file, then it would work fine.

Code: (C#)
//Source Code Listing

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Shapes;
using System.Threading;

namespace ImageTester
  public partial class MainPage : UserControl
        public MainPage()
            string url = "";
            Image myImage = new Image();
            myImage.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(LoadImage_Failed);
            ImageSource imgSource = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute));
            myImage.SetValue(Image.SourceProperty, imgSource);

        void LoadImage_Failed(object sender, ExceptionRoutedEventArgs e)


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1