|
This innocuous project setting saved my butt. I had a nasty gotcha that for the life of me I couldn't see what was causing it. I'd copied a chunk of code and forgot to change a variable name. It compiled fine but was spooking me with a different value to what I expected. A light bulb switched on and I set the compile warnings as error option and lo, the compiler spewed an error that the variable might not have been assigned. Corrected, recompiled, all fine.
Our main app, the product of hacks, kicks, smack-downs over the years has literally 100 and 100s of warnings. If we ever get the time, we'll address them. That got me thinking: if only it was possible to set the warnings as errors on by default and password protect the setting so it can never be changed. It won't help us at this time but by golly, it's a darned useful setting!
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
Well, I suppose if you use a TFS team build, you can alter the setting the project file before the build starts
|
|
|
|
|
You could send everyone a build command that contains the /warnaserror [^] tag.
This would help everyone use the same build command and making warnings appear as errors.
modified 2-May-13 6:15am.
|
|
|
|
|
It is indeed useful - I always run with it enabled.
You can make it the default in new projects by creating a template with it enabled though: Just create a new project, set the option on in the Properties (and make any other changes you want, such as references) then "File...Export Template..." and save it as a Project Template will mean it is enabled by default.
Don't know any way to lock it as read-only, I'm afraid!
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
Thanks OG. It's one of those settings that's easy to overlook or neglect. The export template seems a very workable idea.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
Welcome! I'm a big fan of automating things so I don't forget them...
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
You should have a non-developer (a configuration manager) who performs the test and production builds. I worked at a place where the first task the testers did was build the code and kick it back if there were problems.
|
|
|
|
|
Just all about of my apps I've ever written copy files when needed on demand and nothing else is responsive until a file copy or move is completed. If a lot of files are involved it can take a while before you know it's done. Sometimes, I'll display the pathnames in a status bar, that kind of feedback malarkey.
Programs like 7z, possibly WinRar as well, go through the hoops of uncompressing an archive and when the files/folders are being copied you see the conventional Windows copy file dialog and progress bar. Is there a special API call or trick they they use to do this?
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
Yes, there are API's that will do this for you, but you could always go the easy way and use the Microsoft.VisualBasic.FileIO namespace and use one of the following methods:
FileSystem.CopyFile(source, destination, UIOption.AllDialogs);
FileSystem.CopyDirectory(source, destination, UIOption.AllDialogs);
|
|
|
|
|
I was thinking it might have been functions in shlwapi.dll that had similar options to display a UI for file copy, but my memory must be fading with age
'g'
|
|
|
|
|
It's in Shell32.dll. I'm pretty sure it's this[^] API.
|
|
|
|
|
yup, that'd be it - well done !!
'g'
|
|
|
|
|
Thanks for the heads-up on the that Pete. A while back I remember sneering at that namespace and the next moment I found it made life easier! I will investigate it once more.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
modified 2-May-13 5:03am.
|
|
|
|
|
You're welcome. I'm glad that I can supply some aid here.
|
|
|
|
|
A little while ago, I see somebody down-voted my original question which was somewhat puzzling given the relevance of what I was asking. It seems you can't please some folks.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
I've upvoted in compensation. It seemed to be a fair question to me. If it wasn't, I wouldn't have given a sensible answer.
|
|
|
|
|
Thanks for watching my back. You can't be too careful.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
The copying code is called on a background thread while the Progress Bar is being updated via the main or UI thread.
Thus, you see the effect of the progess bar incrementing while the file is being copied.
|
|
|
|
|
In an existing C# 2008 windows application I am trying to decide how to use the existing application without rewriting it. Currently there is a 'driver C# 2008 windows' program that calls the 'main C# 2008 desktop' application to perform various caLLS to a third parfty web service.
Now I would like to use the 'main C# 2008 desktop' application to be run by users. The users would enter the required paramters in a desktop screen and/or possibly a dos popup window. The application would know who is running the program by the paramters that are passed to the application.
Thus my question is, can a desktop screen and/or a dos popup window show up when users click on the executable? The default would be for the no desktop window to show up when the program is called by the 'driver C# 2008 windows' program.
Thus can you show me code and/or point me to urls that would show me how to accomplish this goal? If my goal not realistic, can you suggest other ways that I can accomplish the add on goal I am trying to acheive?
|
|
|
|
|
Errrr, dcof, you're posting under your other account again. Honestly, I don't know why you're still persisting with this architecture. We told you, when you first started posting about this under your many accounts, that it's not a good design and that you should seek to replace the second console application as it's unnecessary. You are tying yourself in knots here, trying to fix this broken application.
|
|
|
|
|
i am getting an error: unexpected end of file on the line that contains databaseKeyValue. Not sure why that is the case. Any help will be greatly appreciated.
private static bool addItemsToDrawing(
Visio.Page drawingPage)
{
bool itemsAdded = false;
Array shapeIDs;
addShapesToDrawing(drawingPage, out shapeIDs);
if (shapeIDs != null)
{
for (int index = shapeIDs.GetLowerBound(0);
index <= shapeIDs.GetUpperBound(0);
index++)
{
short shapeID = (short)(int)(shapeIDs.GetValue(index));
Visio.Shape newShape = drawingPage.Shapes.get_ItemFromID(shapeID);
int databaseKeyValue = newShape.get_Cells(_VisioPropCellPrefix + _IDColumn).get_ResultInt((short)Visio.VisUnitCodes.visNumber, 0);
_ItemShapeIndexMap.Add(databaseKeyValue, newShape.Index);
}
itemsAdded = true;
}
return itemsAdded;
}
|
|
|
|
|
I geuss you mean you get an Exception when running this code? Probably get_Cells() returns an empty result set.
|
|
|
|
|
int databaseKeyValue = newShape.get_Cells(_VisioPropCellPrefix + _IDColumn).get_ResultInt((short)Visio.VisUnitCodes.visNumber, 0);
That's too many statements on a single line. Call a single method per line, and step trough the code. It's probably not one of those methods that causes the exception, but a related event.
short shapeID = (short)(int)(shapeIDs.GetValue(index)); Why cast it to int, if you need a short?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i have designed a table as shown below. the are two literal controls as i am binding the datatable to the literal contol creating a tabular structre in the page load itself. The data is displayed correctly in default.aspx page. i want to export this aspx page to pdf . I using Itextsharp.dll.
On button click i have written code. The PDF is generated but it is getting distorted. Not getting generated as per the displayed aspx page.
Default.aspx and cs file is pasted below.
<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div width="100%">
<asp:Panel ID="pnl" runat="server">
<table style="width:100%; border:1 solid black">
<tr>
<td align="center" style="width:100%" colspan="2" >
Customer Details
</td>
</tr>
<tr>
<td style="width:30%">
<asp:Literal ID="litvac" runat="server"></asp:Literal>
</td>
<td align="center" style="width:30%">
<asp:literal id="litsal" runat="server"></asp:literal>
</td>
</tr>
</table>
</asp:Panel>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
</body>
</html>
now the cs file is as below
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string Qexp1 = "select * from emp";
string dconn = ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString;
OracleConnection oraconn = new OracleConnection(dconn);
oraconn.Open();
OracleCommand oracmd = new OracleCommand("select * from emp", oraconn);
oracmd.CommandType = CommandType.Text;
DataTable dt = new DataTable();
OracleDataReader oda = oracmd.ExecuteReader();
dt.Load(oda);
litvac.Text = "<table cellspacing='0' cellpadding='0' width='50%' border='1'><tr><td colspan='8' class='td_bg' align='Center' style='border-color: #808080'><b>Value Of Account [Fig. are in lacs]</b>";
litvac.Text += "</td></tr><tr><td align='center' style='border:1 solid #808080'><b>EMP</b></td><td align='center' style='border:1 solid #808080'><b>Ename</b></td></tr>";
for (int k = 0; k <= dt.Rows.Count - 1; k++)
{
litvac.Text += "<tr><td align='center' style='border:1 solid #808080'>" + Convert.ToString(dt.Rows[k]["empno"]) + "</td><td align='left' style='border:1 solid #808080'>" + Convert.ToString(dt.Rows[k]["ename"]) + "</td></tr>";
}
litvac.Text += "</table>";
litsal.Text = "<table cellspacing='0' cellpadding='0' width='50%' border='1'><tr><td colspan='8' class='td_bg' align='Center' style='border-color: #808080'><b>Value Of Account [Fig. are in lacs]</b>";
litsal.Text += "</td></tr><tr><td align='center' style='border:1 solid #808080'><b>job</b></td><td align='center' style='border:1 solid #808080'><b>sal</b></td></tr>";
for (int k = 0; k <= dt.Rows.Count - 1; k++)
{
litsal.Text += "<tr><td align='center' style='border:1 solid #808080'>" + Convert.ToString(dt.Rows[k]["job"]) + "</td><td align='left' style='border:1 solid #808080'>" + Convert.ToString(dt.Rows[k]["sal"]) + "</td></tr>";
}
litsal.Text += "</table>";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
}
|
|
|
|
|
I suspect iText is choking because of either invalid HTML, or all your nested tables are just too complicated for it. Post the final markup (view source) of your page so we can check it for known iText errors. One unclosed tag will mess it up bad.
|
|
|
|