Windows サービス インターフェイスとして Silverlight を使用したいと考えています。そのために、カスタム Web サーバーを使用して xap ファイルを提供していますが、正常に動作します。
RiaServices を使用したいのですが、もちろん IIS は関係ありません。
これが私のコードです:
[EnableClientAccess]
public class TestDomainService : DomainService {
public IQueryable<Foo> GetPontos() {
List<Foo> list = new List<Foo>();
list.Add(new Foo {Id = 1});
return list.AsQueryable();
}
}
public class Foo {
[Key]
public int Id { get; set; }
public string Name { get; set; }
}
そしてプログラム:
static void Main(string[] args) {
DomainServiceHost host = new DomainServiceHost(typeof(TestDomainService), new Uri("http://0.0.0.0:8099/TestDomainService"));
host.Open();
}
このコードを空の cmd アプリケーションで使用すると、再生ボタンを押すとランタイム例外がスローされます。
System.TypeAccessException が処理されませんでした。アセンブリ 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' は、現在の AppDomain で有効になっていない条件付き APTCA アセンブリです。このアセンブリを部分信頼コードまたはセキュリティ透過コードで使用できるようにするには、アセンブリ名「System.ComponentModel.DataAnnotations」を追加してください。PublicKey=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9' to the the PartialTrustVisibleAssemblies list when creating the AppDomain. Source=System.ServiceModel.DomainServices.Server TypeName="" StackTrace: System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetForeignKeyMembers() で System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetTypeDescriptor (型 objectType、オブジェクト インスタンス) で System .ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.System.Collections.Concurrent.ConcurrentDictionary のDisplayClass8.b _7(Type タイプ)2.GetOrAdd(TKey key, Func
2 valueFactory) System.ServiceModel.DomainServices.Server.DomainServiceDescription.GetDescription(Type domainServiceType) で System.ServiceModel.DomainServices.Hosting.DomainServiceHost..ctor(Type domainServiceType, Uri[] baseAddresses) で PartialTrustTest.Program.Main(String[ ] args) in D:\Users\carlucci\Documents\My Dropbox\My Dropbox\Way2\PartialTrustTest\PartialTrustTest\Program.cs:10 行目 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain .nExecuteAssembly(RuntimeAssembly アセンブリ、String[] args) で System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel) で System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly() で System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext 、String[] activationCustomData) で System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext) で System.Activator.CreateInstance(ActivationContext activationContext) で Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() で System.Threading.ThreadHelper.ThreadStart_Context(オブジェクト状態) System.Threading.ExecutionContext.Run で (ExecutionContext 実行コンテキスト、ContextCallback コールバック、オブジェクト状態、ブール値の ignoreSyncCtx) System.Threading.ExecutionContext.Run で (ExecutionContext 実行コンテキスト、ContextCallback コールバック、オブジェクト状態) System.Threading.Th でMicrosoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() での CreateInstance(ActivationContext activationContext) System.Threading.ThreadHelper.ThreadStart_Context(オブジェクト状態) で System.Threading.ExecutionContext.Run(ExecutionContext executionContext、ContextCallback コールバック、オブジェクト状態、Boolean ignoreSyncCtx) System.Threading.ExecutionContext.Run (ExecutionContext executionContext、ContextCallback コールバック、オブジェクト状態) で System.Threading.ThMicrosoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() での CreateInstance(ActivationContext activationContext) System.Threading.ThreadHelper.ThreadStart_Context(オブジェクト状態) で System.Threading.ExecutionContext.Run(ExecutionContext executionContext、ContextCallback コールバック、オブジェクト状態、Boolean ignoreSyncCtx) System.Threading.ExecutionContext.Run (ExecutionContext executionContext、ContextCallback コールバック、オブジェクト状態) で System.Threading.ThSystem.Threading.Th での ExecutionContext.Run (ExecutionContext 実行コンテキスト、ContextCallback コールバック、オブジェクト状態)System.Threading.Th での ExecutionContext.Run (ExecutionContext 実行コンテキスト、ContextCallback コールバック、オブジェクト状態)
readHelper.ThreadStart() InnerException:
System.ComponentModel.DataAnnotations を APTCA に追加しようとしましたが、成功しませんでした:(
アプリケーションを完全な信頼で実行するように変更しましたが、成功しませんでした:(
何か案が?