Castle remoting sample - client throwing exception - castle-windsor

I am using the sample from castle # http://old.castleproject.org/container/facilities/trunk/remoting/containersconnected.html for "Scenario: Using the container on both endpoints and use the container components"
The only update I have made to this is one line in the config files from type="Castle.Facilities.Remoting.RemotingFacility, Castle.MicroKernel"
to
type="Castle.Facilities.Remoting.RemotingFacility, Castle.Windsor" as suggested by Mauricio in question Castle remoting facility not working
I also updated the references in both the client and server to use latest castle dlls. The server starts up successfully but the client does not. I get the following exception on the client:
Could not set up component 'remote.console.component'. Type 'System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' does not implement service 'Example.Shared.IRemoteConsole, Example.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Any suggests on what I am doing wrong?
The following is the client config file
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/>
</configSections>
<castle>
<facilities>
<facility id="remote.facility"
type="Castle.Facilities.Remoting.RemotingFacility, Castle.Windsor"
baseUri="tcp://localhost:2133"
isClient="true"
remoteKernelUri="tcp://localhost:2133/kernel.rem"
remotingConfigurationFile="RemotingTcpConfigClient.config">
</facility>
</facilities>
<components>
<component
id="remote.console.component"
service="Example.Shared.IRemoteConsole, Example.Shared"
type="System.Object, mscorlib"
remoteclient="component"/>
</components>
</castle>
</configuration>

Replace:
<component
id="remote.console.component"
service="Example.Shared.IRemoteConsole, Example.Shared"
type="System.Object, mscorlib"
remoteclient="component"/>
with:
<component
id="remote.console.component"
type="Example.Shared.IRemoteConsole, Example.Shared"
remoteclient="component"/>

Related

code first -The provider did not return a ProviderManifestToken string

I wrote a windows form solution with 2 layers; one is DataAccess and the other is windows form.
I use Code first. If DataAccess Layer runs in the application console, there is no problem with the db. Create the schema and insert the data.
However, when I run the solution with Windows Form as the initial project and refer to DataAccess as a dll, I cannot build the database. It throws an exception.
I think that the app.config file is the problem, but if I copy the app.config file of DataAccess project to the windows form, it does not resolve the problem.
the config file of DataAcces layer:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
the exception:
"first exception for 'System.Data.Entity.Core.ProviderIncompatibleException' in EntityFramework.dll
Aditional Information: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct."
Inner Exception:
{"The provider did not return a ProviderManifestToken string."}
The problem could be due to Error in connection string
or in my case it was that
SQL server service was not running
manually start the SQL service through SQL SERVER COnfiguration Manager
after a long deep search, i found that solution was "clean the solution".

Enterprise Library 6.0 - exceptional handling block-The configuration section for Exception Handling cannot be found in the configuration source

we are using enterprise library 6.0- exceptional handling block and configuration console for defining policy.
The following code has been generated in app.config file for the defined policy
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<exceptionHandling>
<exceptionPolicies>
<add name="DataAccessPolicy">
<exceptionTypes>
<add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="ThrowNewException">
<exceptionHandlers>
<add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
exceptionMessage="An occured in the data
access layer.
Please Contact the
Admin with Error Id { }."
replaceExceptionType="Mindtree.Azure.PaymentGatewayExceptionHandler.DataAccessException, Mindtree.Azure.PaymentGatewayExceptionHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
</exceptionPolicies>
</exceptionHandling>
</configuration>
I have the following code in my catch block, i am defining manager using configuration source factory and setting the exception manager
IConfigurationSource config = ConfigurationSourceFactory.Create();
ExceptionPolicyFactory factory = new ExceptionPolicyFactory(config);
ExceptionPolicy.SetExceptionManager(factory.CreateManager())
bool rethrow = ExceptionPolicy.HandleException(ex,"DataAccessPolicy");
if(rethrow)
throw;
DataAccessPolicy is defined in the app.config file which uses the repalce handler
but the following error is thrown when debugging
The configuration section for Exception Handling cannot be found in the configuration source.
Any Help would be appereciated. Thanks in advance

Linqpad Error with EF DbContext: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception

