Caching Application block having problem when used with WCF under IIS5.1

Topics: Caching Application Block
Nov 12, 2008 at 2:20 PM
Hi,

I am having the problem with caching application block.
When I run the application (WCF Service) using console application caching working perfectly.

When I hosted the WCF service under IIS5.1 server I am having this problem.
Environment: VS2008, .NET3.5, Windows XP, IIS5.1, WCSF (Client)
Here is my configuration file:

<configuration>
<configSections>
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings,Microsoft.Practices.EnterpriseLibrary.Caching" />
</configSections>
<cachingConfiguration defaultCacheManager="Default Cache Manager">
<backingStores>
<add name="inMemory"
type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching" />
</backingStores>

<cacheManagers>
<add name="Default Cache Manager"
expirationPollFrequencyInSeconds="60"
maximumElementsInCacheBeforeScavenging="1000"
numberToRemoveWhenScavenging="10"
backingStoreName="inMemory" />
<add name="Loading Scenario Cache Manager"
expirationPollFrequencyInSeconds="60"
maximumElementsInCacheBeforeScavenging="1000"
numberToRemoveWhenScavenging="10"
backingStoreName="inMemory" />
</cacheManagers>
</cachingConfiguration>
</configuration>

I am creating instance inmy Service Contructor:
CacheManager cacheManager;
public DistributionService()
{
connString = Settings.CONNECTIONSTRING;
connection = new OracleConnection(connString);
cacheManager = CacheFactory.GetCacheManager("Loading Scenario Cache Manager");
resMgr = new ResourceManager(typeof(DistributionServiceResource));
}
I am accessing the services (WCF) using WebClientSoftwareFactory. I placed the Common.dll & Cahcing in GAC as well.

Here is my Error Stack at client side..

