asp.net4ashxから文字列を取得する単純なメソッドに問題があります。このasp.netアプリケーションによってホストされているSilverlightアプリケーションのメソッドを以下で実行しています。
private void LoadPlugins()
{
var serviceAddress = _baseAddress
+ "PluginsService.ashx?"
+ DateTime.Now.Ticks;
var client = new WebClient();
client.DownloadStringCompleted += client_DownloadStringCompleted;
client.DownloadStringAsync(new Uri(serviceAddress));
}
void client_DownloadStringCompleted(
object sender,
DownloadStringCompletedEventArgs e)
{
var plugins = e.Result.Split(
new string[] { Environment.NewLine },
StringSplitOptions.RemoveEmptyEntries);
foreach (var plugin in plugins)
{
AddXap(_baseAddress + plugin);
}
}
PluginsService.ashx.cs:
namespace MefPlugins.Web
{
/// <summary>
/// Summary description for PluginsService
/// </summary>
public class PluginsService : IHttpHandler
{
private const string PluginsFolderName = "Plugins/";
public void ProcessRequest(HttpContext context)
{
//var pluginFolder = new DirectoryInfo(
// HttpContext.Current.Server.MapPath(
// PluginsFolderName));
//var response = new StringBuilder();
//if (pluginFolder.Exists)
//{
// foreach (var xap in pluginFolder.GetFiles("*.xap"))
// {
// response.AppendLine(
// PluginsFolderName + xap.Name);
// }
//}
var response = new StringBuilder();
response.Append("test");
context.Response.ContentType = "text/plain";
context.Response.Write(response);
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
エラーが発生します:
System.Reflection.TargetInvocationExceptionがユーザーコードによって処理されませんでしたMessage=操作中に例外が発生し、結果が無効になりました。例外の詳細については、InnerExceptionを確認してください。StackTrace:w System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()w System.Net.DownloadStringCompletedEventArgs.get_Result()w MefPlugins.MainPage.client_DownloadStringCompleted(Object sender、DownloadStringCompletedEventArgs e)w System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e) Net.WebClient.DownloadStringOperationCompleted(Object arg)InnerException:System.Net.WebExceptionメッセージ=WebClient要求中に例外が発生しました。InnerException:System.NotSupportedExceptionメッセージ=URIプレフィックスが認識されません。
どこにバグがあるのでしょうか?これはhttp://www.galasoft.ch/sl4u/code/chapter20/20.02-Mef/MefPlugins.zipの例です