I happily run LinqPad 4.47.02 on a Win7 machine. I tried to add a EF5/dbContext connection. I choose my assembly, the class within the assembly and such assembly's config file. When I add the connection, i get this error:
The type initializer for 'System.Data.Entity.Internal.AppConfig' threw
an exception.
My app.config contains this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider"
invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
</DbProviderFactories>
</system.data>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="FipavContextContainer" connectionString="metadata=res://*/FipavContext.csdl|res://*/FipavContext.ssdl|res://*/FipavContext.msl;provider=MySql.Data.MySqlClient;provider connection string="server=127.0.0.1;User Id=root;database=fipavmanagerdb"" providerName="System.Data.EntityClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
</configuration>
I tried to comment the tag in configfile as suggested here but i get the same error.
As a side note, the connection worked and I have many saved linqpad queries. When I try to load and run one of them, linqpad crashes with no additional info.
What am I doing wrong?
Thank you,
F.
(weird) SOLUTION:
I tried moving the <configSections> tag just before <system.data> tag and the error flied away
As per msdn article for configSections element:
If this element is in a configuration file, it must be the first child element of the configuration element
I believe that one of the reasons is that this element defines handlers to handle custom sections in the config so if it is first you don't need to read parse config multiple time to handle a case where a custom section is defined before the handler for this section is defined.

Report Viewer Web Control Version 10 Gives Error Despite Set Up Correctly

Reports are deployed and working, verified in Report Manager.
My application is an MVC2 app with my report on its own aspx page. This page worked with version 8 of the report viewer control, but we moved to new servers, upgraded sql server, and are trying to update our website to match.
The servers are Windows Server 2008 with IIS 7.5.
I am testing in both chrome and IE 9.
Despite my best efforts, I still get this error:
Report Viewer Configuration Error
The Report Viewer Web Control HTTP Handler has not been registered in
the application's web.config file. Add <add verb="*"
path="Reserved.ReportViewerWebControl.axd" type =
"Microsoft.Reporting.WebForms.HttpHandler,
Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" /> to the system.web/httpHandlers
section of the web.config file, or add <add
name="ReportViewerWebControlHandler" preCondition="integratedMode"
verb="*" path="Reserved.ReportViewerWebControl.axd"
type="Microsoft.Reporting.WebForms.HttpHandler,
Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" /> to the system.webServer/handlers
section for Internet Information Services 7 or later.
But, I've already done this. in fact, I even read this from MSDN:
To use IIS 7.0 in Integrated mode, you must remove the HTTP handler in system.web/httpHandlers. Otherwise, IIS will not run the application, but will display an error message instead.
Just to be safe, I tried a combo of neither while adding the handler into IIS directly, just the web server http handler in my config, just the http handler in my config, and both.
Let's start with my web.config
<configuration
<system.web>
<httpRuntime maxQueryStringLength="4096" />
<compilation targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
</compilation>
</system.web>
<system.webServer>
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
</configuration>
I have the assemblies, the build provider, and the handler. What else could be wrong?
I found a quick and dirty workaround - to your web config add this:
<location path="Reserved.ReportViewerWebControl.axd">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
I saw in fiddler that for some reason when page requested Reserved.ReportViewerWebControl.axd instead of getting HTTP 200 response server would send 302 - moved to login.aspx?returnurl="Reserved.ReportViewerWebControl.axd. So allowing all users to the handler path solves the problem.
I thought its ReportViewer Rendering Issue on IIS7
I have manually mapped my reportviewer handle to IIS7 like this:
•Open Internet Information Services (IIS) Manager and select your Web application.
•Under IIS area, double-click on Handler Mappings icon.
•At the Action pane on your right, click on Add Managed Handler.
•At the Add Managed Handler dialog, enter the following:
Request path: Reserved.ReportViewerWebControl.axd
Type: Microsoft.Reporting.WebForms.HttpHandler
Name: Reserved-ReportViewerWebControl-axd
•Click OK.
also changed by web config by adding
Still mine's not working. I thought the above solution would help others.
I have tries this by removing unwanted mvc assemblies from asp.net project. So the simple solution was to remove WebMatrix.*.dll from Bin folder in web project as that belongs to mvc framework.

Programmatically configure an EntLib CAB CacheManager

Currently I'm having to include a significant chunk of XML in the app.config to get the CAB CacheManager going and I'd rather hide the configuration away in my code.
Is there any way to programmatically configure an Enterprise Library Caching Application Block's CacheManager?
why don't you use configSource attribute in your web.config to move to another config file the CAB configuration?
For Example:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
....
</configSections>
<cachingConfiguration configSource="Config\Caching.config" />
And then, in Config\Caching.config:
<?xml version="1.0" encoding="utf-8" ?>
<cachingConfiguration defaultCacheManager="DefaultCacheManager">
<cacheManagers>
<add name="DefaultCacheManager"
expirationPollFrequencyInSeconds="60"
maximumElementsInCacheBeforeScavenging="1000"
numberToRemoveWhenScavenging="10"
backingStoreName="Null Storage"
type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
..
As far as I know, you can use a separate config file for each configSection in your web.config
s.