App.config in Service needs to point to another config with rules

Topics: Building and extending application blocks, Caching Application Block , Cryptography Application Block, Data Access Application Block, Enterprise Library Core, Exception Handling Application Block, General discussion, Logging Application Block, Policy Injection Application Block, Pre-release discussions, Security Application Block, Validation Application Block
Jan 12, 2010 at 7:21 PM

Hello,

Is there anyway possible to have my App.config in my windows service point to another config; lets say its called Validation.App.config, that contains rule sets needed for validation? Note: the Validation.App.config lives outside my solution that houses my service, the App.config which contains localhost info and etc, lives in the solution that houses my windows service. The reason I am asking is because a short while ago I posted on this site about any issue pertaining to my my Validation.App.config not being used when I make a validate call.  I thought if there was a way to point directly to the config I needed to uitilize I could solve my issue. Here is a link to my previous posting http://entlib.codeplex.com/Thread/View.aspx?ThreadId=80562

Please help if you can, thanks!

Jan 12, 2010 at 8:20 PM

Additionally, I tried following the instructions give in this example http://www.pnpguidance.net/Post/EnterpriseLibraryExternalConfigurationSourceApplicationBlockSettings.aspx

However, after doing so I am now getting a Fault exception stating "The creator of this fault did not specify a Reason". I am not able to call this particular method in my windows service that deals with validation; using the config discussed earlier, without getting this exception. Does anyone else have this problem?

Jan 13, 2010 at 1:53 AM

I'm not sure what happened there but the best way would be to debug and get the exact exception which occurred.  By the way there's another approach to this, you may want to try it out - http://blogs.msdn.com/tomholl/archive/2006/04/02/entlib2externalconfig.aspx.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 13, 2010 at 5:55 PM
Edited Jan 13, 2010 at 6:13 PM

Hello Sarah,

I found an article which outlines exactly what my issue is. http://kunal.org/wordpress/?p=91

The only difference is that my method has an object; class (JobInfo), that I am passing a parameter, e.g.

[OperationContract]

[FaultContract(typeof(ValidationFault]

string Validate(int pJobType, JobInfo pJobInfo);

But the issue is the same as the one found in the link provided.

Please let me know if this makes the issue clearer, thanks.

Jan 14, 2010 at 8:52 AM

Hi,

Yes, I have successfully repro your error. I'm also not really sure why it throws a exception like that, i'll investigate it further. But even there is that exception, you'll get the validation messages from the fault. Have you tried looking into the details of the validationfault?

 

            try
            {
                client.GetFoo("Bar");
            }
            catch (FaultException<WCF.ValidationFault> ex)
            {
                WCF.ValidationFault d = ex.Detail;
                foreach (ValidationDetail item in d.Details)
                {
                    Console.WriteLine(item.Message + "  " + "Parameter name : " + item.Tag);
                }
            }

Valiant Dudan
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 15, 2010 at 7:53 AM

The message "The creator of this fault did not specify a Reason" is created by entlib but as Valiant has illustrated, you can get the validation results from the Details property.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com