-
-
Save fischerman/0b97878c32bfefda8548 to your computer and use it in GitHub Desktop.
Reproduce error with EWS on mono
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM mono:onbuild | |
CMD [ "mono", "./ewsTest.exe" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Exchange.WebServices.Data; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace ewsManageedTest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2); | |
service.Url = new Uri(""); | |
service.Credentials = new WebCredentials("", ""); | |
var subscription = service.SubscribeToStreamingNotifications( | |
new FolderId[] {new FolderId(WellKnownFolderName.Calendar, "")}, | |
EventType.Created, | |
EventType.Deleted, | |
EventType.Modified | |
); | |
service.TraceListener = new Tracer(); | |
service.TraceFlags = TraceFlags.EwsResponse | TraceFlags.EwsRequest; | |
service.TraceEnabled = true; | |
StreamingSubscriptionConnection conn = new StreamingSubscriptionConnection(service, 10); | |
conn.AddSubscription(subscription); | |
conn.OnDisconnect += conn_OnDisconnect; | |
conn.OnNotificationEvent += conn_OnNotificationEvent; | |
conn.OnSubscriptionError += conn_OnSubscriptionError; | |
conn.Open(); | |
Thread.Sleep(TimeSpan.FromHours(1)); | |
} | |
static void conn_OnSubscriptionError(object sender, SubscriptionErrorEventArgs args) | |
{ | |
} | |
static void conn_OnNotificationEvent(object sender, NotificationEventArgs args) | |
{ | |
} | |
static void conn_OnDisconnect(object sender, SubscriptionErrorEventArgs args) | |
{ | |
if (args.Exception != null) | |
throw args.Exception; | |
} | |
} | |
class Tracer : ITraceListener | |
{ | |
public void Trace(string traceType, string traceMessage) | |
{ | |
Console.WriteLine(" [ T ] type: {0} \n {1} ", traceType, traceMessage); | |
} | |
} | |
} |
Downloaded latest mono release on windows and created a console program, ran it in the mono command prompt, still works fine. I'm now more inclined to think that something has been fixed between Exchange 2010 SP2 and Exchange 2013, since I can't replicate the error.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tried this against a Exchange 2013 box I have. Running as a test within Visual Studio.
Requested 2010_SP2 mode from the server as in your code.
Seems to work just fine, no problem.
Maybe a mono-specific problem.
Response message: