Concise solutions for tough problems.
Over the years working on variety of different projects, I have run into some really tough problems
that were really hard to find a solution for. In some cases, unfortunately, there isn't a good
solution, and not even a good work around. In others, there is a solution, but it's less than we'd like.
And many of these toughies seem to emerge time and time again. And in still other cases there is a good
answer, but no matter how long you google for it, and how many books you scan through, you just can't
seem to find it. This section of BrianHewitt.com is dedicated to all of these scenarios, in the hopes
that others can gain from my growing pains. (And so I have a place to look if I forget the solution :) )
Problem debugging my ASP.NET application: "The breakpoint will not currently be hit. No symbols have been loaded for this document."
Date: | April 12, 2004 |
Key Words: | Debugging ASP.NET, No Symbols Loaded |
Problem: | I am trying to debug a problem with one of the functions of my ASP.NET application, and I keep seeing the message "The breakpoint will not currently be hit. No symbols have been loaded for this document." whenever I set a breakpoint (the breakpoint dot also has a question mark in it). When I run the application, the execution does not stop at the breakpoint, as indicated by the message. How do I fix this? |
Solution: |
I've read a number of different solutions out there including deleting shadow cache, and deleting
the offending compiled code, but the solution that worked most quickly and painlessly for me was to
do the following:
|
Problem downloading CSV data with Netscape 7.1
Date: | March 26, 2004 |
Key Words: | Netscape 7.1, CSV, content-type, content-disposition, ASP |
Problem: | I'm using an ASP page to create and send a CSV file to the browser. When users try to download and save this file using Netscape 7.1, the file always saves as filename.csv.asp. How can I get Netscape to quit adding the .asp extension. |
Solution: |
I worked, and worked, and worked on this one. Every code snippet I reviewed and tried failed
to deliver on this one, no matter how they promised it would work. I also encountered at least
one website that actuall stated "no solution is known" for this problem. In terms of writing
code for this, I agree, no amount of code will change this behavior. However, I did find a
solution on my own, while messing around with Netscape's preferences.
With that said, there is another solution, one that some people won't like. It involves updating the user's settings in Netscape 7.1. Here's what you need to do:
|
Transforming XML string and NOT saving the results to a file
Date: | March 24, 2004 |
Key Words: | C#, .NET, XSL, ASP.NET, Transform |
Problem: |
One popular approach to web user interface development is to use an XSL stylesheet to transform
XML content. There are a billion examples (or the same example is distributed over a billion sites)
that show you how to open an XML file, transform it with the .NET Framework using a XSL file, and
then write the result to another XML or HTML file.
Great. Now what if you have a string of XML that you want to transform into another string without writing this out to a file? |
Solution: |
This is another situation where the code isn't difficult, but if you want to find an example that
strays from the well-beaten path, you're out of luck. Without wasting too much time on words,
here's the code you want:
public static string DoTransform(string strSourceXML, string strXSLPath) { // Create Tranformation Object. System.Xml.Xsl.XslTransform objTransform = new System.Xml.Xsl.XslTransform(); objTransform.Load(strXSLPath); // Load XML into a StringReader and create a StringWriter to receive the XML. System.IO.StringReader objReader = new System.IO.StringReader(strSourceXML); System.IO.StringWriter objWriter = new System.IO.StringWriter(); // Create XPath Doc, load it with StringReader. System.Xml.XPath.XPathDocument XPDoc = new System.Xml.XPath.XPathDocument(objReader); // Transform the XML. objTransform.Transform(XPDoc, null, objWriter, null); return objWriter.ToString(); }Please note that this function assumes that you are using an XSL file to do your transformation. I think it's safe to say that this will the be the case 95% percent of the time. I haven't investigated it yet, but my guess is that you can most likely use the StringReader object to handle cases where you already have the text of your stylesheet. |