"Object reference not set to an instance of an object."
at Microsoft.Practices.EnterpriseLibrary.Caching.CachingConfigurationView.GetCacheManagerData(String cacheManagerName)
at Microsoft.Practices.EnterpriseLibrary.Caching.CacheManagerCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)
at Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp[TTypeToBuild](IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, String id, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.LocatorNameTypeFactoryBase`1.Create(String name)
at Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager(String cacheManagerName)
at DistService.DistributionService..ctor()
at CreateDistService.DistributionService()
at System.ServiceModel.Dispatcher.InstanceBehavior.InstanceProvider.GetInstance(InstanceContext instanceContext, Message message)
at System.ServiceModel.Dispatcher.InstanceBehavior.GetInstance(InstanceContext instanceContext, Message request)
at System.ServiceModel.InstanceContext.GetServiceInstance(Message message)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
What was the problem in my configuration fille?
Nov 13, 2008 at 1:24 AM
Edited Nov 13, 2008 at 2:12 AM
Does it throw any exception if you exclude the code for caching? Just want to verify if this is an issue in caching itself or if there's other concern regarding hosting wcf in iis5.1.



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

Nov 17, 2008 at 3:29 AM
Hi,

Here is the sample I created for this error. Attachments contains 2 files,
1st attachment is server to put under IIS. (CalculatorService.zip) --Give the virtual name as CalculatorService, because this name I used in my client.
2nd is Client I am accessing from class library consumed in web. (CalculatorConsumer.zip)

While setting the client & server if you find any difficulty pl let me know.

I am not tested after removing caching from my sample, tomorrow I'll let you know. Meanwhile can you look into this sample?
Thanks & Regards
Ramesh Tamma | Wipro Technologies

________________________________

From: AvanadeSupport [mailto:[email removed]
Sent: Wed 12/11/2008 8:25 PM
To: Ramesh Tamma (WT01 - ENERGY & UTILITIES)
Subject: Re: Caching Application block having problem when used with WCF under IIS5.1 [entlib:39767]



From: AvanadeSupport

Does it throw any exception if you commented the code for caching? Just want to verify if this is an issue in caching itself or if there's other concern regarding hosting wcf in iis5.1.



Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
[email removed]


Read the full discussion online <http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=39767&ANCHOR#Post132168> .

To add a post to this discussion, reply to this email ([email removed] <mailto:[email removed]?subject=[entlib:39767]> )

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe <http://www.codeplex.com/site/discussions/thread/unsubscribe/39767> on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com
Nov 17, 2008 at 3:53 AM
Thanks, I'll check that out.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Nov 17, 2008 at 4:02 AM
The CalculatorService needs the log4net reference for the ILog interface and LogManager class.  Could you send me the project or just these two so I could run it.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Nov 17, 2008 at 2:48 PM
Hi ,

Either you can remove reference of Log4net and proceed further or attached log4net.dll you can use.

Thanks in advance,

Thanks & Regards
Ramesh Tamma | Wipro Technologies

________________________________

From: AvanadeSupport [mailto:[email removed]
Sent: Sun 16/11/2008 11:02 PM
To: Ramesh Tamma (WT01 - ENERGY & UTILITIES)
Subject: Re: Caching Application block having problem when used with WCF under IIS5.1 [entlib:39767]



From: AvanadeSupport

The CalculatorService needs the log4net reference for the ILog interface and LogManager class. Could you send me the project or just these two so I could run it.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
[email removed]
<mailto:[email removed]?subject=Enterprise Library Forum Question>

Read the full discussion online <http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=39767&ANCHOR#Post132976> .

To add a post to this discussion, reply to this email ([email removed] <mailto:[email removed]?subject=[entlib:39767]> )

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe <http://www.codeplex.com/site/discussions/thread/unsubscribe/39767> on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com
Nov 18, 2008 at 3:00 AM
Yup, I just removed the reference to log4net.  I'm still currently setting it up under iis and I'm having trouble browsing to CalculatorService.svc, it's giving me a configuration error, probably due to permissions.  I'll let you know what I can find out as soon as I have it running.  By the way, did you already tried to remove the lines of code relating to caching?  If it throws an exception, I'll suggest you resolve that first and see if it will throw the same exception after adding the codes for caching again.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Nov 18, 2008 at 3:13 AM
Hi,

I tried without caching in my constructor. It's working. So I think problem with caching application block..

Yes, you have to remove Anonymous access and make it IntegratedWindowsAuthentication.

Thanks & Regards
Ramesh Tamma | Wipro Technologies

________________________________

From: AvanadeSupport [mailto:[email removed]
Sent: Mon 17/11/2008 10:00 PM
To: Ramesh Tamma (WT01 - ENERGY & UTILITIES)
Subject: Re: Caching Application block having problem when used with WCF under IIS5.1 [entlib:39767]



From: AvanadeSupport

Yup, I just removed the reference to log4net. I'm still currently setting it up under iis and I'm having trouble browsing to CalculatorService.svc, it's giving me a configuration error, probably due to permissions. I'll let you know what I can find out as soon as I have it running. By the way, did you already tried to remove the lines of code relating to caching? If it throws an exception, I'll suggest you resolve that first and see if it will throw the same exception after adding the codes for caching again.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
[email removed] <mailto:[email removed]?subject=Enterprise Library Forum Question>

Read the full discussion online <http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=39767&ANCHOR#Post133289> .

To add a post to this discussion, reply to this email ([email removed] <mailto:[email removed]?subject=[entlib:39767]> )

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe <http://www.codeplex.com/site/discussions/thread/unsubscribe/39767> on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com
Nov 18, 2008 at 3:20 AM
I already did that. Where did you place your solution, is it under inetpub/wwwroot?  When I point my virtual directory in there, I get a different error, it's complaining about the service attribute type, CalculatorService.Calculator.  If in other directory, I'm getting the configuration error.  Could you give me the exact steps?  I might be missing  or just forgetting something  here.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Nov 18, 2008 at 3:49 AM
Edited Nov 18, 2008 at 6:20 AM
I found this workitem (http://www.codeplex.com/entlib/WorkItem/View.aspx?WorkItemId=14241), the one you updated.  It may be the same issue since both are occuring in the 3.1 version, could you repro it in the 4.1 version?  I'll try as soon as I have it running. 

Another thing, did you have other versions of entlib previously installed?  There may be just an inconsistency in dll referencing.  Make sure you're referencing the correct ones.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Nov 18, 2008 at 6:32 AM
I should've noticed and asked you before, you have this line of code, 

cacheManager = CacheFactory.GetCacheManager("Loading Scenario Cache Manager");

but you don't have the Caching Application Block defined in your configuration.



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




 



 

 

Nov 18, 2008 at 2:54 PM
Hi,

Sorry for that, I forgot to send you the app.config file, pl find the attached app.config which is I am using in my application.
If I remove/comment the cache initialization, then the service is returning without any error.
Thanks & Regards
Ramesh Tamma | Wipro Technologies

________________________________

From: AvanadeSupport [mailto:[email removed]
Sent: Tue 18/11/2008 1:32 AM
To: Ramesh Tamma (WT01 - ENERGY & UTILITIES)
Subject: Re: Caching Application block having problem when used with WCF under IIS5.1 [entlib:39767]



From: AvanadeSupport

I should've noticed and asked you before, you have this line of code,

cacheManager = CacheFactory.GetCacheManager("Loading Scenario Cache Manager");

but you don't have the Caching Application Block defined in your configuration.



Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
[email removed] <mailto:[email removed]?subject=Enterprise Library Forum Question>













Read the full discussion online <http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=39767&ANCHOR#Post133316> .

To add a post to this discussion, reply to this email ([email removed] <mailto:[email removed]?subject=[entlib:39767]> )

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe <http://www.codeplex.com/site/discussions/thread/unsubscribe/39767> on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com
Nov 19, 2008 at 5:47 AM
Edited Nov 19, 2008 at 9:23 AM
Hi, I can now run your application but I wasn't able repro the error you're getting.  I was wondering why you have the Caching Application Block configured in an app.config file.  What I did is to just add the CAB in the CalculatorService's web.config (added a default cache manager and the Loading Scenario Cache Manager).  I noticed that you used the CalculatorService project as reference to your CalculatorClientService project.  If you're hosting the service under iis, make sure to use a service reference.  I have the exact environment as yours, by the way.


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

Nov 25, 2008 at 1:50 PM
Hi,

That solves my problem after placing all my config entries to web.confid instead of app.config. Initially in dev mode we created one console app, to access the WCF services, but later I though it'll read all my entries from my app.config. But my assumption is wrong...thanks a lot....


Thanks & Regards
Ramesh Tamma | Wipro Technologies

________________________________

From: AvanadeSupport [mailto:[email removed]
Sent: Wed 19/11/2008 12:47 AM
To: Ramesh Tamma (WT01 - ENERGY & UTILITIES)
Subject: Re: Caching Application block having problem when used with WCF under IIS5.1 [entlib:39767]



From: AvanadeSupport

Hi, I was finally able to run your application and I didn't repro your error. I was wondering why you have the Caching Application Block configured in the app.config. What I did is to just add the CAB in the CalculatorService's web.config. A default cache manager and the Loading Scenario Cache Manager. I noticed you used the CalculatorService project as reference to your CalculatorClientService project. If you're hosting the service under iis, make sure to use a service reference. I have the exact environment as yours, by the way.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
[email removed] <mailto:[email removed]?subject=Enterprise Library Forum Question>


Read the full discussion online <http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=39767&ANCHOR#Post133563> .

To add a post to this discussion, reply to this email ([email removed] <mailto:[email removed]?subject=[entlib:39767]> )

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe <http://www.codeplex.com/site/discussions/thread/unsubscribe/39767> on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com