outofmemory Exception for Microsoft.Web.RedisSessionStateProvider if using obfuscated libraries - redis

I want to use the Microsoft.Web.RedisSessionStateProvider as a session cache provider for an asp.net application. I have to use some obfuscated libriares in my application. Once I add them, I get an out-of-Memory exception. The Cache works if I remove the references to those libraries. The exception occurs immediately after global.asax application_start. Maybe directly before or on session_start.
<sessionState mode="Custom" customProvider="LocationNewsCache"> <providers>
<add name="LocationNewsCache" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="link to AWS ElastiCache"
port="6379" accessKey="" ssl="false" throwOnError="true"/> </providers> </sessionState>
the error marks the "add Name" line as red and states it as System.OutOfMemoryException

Do you have any implementation in your global.asa? Post the code here! Do you connection with Redis Server is ok? Change provider version Microsoft.Web.Redis.RedisSessionStateProvider.

Related

problem when publishing asp.net core project on a server

I'm implementing asp.net core project. I published my project into a package and set it on a main server, but, the database was set on another server. To do that, in the part of connection string of appsetting file, I just changed the server name and database name and when running the project I confront with the following error:
I appreciate if anyone can suggest me a solution for it.
This error indicates that an exception has occurred in your project, but since it is not a development environment, it is impossible to show you the real error message.
If you want to get the real error information, you can try to change the value of the ASPNETCORE_ENVIRONMENT variable from Production or other to Development in web.config file, and then refresh to see the real error information.
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
For more details, please refer to this discussion.

Umbraco suddenly login failed for user

I'm currently using the CMS Umbraco for my website to handle my blog. While suddenly the login won't work for any user.
UmbracoTracelog
Event Id: 0, state: Login attempt failed for username test from IP
address 127.0.0.1
I've checked my MSSQL where all instances are running and connecting
correctly to my project.
I've tried the UmbracoAdminReset.dll but it doesn't make any
difference.
I've tried to manually change the password in the MSSQL Umbraco users
table with the same login attempt failed error
I've tried to login on different user and still gets the same error
I've built i have restarted the computer but the error still applies, this worked earlier today, All i have done is just working with Disqus comment API on their website.
I've noticed in my Web.config that i have errors in (I manually replaced the PublicKeyToken here with *******)
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=***************" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
Invalid module qualification: Failed to resolve assembly System.Web.Providers
Cannot Resolve symbol DefaultSessionStateProivder
The website runs fine, I get to the login page, I just cannot login because I get Login attempt failed error.
EDIT:
In my Errorlist i can see 28 messages that says:
Could not find schema information for element __
UmbracoConfiguration
security
settings
and 25 more with the same.
It seems like you are missing the DLL for 'System.Web.Providers' OR you are using a different version.
If you publish from Visual Studio, ensure you have set 'CopyLocal' to TRUE if your project references this DLL.
You could also just try to FTP the missing file up to your hosting account.
Let me know how it goes.
Regards
Craig

mini profiler WCF

