2010-12-16 8 views
4

Windows 서비스 인터페이스로 silverlight를 사용하고 싶습니다. 이를 위해 xap 파일을 제공하기 위해 사용자 지정 웹 서버를 사용하고 있으며 정상적으로 작동합니다.IIS없이 Silverlight RiaServices를 사용할 수 있습니까?

이제 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.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetForeignKeyMembers()'에 의해 시도되었습니다. ccess 보안 중요 유형 인 System.ComponentModel.DataAnnotations.AssociationAttribute '가 실패했습니다. 어셈블리 'System.ComponentModel.DataAnnotations, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'는 현재 AppDomain에서 사용할 수없는 조건부 APTCA 어셈블리입니다. 응용 프로그램 도메인을 만들 때 부분 신뢰 또는 보안 투명 코드에 의해 사용되는이 어셈블리를 사용하려면하여 PartialTrustVisibleAssemblies 목록에 어셈블리 이름 ', 한 PublicKey = 0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9 System.ComponentModel.DataAnnotations'를 추가하시기 바랍니다. 출처 = System.ServiceModel.DomainServices.Server 유형 이름 = "" 스택 트레이스 : System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetForeignKeyMembers에서 () System.ServiceModel.DomainServices.Server.DomainTypeDescriptionProvider.GetTypeDescriptor에서 (유형 objectType의,) System.ServiceModel.DomainServices.Server.DomainServiceDescription.AddEntityType에서 System.ComponentModel.TypeDescriptor.GetProperties에서 System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties에서 () (유형 componentType가) 을 객체 인스턴스 (형식 entityType) at System.ServiceModel.DomainServices.Server.DomainServiceDescription.AddQueryMethod (도메인 System.ServiceModel.DomainServices.Server.DomainServiceDescription에서 System.ServiceModel.DomainServices.Server.DomainServiceDescription.CreateDescription (유형 domainServiceType) 에서 System.ServiceModel.DomainServices.Server.DomainServiceDescription.Initialize() 에서 OperationEntry 방법) . System.ServiceModel.DomainServices에서 System.ServiceModel.DomainServices.Server.DomainServiceDescription.GetDescription (유형 domainServiceType) 에서 <> C_ DisplayClass8.b _7 (형 타입) System.Collections.Concurrent.ConcurrentDictionary 2.GetOrAdd(TKey key, Func 2 ValueFactory의 AT) D : \ Users \ carlucci \ Documents \ My Dropbox \ My Dropbox \ My2 \ PartialTrustTest \ PartialTrustTest의 PartialTrustTest.Program.Main (String [] args)에서 .Hosting.DomainServiceHost..ctor (유형 domainServiceType, Uri [] baseAddresses) \ Program.cs : System.AppDomain._nExecuteAssembly (RuntimeAssembly 어셈블리, String [] args)의 줄 System.AppDomain.nExecuteAssembly (RuntimeAssembly 어셈블리, String [] args)의 at System .Runtime.Hosting.ManifestRunner.Run (Boolean checkAptModel) at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly() at System.Runtime.Hosting.ApplicationActivator.를 CreateInstance (ActivationContext activationContext 문자열 [] activationCustomData) Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone에서 System.Activator.CreateInstance (ActivationContext activationContext) 에서 System.Runtime.Hosting.ApplicationActivator.CreateInstance (ActivationContext activationContext) (AT ) System.Threading.ExecutionContext.Run에서 System.Threading.ExecutionContext.Run에서 System.Threading.ThreadHelper.ThreadStart_Context (개체 상태) (의 ExecutionContext의 ExecutionContext, ContextCallback 콜백 개체 상태, 부울 ignoreSyncCtx) (의 ExecutionContext의 ExecutionContext, ContextCallback 콜백에서, 개체 상태)at System.Threading.Th

,210

readHelper.ThreadStart() 의 InnerException : 나는 APTCA에 System.ComponentModel.DataAnnotations를 추가하려고


,하지만 난 완전 신뢰에서 실행되도록 내 응용 프로그램을 변경없이 성공 :(

하지만, 성공 없음 :(

어떤 생각?

+0

디버그 모드에서 실행하는 경우, 프로젝트 속성으로 이동해야>의 선택을 취소 "비주얼 스튜디오를 사용 호스팅 프로세스 "및이 오류가 중지됩니다. –

답변

0

IIS가없는 RIA 서비스를 사용할 수 있습니다. 열기 전에 도메인 서비스를 구성 : 당신이 제거해야 IIS와 관련된 몇 가지 설정이 있었다 기억으로

DomainServiceHost host = new DomainServiceHost(typeof(DomainService1), uri); 
host.Description.Behaviors.Remove<AspNetCompatibilityRequirementsAttribute>(); 

은 또한 당신의 EXE 파일의 *의의 .config를 확인합니다.

또한 VS의 프로젝트 속성에서 "디버그"탭을 열고 "Visual Studio 호스팅 프로세스 사용"을 선택 취소하십시오.

1

뿐만 아니라 Excel PowerPivot에서 소모 할 수있는 OData를 RIA에 제공하는 전체 코드 목록도 있습니다. 비주얼 스튜디오 호스팅 프로세스를 끄거나 디버깅하지 않고 실행해야한다는 것을 기억하십시오. 후행 슬래시를 포함하는 기억은 PowerPivot을 사용하는 경우 그래서 당신의 URL가 될 것입니다 : -> 디버그 - http://localhost:999/TestDomainService/

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(); 
       } 
     } 
}