Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否可以在没有IIS的情况下使用Silverlight服务?_Silverlight_Ria_Wcf Ria Services_Partial Trust - Fatal编程技术网

是否可以在没有IIS的情况下使用Silverlight服务?

是否可以在没有IIS的情况下使用Silverlight服务?,silverlight,ria,wcf-ria-services,partial-trust,Silverlight,Ria,Wcf Ria Services,Partial Trust,我想使用silverlight作为我的windows服务界面。为此,我使用一个定制的web服务器来提供xap文件,它工作得很好 现在我想使用RiaServices,但我当然不想使用IIS 这是我的密码: [EnableClientAccess] public class TestDomainService : DomainService { public IQueryable<Foo> GetPontos() { List<Foo> list =

我想使用silverlight作为我的windows服务界面。为此,我使用一个定制的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; }
}
您可以在空的cmd应用程序中使用此代码,一旦点击play,将引发运行时异常:

System.TypeAccessException未经处理消息=安全透明方法“System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetForeignKeyMembers()”尝试访问安全关键类型System.ComponentModel.DataAnnotations.AssociationAttribute”失败。 程序集“System.ComponentModel.DataAnnotations,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”是当前AppDomain中未启用的有条件APTCA程序集。要使此程序集能够由部分信任或安全透明代码使用,请添加程序集名称'System.ComponentModel.DataAnnotations,PublicKey=0024000004800009400006020000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53工厂1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C3988C454307E8E33B84263DAEC9F59686F74E57565E2189F46A249至DAC3080559创建AppDomain时的PartialTrustVisibleSassemblies列表。 Source=System.ServiceModel.DomainServices.Server TypeName=“” 堆栈跟踪: 位于System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetForeignKeyMembers()处 位于System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetTypeDescriptor(类型objectType,对象实例) 位于System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties()处 位于System.ComponentModel.TypeDescriptor.GetProperties(类型componentType) 位于System.ServiceModel.DomainServices.Server.DomainServiceDescription.AddEntityType(类型entityType) 位于System.ServiceModel.DomainServices.Server.DomainServiceDescription.AddQueryMethod(DomainOperationEntry方法) 位于System.ServiceModel.DomainServices.Server.DomainServiceDescription.Initialize()处 位于System.ServiceModel.DomainServices.Server.DomainServiceDescription.CreateDescription(类型domainServiceType) 位于System.ServiceModel.DomainServices.Server.DomainServiceDescription.c_DisplayClass8.b_7(类型) 在System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKey键,Func
2值工厂) 位于System.ServiceModel.DomainServices.Server.DomainServiceDescription.GetDescription(类型domainServiceType) 位于System.ServiceModel.DomainServices.Hosting.DomainServiceHost..ctor(类型domainServiceType,Uri[]baseAddresses) 位于D:\Users\carlucci\Documents\My Dropbox\My Dropbox\Way2\PartialTrustTest\PartialTrustTest\Program.cs中的PartialTrustTest.Program.Main(字符串[]args):第10行 位于System.AppDomain.\u nExecuteAssembly(RuntimeAssembly程序集,字符串[]args) 位于System.AppDomain.nExecuteAssembly(运行时程序集,字符串[]args) at System.Runtime.Hosting.ManifestRunner.Run(布尔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\u上下文(对象状态) 在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态,布尔ignoreSyncCtx) 在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态) 在System.Threading.Th

readHelper.ThreadStart() 内部异常:


我尝试将System.ComponentModel.DataAnnotations添加到APTCA,但没有成功:(

我将应用程序更改为完全信任运行,但未成功:(


有什么想法吗?

您可以在没有IIS的情况下使用RIA服务。请在打开之前配置域服务:

DomainServiceHost host = new DomainServiceHost(typeof(DomainService1), uri);
host.Description.Behaviors.Remove<AspNetCompatibilityRequirementsAttribute>();
DomainServiceHost主机=新的DomainServiceHost(typeof(DomainService1),uri);
host.Description.Behaviors.Remove();
还要检查exe文件的*.config,因为我记得有一些与IIS相关的设置需要删除


此外,在VS中的项目属性中,打开“调试”选项卡并取消选中“启用Visual Studio宿主进程”.

这不仅是可能的,而且这里有一个完整的代码列表,它为RIA提供了OData,该OData可由Excel PowerPivot使用。请记住,您必须关闭visual studio宿主进程,或者只是在不调试的情况下运行。使用PowerPivot时,请记住包含尾部斜杠,以便您的URL:

使用系统;
使用System.ComponentModel.DataAnnotations;
使用System.Linq;
使用System.ServiceModel.Activation;
使用System.ServiceModel.DomainServices.Hosting;
使用System.ServiceModel.DomainServices.Server;
命名空间控制台应用程序1
{
公共部分课程
{
[启用客户端访问]
公共类TestDomainService:DomainService
{
[查询(IsDefault=true)]
公共IQueryable GetAllFoos()
{
返回newfoo[]{newfoo{Id=1,Name=“Jonathan”}}.AsQueryable();
}
}
公开课Foo
{
[关键]
公共int Id{get;set;}
DomainServiceHost host = new DomainServiceHost(typeof(DomainService1), uri);
host.Description.Behaviors.Remove<AspNetCompatibilityRequirementsAttribute>();
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.ServiceModel.Activation;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;

namespace ConsoleApplication1
{
       public partial class Program
       {
              [EnableClientAccess]
              public class TestDomainService : DomainService
              {
                     [Query(IsDefault=true)]
                     public IQueryable<Foo> GetAllFoos()
                     {
                           return new Foo[] { new Foo { Id = 1, Name = "Jonathan" } }.AsQueryable();
                     }
              }

              public class Foo
              {
                     [Key]
                     public int Id { get; set; }
                     public string Name { get; set; }
              }

              static void Main(string[] args)
              {
                     var svc = new DomainServiceHost(typeof(TestDomainService), new Uri[] { new Uri("http://localhost:999/TestDomainService") });
                     svc.Description.Behaviors.RemoveAll<AspNetCompatibilityRequirementsAttribute>();

                     var svcDescription = DomainServiceDescription.GetDescription(typeof(TestDomainService));
                     var endpoints = new ODataEndpointFactory().CreateEndpoints(svcDescription, svc);

                     svc.Description.Endpoints.Clear();

                     foreach (var endpoint in endpoints)
                     {
                           svc.Description.Endpoints.Add(endpoint);
                     }

                     svc.Open();

                     Console.WriteLine("Domain service started, press any key to exit.");
                     Console.ReadKey();
              }
       }
}