I need caching facility which should work from both WCF and from within an ASP .NET app. I have seen:
System.Web.Caching.Cache which is not usable from WCF (as I understand it is usable only if service is hosted in IIS, which is not always the case)
System.Runtime.Caching which is usable from both of them, but only available from .NET 4, but our .NET version is 3.5.
Any suggestions?
You can absolutely use System.Web.Caching.Cache outside of IIS. Just add a reference to System.Web and away you go - it is absolutely not a feature of IIS.
There were issues in .NET 1.0 and 1.1 but apparently not in 2.0 and upwards - see this Knowledge Base article.
But like Davide Piras I would also recommend considering AppFabric to share the cache between your two applications, if that would be useful. I'm not sure what you mean by "my requirement cannot afford something like AppFabric" - by "afford" are you talking about performance, memory, or what? Whilst AppFabric is designed to be used on a cache server it does not by any means require dedicated hardware, you can run the service on the same box as your application if you need to.
new solution use Windows Server AppFabric Caching
https://github.com/geersch/AppFabric
http://dotnet.dzone.com/articles/caching-wcf-services-part-2
http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/AAP314
***2.in .NET 1.0 and 1.1 http://support.microsoft.com/kb/917411
Related
I remark that for my project I really need often something to manage a cache of our data(for data access performance, for offline work, ...).
So I was asking me if there was something which could respond to my needs or if I will have to create my own framework for this. It can be only a "Core" which furnish the logic, and we have to implement the business part.
My needs are:
Data sources can be WCF/Web service/...(this part should be implemented on every new project
It has to manage an store of data
available
This store must be refreshed regularly by polling the service
This store can be persistent(write cache on disk for the next start)
The framework must allows modifications, online and offline,
asynchronous and synchronous(if online)
It has to run with c# 4.0
If the local cache store can be accessed through LINQ, it would be great(like directly through a list
The concurrency has to be managed(or offer us a way to manage it)
The use/configuration of this framework should be shorter than implement myself it every time
So here we are, do you know a tools which can fits into my query?
Somebody tell me that MS entreprise library should have something like that, but I didn't found anything.
Thank you!
You could have a look at
Windows Server AppFabric. It used to be called 'velocity'.
It is a distributed in-memory application cache platform for
developing scalable, high-performance applications.
Otherwise, the Enterprise Library Caching Application Block you're talking about is here: The Caching Application Block however, this page says:
Caching Application Block functionality is built into .NET Framework
4.0; therefore the Enterprise Library Caching Application Block will
be deprecated in releases after 5.0. You should consider using the
.NET 4.0 System.Runtime.Caching classes instead of the Caching
Application Block in future development.
And actually, the System.Runtime.Caching Namespace is a very good building block to build on if you're going to write something by yourself. I don't think it implements the notion of distributed cache, that's why Windows Server AppFabric exists.
Now, there is also non-Microsoft technologies available in the .NET space. Have a look a memcached and .NET implementation or usage:
Is there a port of memcache to .Net?
Memcached with Windows and .NET
You also have commercial packages available, like NCache (I'm not affiliated). I don't know what they provide, but it's also probably interesting to have a look at it, just to be aware what they provide, to ensure you don't miss any feature you'd need later one.
Have a look at SharedCache.
I am trying to implement caching in .Net such that the cached data is accessible not just by an application that may run multiple times on the same machine but by other types of applications that may run on the machine. They could be windows services, web services, win forms etc.
I have looked at System.Runtime.Caching (because Enterprise Application Blocks Caching is going to become obsolete) as a means to achieve this. The default MemoryCache is insufficient to achieve this as I don't believe that it work across app domains.
Is there a way I can implement the kind of caching I am looking for or is there a caching dll of some sort (must be free) that I can use to achieve my goal?
Is there a way to use System.Runtime.Caching with IsolatedStorage scoped to MachineLevel?
I've looked at memcache too and can't use it because we need this to run on windows machines. I started looking at SharedCache (http://www.codeproject.com/KB/web-cache/AdvanceCaching.aspx) and am curious about the pitfalls it has as well.
Thanks.
-- Revision 1 --
I think the optimal solution for me would use the Caching object to a Memory Mapped File (http://msdn.microsoft.com/en-us/library/dd997372.aspx). So the question I have now is whether anyone has done that with the System.Runtime.Caching object. There must be a way to extend it if necessary...examples of how to do so would also be much appreciated.
You're looking for AppFabric Cache. It's a Windows Server technology from Microsoft. It's free.
I should also say that if you like memcached, you can use that on Windows as well, and in fact Microsoft Azure team members used to recommend it, before the AppFabric caching was available on Windows Azure.
Have you evaluated Microsoft Velocity? Take a look - I believe if you are not okay with using the AppFabric Cache, this should work out for you:
http://msdn.microsoft.com/en-us/magazine/dd861287.aspx#id0450004
For simple client based caching, you can look at file based caching.
In the Windows Features control panel applet, under Internet Information Services → World Wide Web Services → Application Development Features, there are two options: ".NET Extensibility" and "ASP.NET".
What is the difference between these two options? If I'm developing simple ASP.NET web applications / services, is there any need for the .NET Extensibility option?
I Google'd the terms, and came up with this link:
http://forums.iis.net/t/1146942.aspx
This link confuses me, because the response (from a supposed Microsoft employee) says that to test for .NET Extensibility, you create a simple ASPX page, and try to load it. That seems (to ME) more like a test for the ASP.NET option.
Any clues?
In versions of IIS prior to 7.0, the ASP.NET pipeline was separate from the web server's request processing pipeline. The web server's functionality was usually extended via ISAPI filters and extensions.
However, in IIS 7.x they are more tightly integrated, which allows for the server to be extended using managed code, via the ASP.NET extensibility APIs. Two primary ways this can be done are via modules and handlers, which are quite similar to ISAPI filters and extensions respectively.
The APIs of interests are:
System.Web.IHttpModule
System.Web.IHttpHandler
System.Web.IHttpAsyncHandler.
You can read more about how to extend the server in the articles below.
http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis-7/
http://learn.iis.net/page.aspx/170/developing-a-module-using-net/
http://msdn.microsoft.com/en-us/magazine/cc164128.aspx#S4
This site talks about .Net extensibility in relation to IronPython: http://www.asp.net/learn/whitepapers/ironpython
You might want to review more info at this site: http://aspnetextensibility.com/
Assuming your developing asp.net sites in c# or vb.net then you will need the ASP.Net support. To sum up, it's probably one of those things you'll be able to define when you actually need the .Net Extensibility option installed.
However, if you really want to know: .Net Extensibility is an IIS 7 feature which brings the ability to extend IIS 7 via the runtime extensibility model into the core server product.
Building "regular" sites (whatever those are), don't worry about it. Needing to get down and dirty by modifying the pipeline through modules or handlers? Install it. Either way, you are still going to need the regular ASP.Net support installed.
With regards to what the MS guy said about the Hello World file.. Ignore that, he didn't read the full question...
It's a very simple question, but I wasn't able to find exact answer.
Do you need to install anything extra besides .Net Framework 3.5 and IIS7 to run ASP.Net MVC applications?
Hope it will be useful to other people too.
If you don't use any third party libraries, then no.
The host has to have the .NET 3.5 SP1 installed.
However you need to be aware of the trust level issues. Most shared hosts run in medium trust mode. Although this will suffice for the MVC itself, it may not for your other code. If you use reflection for example, you will need the full trust enabled.
Basically this simple code may get you into trouble:
object something = 5;
if (something is int)
{
// Do something
}
Check your code and choose the host wisely.
I wrote a windows service in C# that does some functionality (a public method) after reading a file at regular intervals. Is it possible for me to use this functionality from another C# application ? If possible, please give a solution based on .net 2.0 as well as .net 3.0
Thanks
The cleanest option would be to write that functionality in a separate assembly (dll) that you use from both the service and the second .NET application.
You can reference the service assembly (even if it is an exe, in VS2008 at least) - but it seems a little overkill.
If you want to execute the method in the context of the running service, then you'll need some IPC (perhaps WCF or sockets).
Just expose it using WCF and call it from your other app. They are in different processes so you have to use IPC
Depends hwo you want to reuse.
If you want to access the running window service then expose then functionality via WCF. Of you want to just use the code then place it in a assembly and reference from another project/program.
I'd say the .net 2.0 and 3.0 would be the same from the latter but since .net 2.0 fmk does not have WCF I'd suggest a windows remoting endpoint for the earlier if you're using .net 2.0 only or WCF as I stated.