diff --git a/README.md b/README.md
index d7f279b..8afdbc7 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ Library _almost_ ready for production usage. We need contributors to make 1.0.0
To use TLSharp follow next steps:
1. Clone TLSharp from GitHub
-1. Compile source with VS2015
+1. Compile source with VS2015 or MonoDevelop
1. Add reference to ```TLSharp.Core.dll``` to your awesome project.
# Dependencies
@@ -194,6 +194,7 @@ List of donators:
# Contributors
* [Afshin Arani](http://aarani.ir) - TLGenerator, and a lot of other usefull things
+* [Knocte](https://github.com/knocte)
# License
diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs
index f7c4ef2..2d8babf 100644
--- a/TLSharp.Core/Network/MtProtoSender.cs
+++ b/TLSharp.Core/Network/MtProtoSender.cs
@@ -279,9 +279,7 @@ namespace TLSharp.Core.Network
{
var resultString = Regex.Match(errorMessage, @"\d+").Value;
var dcIdx = int.Parse(resultString);
- var exception = new InvalidOperationException($"Your phone number registered to {dcIdx} dc. Please update settings. See https://github.com/sochix/TLSharp#i-get-an-error-migrate_x for details.");
- exception.Data.Add("dcId", dcIdx);
- throw exception;
+ throw new MigrationNeededException(dcIdx);
}
else
{
@@ -484,4 +482,15 @@ namespace TLSharp.Core.Network
return new MemoryStream(new byte[len], 0, len, true, true);
}
}
+
+ internal class MigrationNeededException : Exception
+ {
+ internal int DC { get; private set; }
+
+ internal MigrationNeededException(int dc)
+ : base ("$Your phone number is registered to a different dc: {dc}. Please migrate.")
+ {
+ DC = dc;
+ }
+ }
}
\ No newline at end of file
diff --git a/TLSharp.Core/TLSharp.Core.csproj b/TLSharp.Core/TLSharp.Core.csproj
index dda8970..31fee3a 100644
--- a/TLSharp.Core/TLSharp.Core.csproj
+++ b/TLSharp.Core/TLSharp.Core.csproj
@@ -9,7 +9,7 @@
Properties
TLSharp.Core
TLSharp.Core
- v4.5.2
+ v4.5
512
diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs
index 75d0466..40eefaf 100644
--- a/TLSharp.Core/TelegramClient.cs
+++ b/TLSharp.Core/TelegramClient.cs
@@ -110,16 +110,9 @@ namespace TLSharp.Core
completed = true;
}
- catch (InvalidOperationException ex)
+ catch (MigrationNeededException ex)
{
- if (ex.Message.StartsWith("Your phone number registered to") && ex.Data["dcId"] != null)
- {
- await ReconnectToDcAsync((int)ex.Data["dcId"]);
- }
- else
- {
- throw;
- }
+ await ReconnectToDcAsync(ex.DC);
}
}
diff --git a/TeleSharp.Generator/TeleSharp.Generator.csproj b/TeleSharp.Generator/TeleSharp.Generator.csproj
index c386fa6..94f3e9b 100644
--- a/TeleSharp.Generator/TeleSharp.Generator.csproj
+++ b/TeleSharp.Generator/TeleSharp.Generator.csproj
@@ -9,7 +9,7 @@
Properties
TeleSharp.Generator
TeleSharp.Generator
- v4.5.2
+ v4.5
512
true
diff --git a/TeleSharp.TL/TeleSharp.TL.csproj b/TeleSharp.TL/TeleSharp.TL.csproj
index 90f2c27..446410d 100644
--- a/TeleSharp.TL/TeleSharp.TL.csproj
+++ b/TeleSharp.TL/TeleSharp.TL.csproj
@@ -9,7 +9,7 @@
Properties
TeleSharp.TL
TeleSharp.TL
- v4.5.2
+ v4.5
512