我有一个使用silverlight的.NET应用程序。 在页面加载时我的控件没有呈现,我得到了以下错误 -
Microsoft JScript runtime error: Unhandled Error in Silverlight Application The remote server returned an error: NotFound. at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at MultipleUpLoad.Upload_page.GetEventListCallBack(IAsyncResult res)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass19.<InvokeGetResponseCallback>b__17(Object state2)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
由于它只发生在服务器上,所以似乎是环境问题。我该怎么办?
以下是我正确呈现的localLeft handide控件上显示的屏幕:
下面是在服务器上部署时如何呈现(左侧控制未正确呈现)
我控制的代码 -
<DataTemplate x:Key="myTaskTemplate">
<StackPanel Orientation="Horizontal" Width="Auto" >
<TextBlock Margin="5,5,5,5" Width="175" Height="20" FontSize="11" Text="{Binding EventName}" />
<StackPanel Orientation="Vertical" Width="auto">
<TextBox Margin="5,5,5,1" Width="150" Height="20" IsReadOnly="true"></TextBox>
<ProgressBar Margin="1,1,1,1" Width="150" Height="8"></ProgressBar>
</StackPanel>
<Button VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="5,5,5,5"
Content="Upload" Width="80" Height="25" VerticalAlignment="Top" FontSize="11" Click="uploadBtnClick_EventHandler" Tag="{Binding EventName}"></Button>
<!--<CheckBox Margin="5,5,5,5" VerticalAlignment="Top" ></CheckBox>-->
<Ellipse Height="15" HorizontalAlignment="Left" Width="15" Stroke="LightGray" StrokeThickness="2"/>
<Button VerticalContentAlignment="Center" IsEnabled="False" HorizontalContentAlignment="Center" Margin="5,5,5,5" Content="Edit Mapping" Width="110" Height="25" VerticalAlignment="Top" FontSize="11" Click="editMapping_click"></Button>
</StackPanel>
</DataTemplate>
代码背后:
public Upload_page()
{
appln = (App)Application.Current;
UploadDataUri = appln.DeploymentConfigurations["Silverlight_Config_UploadFileURI"];
LoadDataUri = appln.DeploymentConfigurations["Silverlight_Config_LoadDataURI"];
UploadUsingWebClientUri = appln.DeploymentConfigurations["Silverlight_Config_UploadUsingWebClientUri"];
GetEventListUri = appln.DeploymentConfigurations["Silverlight_Config_GetEventListUri"];
LoginUri = appln.DeploymentConfigurations["Silverlight_Config_LoginUri"];
InitializeComponent();
// filelist = new List<FileInfo>();
((TextBox)FindName("dataloadUri")).Text = LoadDataUri;
((TextBox)FindName("receiverUri")).Text = UploadDataUri;
// Initialize EventList
InitializeEventList();
}
public void InitializeEventList()
{
HttpWebRequest rq = (HttpWebRequest)WebRequestCreator.BrowserHttp.Create(new Uri(GetEventListUri));
rq.Method = "POST";
rq.Headers["EventName"] = "GetEventList";
rq.BeginGetResponse(GetEventListCallBack, rq);
}
public void GetEventListCallBack(IAsyncResult res)
{
HttpWebRequest rq = (HttpWebRequest)res.AsyncState;
using (HttpWebResponse httpResponse = (HttpWebResponse)rq.EndGetResponse(res))
{
using (Stream dataStream = httpResponse.GetResponseStream())
{
StreamReader reader = new StreamReader(dataStream);
var result = reader.ReadToEnd();
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
var doc = XDocument.Parse(result);
var error = (from p in doc.Descendants("Error") select p).ToList();
if (error.Count == 0)
{
eventList = (from p in doc.Descendants("mEvent") select GetEvent(p)).ToList();
LayoutRoot.DataContext = eventList;
}
else
{
//redirect to userLogin
System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(LoginUri));
}
}
);
}
}
//_autoEvent.Set();