I want to use silverlight as my windows service interface. For that, I'm using a custom web server to provide the xap file and it works fine.
Now I want to use RiaServices, but of course I there is no IIS involved.
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 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 once you hit play, a runtime exception is thrown:
System.TypeAccessException was unhandled Message=Attempt by security transparent method 'System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetForeignKeyMembers()' to access security critical type System.ComponentModel.DataAnnotations.AssociationAttribute' failed.
Assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is a conditionally APTCA assembly which is not enabled in the current AppDomain. To enable this assembly to be used by partial trust or security transparent code, please add assembly name 'System.ComponentModel.DataAnnotations, PublicKey=0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9' to the the PartialTrustVisibleAssemblies list when creating the AppDomain.
Source=System.ServiceModel.DomainServices.Server
TypeName=""
StackTrace:
at System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetForeignKeyMembers()
at System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetTypeDescriptor(Type objectType, Object instance)
at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties()
at System.ComponentModel.TypeDescriptor.GetProperties(Type componentType)
at System.ServiceModel.DomainServices.Server.DomainServiceDescription.AddEntityType(Type entityType)
at System.ServiceModel.DomainServices.Server.DomainServiceDescription.AddQueryMethod(DomainOperationEntry method)
at System.ServiceModel.DomainServices.Server.DomainServiceDescription.Initialize()
at System.ServiceModel.DomainServices.Server.DomainServiceDescription.CreateDescription(Type domainServiceType)
at System.ServiceModel.DomainServices.Server.DomainServiceDescription.<>c_DisplayClass8.b_7(Type type)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func
2 valueFactory)
at System.ServiceModel.DomainServices.Server.DomainServiceDescription.GetDescription(Type domainServiceType)
at System.ServiceModel.DomainServices.Hosting.DomainServiceHost..ctor(Type domainServiceType, Uri[] baseAddresses)
at PartialTrustTest.Program.Main(String[] args) in D:\Users\carlucci\Documents\My Dropbox\My Dropbox\Way2\PartialTrustTest\PartialTrustTest\Program.cs:line 10
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Th
readHelper.ThreadStart() InnerException:
I tried to add System.ComponentModel.DataAnnotations to the APTCA, but no success :(
I changed my application to run in full trust, but no success :(
Any idea?