I have a WebService solution with Sample.svc and Sample.svc.cs containing a method like;
public override ResponseClass GenerateResponse(RequestClass request)
{
// Some code here.
}
I want to test and debug code line by line with adding breakpoints, but i do not have any knowledge about how to do it?
How can i debug the webservice code?
You need to do following there may be other ways.
Host the service in IIS.
Now open code of service from VS.
Go to Debug
Click on Attach to process.
Select the process in which service is running.
Put breakpoint at method which you want to debug.
Now call that method from other application it will hit break point.
Related
I am experiencing some randomly happening unhandled exception causing w3wp to crash. I want to trace the cause of that exception. I already have a global Application_Error handler override in my MvcApplication class, so the crash must be caused by some out-of-http-context exception. In order to replicate the problem I genereate one myself in a timer callback, and try to trace it. Simplified code like
public static class MonitorTimers
{
public static Timer _taskMonitorTimer = new Timer(state: null, dueTime: 1000, period: 1000, callback: (state) =>
{
throw new Exception("Ouch! Me dead.");
});
}
In my local development environment (iisexpress launched by VS2017) and test environment (IIS 8.5), when the app starts and then crashes, the following can be seen in event viewer:
The most useful Event 1325 and 1026 sourced from ASP.NET and .NET Runtime shows the stack trace - just the thing I need.
My problem is, in my production machine (also IIS 8.5) I can't find the useful event 1325. Only a crash report, bearing no more information than I know. So I don't know what caused the error. I could surround my timer callback with try...catch block but the error could well be caused by something else (unmanaged libraries, error in static class initialization) then I still can't trace.
So suggestions on why event 1325 is missing or some tools that can show the log and analyse the stack trace is greatly appreciated. Thank you.
So, in your case you generate Exception diring Loading of application domain.
When CLR load application domain it firstly init static fields. So, if your code has problem with static fields, then exception will throw until it specifies Application_Error handler.
One more point, Is your application take a lot of memory? There are 2 cases when application can not write logs and execute code in catch block: StackOverflowException and OutOfMemoryException. Can you check is it has some memory leaks or infinite recursion?
One more point: set in visual studion setting to break when any exception throwed.
One more point: It is better to move your initialization logic from static constructors to ApplicationStart or something like this. You can do it temporary, for catch the bag and then move it to previous state.
Facing a very strange issue.
Following this guide https://azure.microsoft.com/en-in/documentation/articles/app-service-mobile-xamarin-forms-blob-storage/ to implement File Sync in Xamarin Forms app.
The Get method in my service (GetUser, default get method in App service controller) is being called thrice & on the 3rd iteration it gives me a 404 resource not found error. First 2 iterations work fine.
This is the client call
await userTable.PullAsync(
null,
userTable.Where(x => x.Email == userEmail), false, new System.Threading.CancellationToken(), null);
If I remove the following line,
// Initialize file sync
this.client.InitializeFileSyncContext(new TodoItemFileSyncHandler(this), store);
then the code works just fine, without any errors.
I will need some time doing a sample project, meanwhile if anyone can shed some light, it will be of help.
Thanks
This won't be an answer, because there isn't enough information to go on. When you get a 404, it's because the backend returned a 404. The ideal situation is:
Turn on Diagnostic Logging in the Azure Portal for your backend
Use Fiddler to monitor the requests
When the request causes a 404, look at what is actually happening
If you are using an ASP.NET backend (and I'm assuming you are because all the File tutorials use ASP.NET), then you can set a breakpoint on the appropriate method in the backend and follow it through. You will need to deploy a debug version of your code.
this is sorted now, eventually I had to give it what it was asking for. I had to create a storage controller for User too, although I don't need one as I don't need to save any files in storage against the users.
I am testing the app further now to see if this sorts my problem completely or I need a storage controller for every entity I use in my app.
In which case it will be really odd as I don't intend to use the storage for all my entities.
I want to use a console command from this bundle within my controller: http://knpbundles.com/dizda/CloudBackupBundle
The developer proposes cronjobs, however I want to use the command to backup my database from within my controller.
How would I do that?
I am getting this error message when i simply try to register this command as a service:
You have requested a non-existent service "backupcommandservice".
Thanks for the help!
commands don't quite work that way. Per the note on http://symfony.com/doc/current/cookbook/console/console_command.html#register-commands-in-the-service-container
registering a command as a service doesn't do much other than control location and dependency injection.
if you want to call a command: http://symfony.com/doc/current/components/console/introduction.html#calling-an-existing-command
that being said you shouldn't call commands from within a controller since you're basically asking to wait for this command to finish executing before you return a response. You'd be better off just sending a request to a queue box (for example beanstalk) and have a worker perform the job.
I created a Web Performance Test for a site which seems to be working fine. It's a simple test for logging in and testing the navigation. Running that test solely works every time. But the problem shows up when I call that test in in a LoadTest. So, I created a load test with only this web performance test in it and it fails all the time right after logging in because of this error:
The server committed a protocol violation. Section=ResponseStatusLine
I've researched this error a lot, and everyone suggests that inserting this statement:
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing=”true”/>
</settings>
</system.net>
in the web.config file solves the issue, but usually QA is separated from DEV and we have no access to their code. I'm just wondering how can the test work when executed individually and not in a load test. I thought the problem might be the number of users or the load pattern, so I set it from my initial Step load pattern to a Constant load pattern with only one user. Still, the same error causes the test to fail. Did anyone have a similar issue? If you need any more data, just let me know.
EDIT: When I specified a proxy (localhost:8888 - for fiddler) in the performance test that the load test uses, the issue didn't occur, but the load test was too slow.
I got exactly the same problem. My test environment is using SSL and is load balanced using an F5 load balancer. I was not getting the problem in a non-load balanced configuration.
A webtest when run does not cache dependent requests whereas the loadtest will cache dependent requests, hence the different behavior encountered.
To get around this problem you need to create a plug in to force dependant requests not to be cached in the load test. The following article tells you how to create a plug in.
http://msdn.microsoft.com/en-us/library/ms243191.aspx
Plug in Code Required:
using System;
using Microsoft.VisualStudio.TestTools.WebTesting;
namespace DisableCache
{
public class DisableCache : WebTestPlugin
{
public override void PostRequest(object sender, PostRequestEventArgs e)
{
foreach (WebTestRequest dependentRequest in e.Request.DependentRequests)
{
dependentRequest.Cache = false;
}
}
}
}
In the past, I got this error because of extra \n in the Url.
In my case, this was caused by a dynamic datasource. Parameter in the datasource should be cleaned.
Are you using DataSource in your Test ?
I've designed a website that works through my own PC.
I set the IIS to work with Custom Errors in case user ran into some unknown exception.
I've also added a check that the error page will e-mail me whenever it found an error.
Can I somehow get the error information (Stack and description) from the error page?
I encourages you to use Open Source library out there that provided functional need. My recommendation is ELMAH.
With a few line of settings in your web.config, you will all set. result screen looks like this.
(source: googlecode.com)
You can use ASP.NET Health monitoring.
http://msdn.microsoft.com/en-us/library/ms998306.aspx
Catch any errors that might be thrown and write them to the event log.
EventLog Logger = new EventLog();
Logger.Source = "ApplictionNme";
Logger.WriteEntry("Writing to event log.");