I am trying to use mini profiler with WCF.
I keep getting a 404 error:
http://website/mini-profiler-resources/results
There are no results being returned.
I am using two versions of the mini profiler. The NUGET version which doesn't include support for WCF works just fine.
I downloaded the git version so that I can use the WCF integration.
I note that if I run the test project included in the sources 'Sample.Mvc' the same error occurs when the home page is executed, but not for some of the links. I cannot seem to get results for any of my own web site pages. The same 404 occurs.
I have downloaded the master version. I am using .NET 4.0 and studio 2010.
I have the following in the config file, I have tried with and without the handlers.
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
I am definitely calling the start and stop methods.
StackExchange.Profiling.MiniProfiler.Stop();
I have read this: MvcMiniProfiler results request giving 404 in Asp.Net MVC app
It did not help.
I have found a clue as to the problem
The following code in miniprofiler is returning NotFound
The profiler is expecting some kind of guid value to be present, and it isn't.
private static string Results(HttpContext context) {
// this guid is the MiniProfiler.Id property
Guid id;
if (!Guid.TryParse(context.Request["id"], out id))
return isPopup ? NotFound(context) : NotFound(context, "text/plain", "No Guid id specified on the query string");
temporary fix
I took out the code above, and just collected the first guid out of storage, and this fixed the problem. I think this code needs cleaning up. I need to learn GIT, and then try and clean it up myself.
var id = MiniProfiler.Settings.Storage.List(10).FirstOrDefault();
Can you see .../mini-profiler-resources/results-index ?
Handler not required btw. There is a comma in your link but assume that is just a question typo.
Are you calling start last thing in the Application_BeginRequest() and stop in Application_EndRequest()
Have you set GlobalFilters.Filters.Add(new ProfilingActionFilter());?
and are you using WebActivator with a MiniProfilerPackage and MiniProfilerStartupModule
Think I need to tidy up my own implementation as looks like I have some unnecessary cruft.

catching log4net exceptions

I need to catch log4net exceptions (its own exceptions not app exceptions logged by it). I wish there's a way of doing it this way:
Try
_logger.Info(response)
Catch ex As Exception
Excepciones.HandleException(ex, "PolicyCore")
End Try
I have this code implemented and there's no errors in compilation but i force log4net to have an error (pointing to a non existing database in the config file) and nothing is threw.
I've tried the listener aproach:
<appSettings>
<add key="log4net.Internal.Debug" value="true" />
</appSettings>
<system.diagnostics>
<trace autoflush="true" indentsize="4" >
<listeners>
<add name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\\temp\\log4net.txt" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
and it's writing the errors to log4net.txt, the forced ones i mean.
This last aproach has a couple of drawbacks: it won't append every error to the file, if the error is the same it doesn't write it, i can't get the listener to write every error to that file, only one (I don't know how to fully configure the trace listener, it might be that). Thus it won't append the date and hour to every line wich is a necesity for me. Finally i can't give structure to it (xml).
Even if the listener work i need to use the try/catch aproach, since i'm using ExceptionHandling from Enterprise library to log the errors in my app.
Anyone who has faced the problem and/or has a solution?
Log4net is designed not to throw any exceptions. This seems to be a good idea because it would be very bad indeed if your application fails because it cannot log. So if you need to log certain messages and need to be sure that this worked, then you should not use a log framework, but rather implement this as part of your "business logic".
You mention that an exception is logged only once. I think that is not true: Log4net usually disables appenders that do not work and thus there is only one exception. The AdoNetAppender for instance can be configured to re-connect to the database in case of a failure in which case you would see the same exception multiple times.

Trying to find out why my WCF service is not working

Over a year ago I had been working on a WCF service, which I wrote using VS 2008. It runs under a Windows service, which I also wrote. It’s been running there ever since. And unfortunately, other projects/priorities have come up, preventing me from continuing with that project, until now.
Now I’m trying to get back to it. However, this go around I’m trying to find out if I can use VS 2010 and .NET 4, instead of .NET 3.5. I’ve brought up the command prompt, to run SvcUtil, to get the wsdl information, which I’ll put into the config file for the new WPF app I’m trying to get started writing. Only thing is, I keep getting an error, saying that I can’t reach the server, etc.
So, I copied the .exe.config file from the server to my machine, where I could edit it with SvcConfigEditor. I’ve made those changes, put it back onto the server, and got an error while trying to run SvcUtil, but worse than that I didn’t see the .svclog files I expected to see. So I got into the server’s Services app. I found the Windows service I wrote a year ago; saw that it was running, and stopped and started it again.
Now I’ve got a different problem. My Windows service starts, but then stops immediately. I get this message saying that the service had started and then stopped, and saying that sometimes that happens with different sorts of services, like Performance Logs and Alerts services. I’ve checked the event log on the server, and then only thing there related to this Windows service is that it entered the start state and then entered the stopped state.
Ah, after attempting to start it 4 times, it finally gave me an error in the event log! (Why didn’t it do that in the first place? And who says that trying to do the same thing over and over again, and expecting different results is a sign of insanity, when clearly the first 3 times it didn’t register anything in the event log, but on the 4th try it did.)
Here’s the error:
Event Type: Error
Event Source: Service1
Event Category: None
Event ID: 0
Date: 5/4/2011
Time: 10:14:46 AM
User: N/A
Computer: HELIOS
Description:
Service cannot be started. System.TypeInitializationException:
The type initializer for 'System.ServiceModel.DiagnosticUtility'
threw an exception. --->System.Configuration.ConfigurationErrorsException: Couldn't find type
for class System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089.
at System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType,
String initializeData)
and here’s the new section of code put into the .config file by SvcConfigEditor:
<sharedListeners>
<add initializeData="C:\Program Files\ASIWindowsService\ASIWindowsService_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="C:\Program Files\ASIWindowsService\ASIWindowsService_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
This question was answered in the comments but there is a gotcha that I've seen in Visual Studio 2010 that could result in a similar situation.
Even if the target framework is set to version 3.x for a WCF project, using the 2010 SvcConfigEditor will automatically insert "System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0..." although it should be inserting "System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0..." This will bite you when deploying the altered web.config to an IIS hosted service where the AppPool is not configured to use the .NET 4.0 framework. The fix is simply edit the web.config back to "Version=2.0.0.0".