2011-02-04 2 views
2

여기 내 코드입니다. 처음 실행하면 HttpNotificationChannel.Find()가 null을 반환합니다.왜 HttpNotificationChannel.Open 던지고 ArgumentException() E_INVALIDARG?

하지만 두 번째로 실행할 때 Find()는 적절한 것을 반환하지만 Open() 호출을 받으면 예외가 발생합니다. Open()이 인수를 취하지 않기 때문에 정말 이상합니다.

내가 뭘 잘못하고 있니?

public string ChannelName = "MyAppChannel"; 
    ... 
    NotificationChannel = HttpNotificationChannel.Find(ChannelName); 
    if (NotificationChannel == null) 
    { 
    NotificationChannel = new HttpNotificationChannel(ChannelName); 
    } 
    NotificationChannel.ChannelUriUpdated += new EventHandler(Channel_ChannelUriUpdated); 
    NotificationChannel.HttpNotificationReceived += new EventHandler(NotificationChannel_HttpNotificationReceived); 
    NotificationChannel.ErrorOccurred += new EventHandler(Channel_ErrorOccurred); 
    NotificationChannel.Open();   // <-- Kaboom here, the 2nd time 

여기에 전체 텍스트와 스택의 :

System.ArgumentException: E_INVALIDARG 
    at Microsoft.Phone.Notification.SafeNativeMethods.ThrowExceptionFromHResult(Int32 hr, Exception defaultException, NotificationType type) 
    at Microsoft.Phone.Notification.HttpNotificationChannel.Open() 
    at LiveShare.NotificationManager.Initialize() 
    at LiveShare.App..ctor() 
    at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) 
    at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) 
    at System.Reflection.ConstructorInfo.Invoke(Object[] parameters) 
    at MS.Internal.TypeProxy.<>c__DisplayClass30.b__2a() 
    at MS.Internal.TypeProxy.CreateInstance(UInt32 customTypeId) 
    at MS.Internal.FrameworkCallbacks.CreateKnownObject(IntPtr nativeRootPeer, UInt32 customTypeId, String initializationString, IntPtr& nativePeer, UInt32 isCreatedByParser) 
    at MS.Internal.FrameworkCallbacks.CreateUnknownObject(String assemblyName, String typeName, IntPtr nativeRootPeer, String initializationString, UInt32& customTypeId, UInt32& coreTypeId, UInt32& typeFlags, IntPtr& nativePeer) 

답변

2

Find()이 성공하면 올바른 해결책은 Open()으로 전화하지 않는 것입니다.

1

described by Nick Harris 지난 4 월과 CTP와 문서화 된 문제에 대한 매우 비슷합니다.

솔루션 : 당신은 거의 즉시 디버그 충돌 후 채널을 열려고하면이 문제까지 에뮬레이터 화재가 발생합니다. 해결책은 간단합니다. 전화를 걸기 전에 에뮬레이터에 2 분을줍니다.

그럴 경우 WP12 주식 시세 표시 응용 프로그램의 푸시 알림을 다루는 좋은 문서가 Silverlight Show에 있습니다.

+0

전화에 배포 할 때 발생합니다 ... –

+0

아니요,이 사항은 다릅니다. Find()가 성공하면 Open()을 호출하지 말아야한다고 생각합니다 ... –