I'm attempting to execute the following:
var builder = services.AddIdentityServer(
options => { options.IssuerUri = "https://boo.com"; })
.AddExtensionGrantValidator<LPDelegationGrantValidator>()
.AddProfileService<ONBProfileService>()
.AddOperationalStore(options =>
{
options.ConfigureDbContext = b =>
{
b.UseSqlServer(connectionString, db => db.MigrationsAssembly(migrationsAssembly));
};
})
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = b =>
{
b.UseSqlServer(connectionString, db => db.MigrationsAssembly(migrationsAssembly));
};
});
This used to work but then I moved the solution to a different location and renamed some of my projects. Now it's crashing with the the following error.
I've tried aligning the versions of the packages I'm referencing to v3.1.3 but it's not fixing this.
Is there a straight-forward way to resolve this?
System.TypeLoadException
HResult=0x80131522
Message=Method 'FindIdentityResourcesByScopeNameAsync' in type 'IdentityServer4.EntityFramework.Stores.ResourceStore' from assembly 'IdentityServer4.EntityFramework.Storage, Version=3.1.3.0, Culture=neutral, PublicKeyToken=f294d0afe402bb2b' does not have an implementation.
Source=IdentityServer4.EntityFramework
StackTrace:
at Microsoft.Extensions.DependencyInjection.IdentityServerEntityFrameworkBuilderExtensions.AddConfigurationStore[TContext](IIdentityServerBuilder builder, Action`1 storeOptionsAction)
at Microsoft.Extensions.DependencyInjection.IdentityServerEntityFrameworkBuilderExtensions.AddConfigurationStore(IIdentityServerBuilder builder, Action`1 storeOptionsAction)
at IdSrv_Host_Console.Startup.GetSqlConfigurationBuilder(IServiceCollection services) in C:\Workspace\dev\live-person-sts-id4\IdentityServer4\Bupa_src\Idsrv_Host_Console\Startup.cs:line 75
at IdSrv_Host_Console.Startup.ConfigureServices(IServiceCollection services) in C:\Workspace\dev\live-person-sts-id4\IdentityServer4\Bupa_src\Idsrv_Host_Console\Startup.cs:line 49
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass15_0.<BuildStartupServicesFilterPipeline>g__RunPipeline|0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass14_0.<ConfigureServices>g__ConfigureServicesWithContainerConfiguration|0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
I faced the same issue when refactored my solution and extracted my DbContext into a separate project. This GitHub issue discussion helped me to fix that: Check that IdentityServer4.EntityFramework.Storage v3.1.3 is installed.
As you mentioned in your question you've already did that but in my case I had different versions in the original ASP.NET application and in the project I've extracted my DbContext to - there NuGet package was resolved with the latest v4.0.2 which caused incompatibility and runtime exception.
Hope that will help!
Related
I'm migrating a WPF based on Prism and DryIOC to .Net Core 3.1. I'm finding that DryIOC fails to handle dependency resolution when it comes to the .net core configuration features. I've tried injecting IOption<>, IConfiguration, etc, nothing using the .Net Core Configuration will resolve without throwing an exception.
I thought that it may be that DryIOC wasn't fully compatible yet with the Microsoft DI, but I've produced a number of sandbox attempts that show that DryIOC does work with web projects using .Net Core. I've also proven that I can get WPF projects to work when not using Prism and DryIOC. I have a sample app that shows the problem I'm getting.
The sample resolves a class object and tries to resolve a configuration section from the file appsettings.json into the MainWindowViewModel. My class object resolves just fine, but blows up when trying to resolve IOptions using this code
public MainWindowViewModel(
IUser user
// Comment out the next line to avoid the DI exception
, IOptions<AppSettings> settings
)
{
_user = user;
// Comment out the next line to avoid the DI exception
_settings = settings;
}
The setup code for the ConfigurationBuilder is as follows:
public static IConfiguration Configuration { get; set; } = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile(
$"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json",
optional: true)
.AddEnvironmentVariables()
.Build();
public IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new DryIocServiceProviderFactory(container: Container.GetContainer()))
.ConfigureServices((hostContext, services) =>
{
// <-- Here is where I'm using IOptions<AppSettings> dependency object -->
services.Configure<AppSettings>(Configuration.GetSection(nameof(AppSettings)));
})
.ConfigureContainer<Container>((hostContext, container) =>
{
// <-- the debugger shows right here, the IOptions<> stuff is in the container -->
var stuff = container.GetServiceRegistrations();
});
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
;
Configuration = builder.Build();
CreateHostBuilder(args: new string[] { }).Build();
Please refer to the sample project for the entire setup.
https://1drv.ms/u/s!AvdDo8v2RmDrjDeBRHfhkHH_kXbK?e=37GHDF
I get the following exception
Unable to resolve WpfPrismCore.ViewModels.MainWindowViewModel IsResolutionCall
from Container without Scope
with Rules with {AutoConcreteTypeResolution}
with Made={FactoryMethod=ConstructorWithResolvableArguments}
Where no service registrations found
and no dynamic registrations found in 0 of Rules.DynamicServiceProviders
and nothing found in 1 of Rules.UnknownServiceResolvers
at DryIoc.Throw.It(Int32 error, Object arg0, Object arg1, Object arg2, Object arg3) in D:\Dev\DryIoc\src\DryIoc\Container.cs:line 10684
at DryIoc.Container.TryThrowUnableToResolve(Request request) in D:\Dev\DryIoc\src\DryIoc\Container.cs:line 939
at DryIoc.Container.DryIoc.IContainer.ResolveFactory(Request request) in D:\Dev\DryIoc\src\DryIoc\Container.cs:line 918
at DryIoc.Container.ResolveAndCacheFactoryDelegate(Type serviceType, IfUnresolved ifUnresolved) in D:\Dev\DryIoc\src\DryIoc\Container.cs:line 256
at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, IfUnresolved ifUnresolved) in D:\Dev\DryIoc\src\DryIoc\Container.cs:line 230
at DryIoc.Resolver.Resolve(IResolver resolver, Type serviceType) in D:\Dev\DryIoc\src\DryIoc\Container.cs:line 5884
at Prism.DryIoc.Ioc.DryIocContainerExtension.Resolve(Type type)
at Prism.PrismApplicationBase.b__6_0(Object view, Type type)
at Prism.Mvvm.ViewModelLocationProvider.AutoWireViewModelChanged(Object view, Action`2 setDataContextCallback)
at Prism.Mvvm.ViewModelLocator.AutoWireViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Baml2006.WpfMemberInvoker.SetValue(Object instance, Object value)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
try add in ConfigureServices first line.
services.TryAddSingleton(typeof(IOptionsSnapshot<>),typeof(OptionsManager<>));
I've started using the dotnetzip from codeplex ...
I Downloaded it and referencing Ionic.ZIP.dll in my .net 4.5 application,
This is my main code...
using (ZipFile archive = new ZipFile(#"C:\Folder\ZipFileName.zip"))
{
archive.Password = "passwprd";
archive.Encryption = EncryptionAlgorithm.PkzipWeak;
archive.StatusMessageTextWriter = Console.Out;
archive.ExtractAll(#"C:\destinationFolder", ExtractExistingFileAction.Throw);
}
this code works fine in a console c# application, but i'm receiving the next error when I want to run my SSIS script....
en System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) en System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) en System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) en System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) en Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
Any Idea ?
I think the issue is related to the DLL references, At runtime the SSIS package read the added assemblies from three locations by default:
The Global Cache Assembly
The .Net Framework folder
The SQL Server DTS Assemblies folder
You can refer to the following link for more details (check both answers)
Creating a reference to a custom assembly from an SSIS Script Task - vb
I am using SSIS 12, SQL Server 2012, Visual Studio 2012 and .net 4.
My SSIS script task code(for sending mail):
// Introduction to the script task
/* The Script Task allows you to perform virtually any operation that can be accomplished in
* a .Net application within the context of an Integration Services control flow.
*
* Expand the other regions which have "Help" prefixes for examples of specific ways to use
* Integration Services features within this script task. */
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace ST_20fdf0b00e2949fda158e6680c127473
{
public void Main()
{
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("raihanuahmed#gmail.com", "password");
MailMessage msg = new MailMessage();
msg.From = new MailAddress("raihanuahmed#gmail.com");
msg.To.Add(new MailAddress("raihan.csse.aiub#gmail.com"));
msg.Subject = "AW2012 ETL Process Complite";
msg.Body = string.Format("{0} records loaded into DimProduct", 0);
smtp.Send(msg);
Dts.TaskResult = (int)ScriptResults.Success;
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}
}
After executing this email sending script, I am always getting
"DTS Script :Runtime Error"
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParams)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
I have uploaded my problem into Youtube here is the link:
DTS Script :Runtime Error
Here is my project link in Dropbox:
EmailScript
I have found the solution :) Many Many thanks to Mr.Nick.McDermaid ......
solution is :
Change account access for less secure apps https://support.google.com/accounts/answer/6010255
I am getting a error when trying to verify container.
The configuration is invalid. Creating the instance for type
SettingModel failed. The registered delegate for type SettingModel
threw an exception. Invalid URI: Invalid port specified.
It seems to be caused by ThemeManager which belongs to mahapps.metro dll I can't seem to get it to play nicely with Simple Injector.
public SettingModel()
{
ThemeColor = ThemeManager.AppThemes.Select(t => t.Name).ToList();
AccentColor = ThemeManager.Accents.Select(a => a.Name).ToList();
var currentSetting = ThemeManager.DetectAppStyle(Application.Current);
CurrentTheme = currentSetting.Item1.Name;
CurrentAccent = currentSetting.Item2.Name;
}
I slowly remove stuff and it got to the point where every where I used theme manager it was breaking. So I start taking out pieces until I got to the point where I kept getting xamlparseexception when I compile which is strange because my code complied before I put in the simple injector.
I followed the tutorial for WPF integration unless that is out dated. I really wanted to try simple injector but it isn't integrating nicely.
Update: Full exception
System.InvalidOperationException was unhandled
HResult=-2146233079
Message=The configuration is invalid. Creating the instance for type MainWindow failed. The registered delegate for type MainWindow threw an exception. Invalid URI: Invalid port specified.
Source=SimpleInjector
StackTrace:
at SimpleInjector.InstanceProducer.VerifyInstanceCreation()
at SimpleInjector.Container.VerifyInstanceCreation(InstanceProducer[] producersToVerify)
at SimpleInjector.Container.VerifyThatAllRootObjectsCanBeCreated()
at SimpleInjector.Container.VerifyInternal()
at SimpleInjector.Container.Verify(VerificationOption option)
at SimpleInjector.Container.Verify()
at Program.Bootstrap() in c:\Users\Work\Documents\Visual Studio 2012\Projects\AzurePeek\AzurePeek\Program.cs:line 35
at Program.Main() in c:\Users\Work\Documents\Visual Studio 2012\Projects\AzurePeek\AzurePeek\Program.cs:line 14
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: SimpleInjector.ActivationException
HResult=-2146233088
Message=The registered delegate for type MainWindow threw an exception. Invalid URI: Invalid port specified.
Source=SimpleInjector
StackTrace:
at SimpleInjector.InstanceProducer.GetInstance()
at SimpleInjector.InstanceProducer.VerifyInstanceCreation()
InnerException: System.UriFormatException
HResult=-2146233033
Message=Invalid URI: Invalid port specified.
Source=System
StackTrace:
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at MahApps.Metro.ThemeManager.get_AppThemes()
at AzurePeek.M
odel.SettingModel..ctor() in c:\Users\Work\Documents\Visual Studio 2012\Projects\AzurePeek\AzurePeek\Model\SettingModel.cs:line 24
at lambda_method(Closure )
at SimpleInjector.InstanceProducer.GetInstance()
InnerException:
UPDATE
After a discussion with #punker76, who is one of the colaborators of the MahApps.Metro library, we concluded that this exception happens because you are running that code out of the scope of a WPF application. Most likely because you are testing your configuration inside a unit test.
There are two things you can do here. Either you need to fool your test suite to think it runs as a WPF application or you will have to move the code that depends on MyApps out of the SettingModel's constructor.
As discussed with #punker76, when starting a WPF application, a call to new FrameworkElement() somehow ensures that the internal UriParser is able to parse pack:// uris (talk about weird hidden ugly scary dependencies).
The other option, which is my preference, is to make constructor's simple and resilient to failure. This means that any code that is not related to building up the object graph should be moved out of the constructor and should be done at runtime.
There are a lot of ways to do this, but a simple way to do this is by postponing the initialization of the properties of the SettingsModel or postponing the creation of SettingsModel itself, since it doesn't look like a service that should be maintained by your DI container at all.
Postponing the creation of SettingsModel is easy by introducing an abstraction that allows access to the settings at runtime:
public interface ISettingsProvider {
SettingsModel CurrentSettings { get; }
}
With the following implementation:
public class SettingsProvider : ISettingsProvider {
private readonly Lazy<SettingsModel> model = new Lazy<SettingsModel>(
() => new SettingsModel());
public SettingsModel CurrentSettings {
get { return this.model.Value; }
}
}
This can be registered as follows:
container.RegisterSingle<ISettingsProvider>(new SettingsProvider());
ORIGINAL ANSWER
The problem is unlikely to be caused by Simple Injector. There isn't anything special about Simple Injector's Verify() method. If you replace the call to Verify() with new SettingModel();, you will most likely see the same exception.
As a matter of fact, if you look at the source code of the MahApps.Metro.ThemeManager.AppThemes property, you'll see the following code:
var themes = new[] { "BaseLight", "BaseDark" };
_appThemes = new List<AppTheme>(themes.Length);
foreach (var color in themes)
{
var appTheme = new AppTheme(color, new Uri(string.Format("pack://application:,,,/MahApps.Metro;component/Styles/Accents/{0}.xaml", color)));
_appThemes.Add(appTheme);
}
return _appThemes;
If you look at the url that is supplied to the Uri constructor, you can understand why it throws an "Invalid URI: Invalid port specified" exception. If you run the following code in a console application, you will get the same error:
new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml");
So I have to conclude that there is a bug in the MahApps.Metro.ThemeManager.AppThemes property that is causing this. I'm wondering how you actually managed to get this working before, because I don't see a way to work around that bug. Did you happen to upgrade to a newer version of MahApps.Metro at the same time as you introduced Simple Injector?
I have come across a large issue that i am having that has suddenly come to light when i upgraded my Silverlight & Web Projects to versions 4 respectively.
Since doing this, all my WCF Services are Failing with the following Error message:
There was an error deserializing the object of type Anyboat.Admin.UserService.User. Unexpected end of file. Following elements are not closed: LastName, AuthenticateUserResult, AuthenticateUserResponse, Body, Envelope.
The StackTrace is:
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.UserServiceClientChannel.EndAuthenticateUser(IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.Anyboat.Admin.UserService.UserService.EndAuthenticateUser(IAsyncResult result)
at Anyboat.Admin.UserService.UserServiceClient.OnEndAuthenticateUser(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
I put a breakpoint in my SilverlightFaultBehaviour on the Response Message and this is the Envelope reponse i got back. Notice the Carriage return which is between *"\r\n"*
"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">\r\n <s:Header>\r\n <a:Action s:mustUnderstand=\"1\">urn:UserService/AuthenticateUserResponse</a:Action>\r\n <a:RelatesTo>urn:uuid:07cc1361-c74c-4449-b423-e982d2ac8e05</a:RelatesTo>\r\n </s:Header>\r\n <s:Body>\r\n <AuthenticateUserResponse>\r\n <AuthenticateUserResult xmlns:d4p1=\"http://schemas.datacontract.org/2004/07/AnyBoat.Web.Classes.DataObjects\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <d4p1:Active>true</d4p1:Active>\r\n <d4p1:EmailAddress>robbie#robbietapping.com.au</d4p1:EmailAddress>\r\n <d4p1:FirstName>Robbie</d4p1:FirstName>\r\n <d4p1:IsAdministrator i:nil=\"true\" />\r\n <d4p1:LastName>Tapping</d4p1:LastName>\r\n <d4p1:Password>xxxxxxxxx</d4p1:Password>\r\n <d4p1:UserID>2</d4p1:UserID>\r\n <d4p1:UserName>robbietapping</d4p1:UserName>\r\n </AuthenticateUserResult>\r\n </AuthenticateUserR
esponse>\r\n </s:Body>\r\n</s:Envelope>"
Can anyone tell me if there is away around this at all, i upgraded my VS2010 to SP1 where this has started to show itself.
Any Information or answers would be greatfully appreciated.
Thanks
EDIT
The Code that the Error Occurs on is:
public Anyboat.Admin.UserService.User EndAuthenticateUser(System.IAsyncResult result) {
object[] _args = new object[0];
Anyboat.Admin.UserService.User _result = ((Anyboat.Admin.UserService.User)(base.EndInvoke("AuthenticateUser", _args, result)));
return _result;
}
Which serialization type do you use at services side? I'm pretty sure that you use some custom serialization. "\r\n" problem is pretty common and it occurs when you're trying to deserialize not well formed xml received from service.
So I see two ways:
The most preferable way. Check the serializer at service side. It's obvious that service returns xml in wrong format.
Add IClientMessageInspector to client and remove special symbols from response before deserialization.