I have some misunderstandings about using RouteTable.Routes.GetReadLock()when overriding a method GetVirtualPathin a user class Route.
According to MSDN Docs
There are two scenarios in which you do not need to call GetReadLock: Public methods of the RouteCollection class, such as GetVirtualPath and GetRouteData strong> call GetReadLock internally. Therefore, you do not have to explicitly call GetReadLock when you call the public RouteCollection class method to retrieve data from the collection.
Since I redefine GetVirtualPathand GetRouteDatait seems that there will be no
internal calls if I do not.
In .NET 3.5, the following line runs smoothly:
using (RouteTable.Routes.GetReadLock())
{
}
In .NET 4.5, I get this error:
Recursive read lock acquisitions not allowed in this mode.
So the question is:
Do I have to activate dark magic to block it, or has Microsoft executed the ReadLock () script in .NET 4.5?
Thanks for sharing the experience!
source
share