I want to use silverlight as my windows service interface. For this, I use a custom web server to provide the xap file, and it works great.
Now I want to use RiaServices, but, of course, I do not participate in IIS.
Here is my code:
[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; } }
And the program:
static void Main(string[] args) { DomainServiceHost host = new DomainServiceHost(typeof(TestDomainService), new Uri("http://0.0.0.0:8099/TestDomainService")); host.Open(); }
You can use this code in an empty cmd application, and after you click the game, an exception is thrown for execution:
System.TypeAccessException was unhandled. Message = Attempted by a transparent security method. System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetForeignKeyMembers () 'to access the critical security type. System.ComponentModel.DataAnnotations.AssociationAttribute 'failed. Assembly 'System.ComponentModel.DataAnnotations, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35' is an APTCA conditional assembly that is not included in the current AppDomain. To enable the assembly that will be used by partially transparent or trust the security code, please add the name of the assembly "System.ComponentModel.DataAnnotations, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9" in the list on PartialTrustVisibleAssemblies to create AppDomain. Source = System.ServiceModel.DomainServices.Server TypeName = "" Stack Trace: at System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetForeignKeyMembers () in System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetTypeDescriptor (type objectType, object instance) in System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties () in System.ComponentModel.TypeDescriptor.GetProperties (TypeTomTerService.Service.Service.Service.Service.Service.Service ServiceModel.DomainServices.Server.DomainServiceDescription.AddQueryMethod (DomainOperationEntry method) in System.ServiceModel.DomainServices.Server.DomainServiceDescription.Initialize () in System.ServiceModel.DomainServices.Server.DomainCerviceDvice tion (type domainServiceType) in System.ServiceModel.DomainServices.Server.DomainServiceDescription. <> c_DisplayClass8.b_7 (Type Type) in System.Collections.Concurrent.ConcurrentDictionary 2.GetOrAdd(TKey key, Func 2 valueFactory) in System.ServiceModel.DomainServices.Server.DomainServiceDescription.GetDescription (Type domainService.DerviceTervicepemepevicepemepevicepemepevicepemepevicepemevicepemeperevicevicemeyerpemevicevicemeyerpeimevice .Hosting.DomainServiceHost..ctor (type domainServiceType, Uri [] baseAddresses) in PartialTrustTest.Program.Main (String [] args) in D: \ Users \ carlucci \ Documents \ My Dropbox \ My Dropbox \ Way2 \ PartialTrustTest \ PartialTrustTest \ Program.cs: line 10 in System.AppDomain._nExecuteAssembly (assembly RuntimeAssembly, String [] args) in System.AppDomain.nExecuteAssembly (assembly RuntimeAssembly, String [] args) in System.Runtime.Hosting.ManifestRunner.Run (Boolean check) in System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly () in System.Runtime.Hosting.ApplicationActivator.CreateInstance (ActivationContext activationContext, String [] activationCus tomData) in System.Runtime.Hosting.ApplicationActivator.CreateInstance (ActivationContext activationContext) in System.Activator.CreateInstance (ActivationContext activationContext) in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDreadHreadProoneZone.readgonezone.readgonezone.readgonezone.readgonezone.readgonezone.readgonezone in System.Threading.ExecutionContext.Run (ExecutionContext executeContext, ContextCallback callback, object state, Boolean ignoreSyncCtx) in System.Threading.ExecutionContext.Run (ExecutionContext executeContext, ContextCallback callback, object state) in System.ThreadingTh
readHelper.ThreadStart () InnerException:
I tried to add System.ComponentModel.DataAnnotations to APTCA but did not succeed :(
I changed my application to full trust, but did not have time :(
Any idea?