instruction stringlengths 0 30k ⌀ |
|---|
I'd like to do the following and can't find an elegant way:
1) Read an XML template into a System.Xml.XmlDocument
2) Populate it with data from my UI
3) Transform it with an XSLT I've written
4) Apply a CSS Stylesheet
5) Render it to a WebBrowser control
I'm currently reading it from a file on disk, populating it, then saving it back out to disk after populating it. I reference the XSLT in the template, and the CSS in the XSLT and then use the WebBrowser.Navigate([filename]) method to display the XML file.
Obviously, when I come to deploy this app, it'll break horribly as the file won't exist on disk, and I won't be able to reference the XSLT and CSS files in the XML file as they'll be resources. I'm planning to include the template as a resource, but can't find a neat way to proceed from there.
Any help much appreciated,
Jon |
What exactly are you trying to do?
Of course, there are numerous places to learn about svn pre-commit hooks (e.g. <a href="http://wordaligned.org/articles/a-subversion-pre-commit-hook"> here </a>, <a href="http://www.windley.com/archives/2008/08/using_a_precommit_hook_to_check_puppet_syntax.shtml"> here</a>, and in the <a href="http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html">Red Book</a>) but it depends what you're trying to do and what is available on your system.
Can you be more specific? |
This error usually indicates a class naming conflict. You are referencing two namespaces or you created a class with the same name in another namespace that you are using. I would start by looking at what that could be. |
You can try your luck with [mod_rewrite][1].
Create a script that takes a local static file name as input, through e.g. $_SERVER['QUERY_STRING'] and outputs it in compressed form. Many providers don't allow configuring mod_rewrite with .htaccess files or have it completely disabled though.
If you haven't used rewrite before, I recommend a good beginner's guide, like probably [this one][2].
This way you can make the apache redirect all requests for a static file to a php script. style.css will be redirected to compress.php?style.css for instance.
As always be **extremely** cautious on the input you accept or you have an XSS exploit on your hands!
[1]: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
[2]: http://www.workingwith.me.uk/articles/scripting/mod_rewrite |
I don't see a problem with a straightforward solution: Table for items, table for tags, crosstable for "tagging"
Indices on cross table should be enough optimisation. Selecting appropriate items would be
SELECT * FROM items WHERE id IN
(SELECT DISTINCT item_id FROM item_tag WHERE
tag_id = tag1 OR tag_id = tag2 OR ...)
|
I don't see a problem with a straightforward solution: Table for items, table for tags, crosstable for "tagging"
Indices on cross table should be enough optimisation. Selecting appropriate items would be
SELECT * FROM items WHERE id IN
(SELECT DISTINCT item_id FROM item_tag WHERE
tag_id = tag1 OR tag_id = tag2 OR ...)
AND tagging would be
SELECT * FROM items WHERE
EXISTS (SELECT 1 FROM item_tag WHERE id = item_id AND tag_id = tag1)
AND EXISTS (SELECT 1 FROM item_tag WHERE id = item_id AND tag_id = tag2)
AND ...
which is admittedly, not so efficient, but I can't think of a better idea. |
I don't see a problem with a straightforward solution: Table for items, table for tags, crosstable for "tagging"
Indices on cross table should be enough optimisation. Selecting appropriate items would be
SELECT * FROM items WHERE id IN
(SELECT DISTINCT item_id FROM item_tag WHERE
tag_id = tag1 OR tag_id = tag2 OR ...)
AND tagging would be
SELECT * FROM items WHERE
EXISTS (SELECT 1 FROM item_tag WHERE id = item_id AND tag_id = tag1)
AND EXISTS (SELECT 1 FROM item_tag WHERE id = item_id AND tag_id = tag2)
AND ...
which is admittedly, not so efficient for large number of comparing tags. If you are to maintain tag count in memory, you could make query to start with tags that are not often, so AND sequence would be evaluated quicker. Depending on expected number of tags to be matched against and expectancy of matching any single of them this could be OK solution, if you are to match 20 tags, and expect that some random item will match 15 of them, then this would still be heavy on a database.
|
There should be VisualSVN log files in your temp folder (somewhat like
"C:\Documents and Settings\<username>\Local
Settings\Temp\VisualSVN-2007-06-02-00-01-416.log").
Do you see anything in that file that helps? |
[Books Online][1] is probably a good place to start (or at least I like it and generally find it useful).
SQLMenace and bofe made some good points. Here's my additional two cents:
I'd recommend configuring _Database Mail_ rather than _SQL Mail_ (i.e. SMTP vs. MAPI, which I think is deprecated anyway). Once you get the mail profile configured, you'll have to also configure the SQL agent to use that mail profile (which is just a page of settings for the agent properties), or else your SSIS job notifications won't actually get sent, even though you can successfully send a test email from Management Studio.
I don't use alerts as often as job notifications, so the only tricky thing I can recall about them is that if you're raising an error and you want the alert to email you when that happens, you have to make sure that the raised error gets written to the log. I think that just boils down to "RAISERROR ... WITH LOG"; here's the [BOL link][2] for the syntax details.
[1]: http://msdn.microsoft.com/en-us/library/ms130214(SQL.90).aspx
[2]: http://msdn.microsoft.com/en-us/library/ms178592.aspx |
[Books Online][1] is probably a good place to start (or at least I like it and generally find it useful).
SQLMenace and bofe made some good points. Here's my additional two cents:
I'd recommend [configuring Database Mail][2] rather than SQL Mail (i.e. SMTP vs. MAPI, which I think is deprecated anyway). Once you get the mail profile configured, you'll have to also configure the SQL agent to use that mail profile (which is just a page of settings for the agent properties), or else your SSIS job notifications won't actually get sent, even though you can successfully send a test email from Management Studio.
I don't use alerts as often as job notifications, so the only tricky thing I can recall about them is that if you're raising an error and you want the alert to email you when that happens, you have to make sure that the raised error gets written to the log. I think that just boils down to "RAISERROR ... WITH LOG"; here's the [BOL link][3] for the syntax details.
[1]: http://msdn.microsoft.com/en-us/library/ms130214(SQL.90).aspx
[2]: http://msdn.microsoft.com/en-us/library/ms188298(SQL.90).aspx
[3]: http://msdn.microsoft.com/en-us/library/ms178592.aspx |
Also, check out ASP.NET MVC or if you're set on webforms, the new System.Web.Routing namespace in ASP.NET 3.5 SP1 |
What method on the master page are you accessing the label from? Depending on the stage of the page lifecycle, the label control may not have been loaded yet |
Could you be accessing it before it is created? Check the page lifecycle: http://msdn.microsoft.com/en-us/library/ms178472.aspx |
It sounds like you just need to integrate your server with [xinetd][1].
This is a server that listens on predefined ports (that you control through config) and forks off processes to handle the actual communication on that port.
[1]: http://www.xinetd.org/ |
I can see the argument for tables for forms, but there is a nicer alternative... you just have to roll up your sleeves and learn CSS.
for example:
<fieldset>
<legend>New Blog Post</legend>
<label for="title">Title:</label>
<input type="text" name="title" />
<label for="body">Body:</label>
<textarea name="body" rows="6" cols="40">
</textarea>
</fieldset>
You can take that html and layout the form either side-by-side labels, or labels on top of the textboxes (which is easier). Having the flexibility really helps. It's also less HTML than the table equivalent of either.
For some excellent examples of CSS forms, check out these excellent examples:
[http://jeffhowden.com/code/css/forms/][1]
[http://www.sitepoint.com/article/fancy-form-design-css/][2]
[http://www.smashingmagazine.com/2006/11/11/css-based-forms-modern-solutions/][3]
[1]: http://jeffhowden.com/code/css/forms/
[2]: http://www.sitepoint.com/article/fancy-form-design-css/
[3]: http://www.smashingmagazine.com/2006/11/11/css-based-forms-modern-solutions/ |
I just found out about this one today -- and I've been working with C# for 5 years!
It's the namespace alias qualifier:
extern alias YourAliasHere
You can use it to load multiple versions of the same type. This can be useful in maintenance or upgrade scenarios where you have an updated version of your type that won't work in some old code, but you need to upgrade it to the new version. [Slap on a namespace alias qualifier][1], and the compiler will let you have both types in your code.
[1]: http://blogs.msdn.com/abhinaba/archive/2005/11/30/498278.aspx |
Plug In Design for .NET App |
|.net|plugins|interface-design| |
I’m looking at rewriting a portion of our application in C# (currently legacy VB6 code). The module I am starting with is responsible for importing data from a variety of systems into our database. About 5-6 times a year, a new client asks us to write a new import for the system that they use. Presently, this requires us to release a new version of our software for each new import option we add to the application.
One of the goals of the rewrite is to make the application support plug-ins. Every new import can become a separate assembly which the host application will recognize and allow the end user to interact with. This will hopefully simplify life to some degree as we can simply drop a new assembly into the directory and have it be recognized and used by the main (host) application.
One of the items I am struggling with relates to the differences between the import options we currently support. In some cases we actually let the user point to a directory and read all of the files within the directory into our system. In other cases we allow them to point to a single file and import its contents. Additionally, some imports have a date range restriction that the user applies while others do not.
My question is, how can I design the application in a manner that allows for some flexibility among the imports we build and support while at the same time implementing a common interface that will allow the host application to easily recognize the plug-ins and the options that each one exposes to the user?
|
You should look into [PHPUnit][1], it looks pretty much like nUnit.
[1]: http://www.phpunit.de/ |
If you must use regex, here is a regex to get just the content part:
content\s*=\s*['"].*?['"]
returns
content = "blogger"
and
content='Worpress.com'
respectively. I'm no regex expert, but it gets those when given your examples in [regexpal][1].
Once you get that you can get everything between the quotes however you choose, be it another regex (which is just immoral at that point) or just looping over the characters.
[1]: http://regexpal.com/ |
I use to be a fan of the Java (and worse C#) practice of making getters and setters (get set properties) throughout an object. This use to be what I considered object oriented, but really this leads us just to exposing the guts and implementation of the object and not really taking advantage of encapsulation. There are times you can't get away from this (OR/M comes to mind), but in general the object should be set up and then perform its function. My dream objects tend to have one or two constructors, and maybe a half dozen functions that do work.
The reason for this is that once I started developing API's there is a real need to keep things simple. You really only want to add as much complexity as is required to get the job done, and getters and setters, while simple in themselves, add complexity in heaps when added in mass. What happens when I load setters i na different order? Anythign different? Are you sure? |
You could use [Spread](http://www.spread.org/) to do group communication. |
I'd say stick with what works for you. Unless you are having issues with VSS, why switch? Subversion is swell, though a little sticky to begin using it. TFS is far better than VSS, though it is fairly expensive for such a small team. I have not used git so I can't really speak to it. |
I once came across a .Net app that was ported from ASP. The .aspx pages were totally blank. To render the UI, the developers used StringBuilders in the code behind and then did a response.write. This would be the wrong way to do it! |
I like using Subversion for my personal projects. I could go down the list of features and pretend like it brings a lot to the table that other source control systems don't, but there's tons of good ones out there and the right choices is really a matter of style. If you check in after each small change (i.e. one checkin per function change), then many people can work on the same source file with very low risk of merge conflicts in practically anything <i>but</i> VSS (I haven't used VSS in years but from what I remember only one person at a time can work on a file.) If this isn't ever going to happen to you, I feel like the best course of action is to use what you know. VSS is better than no source control at all, but it feels restrictive to me these days.
I don't think you're beyond hope because you're asking if it would be better to switch; you're beyond hope when the answer is obvious and you ignore the evidence.
Even if you don't change source control systems, you ought to pick one like SVN or git and spend a few weeks reading about it and making a small project using it; it always helps to sharpen the saw. |
@Dan again, for more complex situations (immutability comes in mind) the Builder Pattern is a great solution.
Also, I agree with you mostly in getters. I believe what you are saying is to mostly follow the "[Tell don't ask][1]" paradigm and I greatly agree. But that is oriented mostly at getters.
Lastly, all of the above are for classes that have a great deal of attributes. I don't see a reason for any if you only have less than, say, 7.
[1]: http://www.pragprog.com/articles/tell-dont-ask |
How do you display a dialog from a hidden window application? |
|winapi|com| |
Apologies in advance if I use duff terminology in this question, I'm working at the edge of my understanding of Win32.
I have developed a COM component (dll) that implements an Edit() method displaying a WTL modal dialog.
The complete interface to this COM component corresponds to a software standard used in the chemical process industry (CAPE-OPEN) and as a result this COM component is supposed to be usable by a range of 3rd party executables that are out of my control.
My component works as expected in many of these EXEs, but for one in particular the Edit() method just hangs without the dialog appearing.
I have a suspicion that the problem may be something to do with this particular EXE running as a 'hidden window application'.
Can anyone suggest how I might get it to display the dialog? I know it is possible because I've seen this EXE display the dialogs from other COM components corresponding to the same interface.
|
|com|winapi| |
Apologies in advance if I use duff terminology in this question, I'm working at the edge of my understanding of Win32.
I have developed a COM component (dll) that implements an Edit() method displaying a WTL modal dialog.
The complete interface to this COM component corresponds to a software standard used in the chemical process industry (CAPE-OPEN) and as a result this COM component is supposed to be usable by a range of 3rd party executables that are out of my control.
My component works as expected in many of these EXEs, but for one in particular the Edit() method just hangs without the dialog appearing.
However if I make a call to ::MessageBox() immediately before DoModal() the dialog displays and behaves correctly after first showing the MessageBox.
I have a suspicion that the problem may be something to do with this particular EXE running as a 'hidden window application'.
Can anyone suggest how I might get it to display the dialog without first showing an unnecessary MessageBox? I know it is possible because I've seen this EXE display the dialogs from other COM components corresponding to the same interface.
|
If you are running on Java 6 you can use the [supplied monitoring tools][1]
[1]: http://java.sun.com/developer/technicalArticles/J2SE/monitoring/ |
Are you using a parent for the Dialog? e.g.
MyDialog dialog(pParent);
dialog.DoModal();
If you are, try removing the parent. Especially if the parent is the desktop window. |
As I said [here][1], I'd go for [Squeakland][2] and the famous [Drive a Car][3] example (powered by [Squeak][4]).
Smalltalk syntax is simple, which is great for children.
And later as the child evolves, he can learn more complex and even very advanced concepts that are also in Squeak (eg. programing statefull webapps with automated refactoring and automated unit tests!).
And like @[cpuguru](#20214) and @[Rotem](#37774) said, Scratch (also Squeak based) is great too.
[1]: http://stackoverflow.com/questions/37133/programming-for-a-9-year-old#37627
[2]: http://www.squeakland.org/
[3]: http://www.squeakland.org/school/drive_a_car/html/Drivecar12.html
[4]: http://www.squeak.org |
You can attach a debugger to the running process before triggering the exception. This should give you a better idea what's up with the application. |
How do you feel about using the [Observer][1] pattern? If not, you can implement a true callback this way:
// This function uses a callback function.
function doIt($callback)
{
$data = "this is my data";
$callback($data);
}
// This is a sample callback function for doIt().
function myCallback($data)
{
print 'Data is: ' . $data . "\n";
}
// Call doIt() and pass our sample callback function's name.
doIt('myCallback');
Displays: Data is: this is my data
[1]: http://en.wikipedia.org/wiki/Observer_Pattern |
Are you using the C/C++ Development Tools exclusively?<br><br>The Spellcheck functionality is dependent upon the Java Development Tools being installed also.<br><br>The spelling engine is scheduled to be pushed down from JDT to the Platform,<br>so you can get rid of the Java related bloat soon enough. :)
|
Inherits="System.Web.Mvc.ViewPage"
I'd imagine that this should be pointed at your View codebehind file class, not at the base ViewPage class.
|
To paraphrase what others have said: the trick isn't in the **schema**, it's in the **query**.
The naive schema of Entities/Labels/Tags is the right way to go. But as you've seen, it's not immediately clear how to perform an AND query with a lot of tags.
The best way to optimize that query will be platform-dependent, so I would recommend re-tagging your question with your RDBS and changing the title to something like "Optimal way to perform AND query on a tagging database".
I have a few suggestions for MS SQL, but will refrain in case that's not the platform you're using. |
And (apart from the observer pattern) you can also use call_user_func().
If you pass an array(obj, methodname) as first parameter it will invoked as $obj->methodname().
<pre>
<?php
class Foo {
public function bar($x) {
echo $x;
}
}
function xyz($cb) {
$value = rand(1,100);
call_user_func($cb, $value);
}
$foo = new Foo;
xyz( array($foo, 'bar') );
</pre> |
What I do:
* I place scripts in a `js` and stylesheets in a `css` dir, respectively.
* In the Apache configuration, I add directives like so:
<Directory /data/www/path/to/some/site/js/>
AddHandler application/x-httpd-php .js
php_value auto_prepend_file gzip-js.php
php_flag zlib.output_compression On
</Directory>
<Directory /data/www/path/to/some/site/css/>
AddHandler application/x-httpd-php .css
php_value auto_prepend_file gzip-css.php
php_flag zlib.output_compression On
</Directory>
* gzip-js.php in the `js` directory looks like this:
<?php
header("Content-type: text/javascript; charset: UTF-8");
?>
* …and gzip-cs.php in the `css` directory looks like this:
<?php
header("Content-type: text/css; charset: UTF-8");
?>
This may not be the most elegant solution, but it most certainly is a simple one that requires few changes and works well. |
.NET MVC Ambiguous Type Reference |
A decent first-cut might be to write a simple PERL script to parse out dependencies and then pipe that data to [Graphviz][1] for visualization.
[1]: http://www.graphviz.org/ "Graphviz" |
I'm not familiar with bazaar, but git doesn't track file renames. To git, this looks like a delete and an add. However, git is smart enough to see that the contents of the file already exist in its repository and will track their position in the system. If you split files up or merge them it's smart enough to keep track of segments of code (blobs) and store that information too. |
SimpleTest is a great system. I started out with it about 5 months ago, having never heard of TDD, and SimpleTest is easy to learn but still powerful. As for resources, I'm currently reading *TDD By Example* by Kent Beck, and it's good. |
Further to Ross' answer, there is no similar construct for other browsers. For example, you can't write conditional comments that target Firefox, for example, but are ignored by Internet Explorer.
The other browsers have chosen not to ignore Internet Explorer's innovation and therefore do not support conditional comments that allow you to target their own rendering engines.
The way I achieve the same effect as your conditional comment around a link to a style sheet is to sniff the user agent string. I then deliver a suitable CSS file for that browser.
This isn't perfect because sometimes people change their user-agent string for compatibility. The other way to target different browsers is to utilise browser specific hacks. These are particularly nasty because they usually rely on bugs in the browser and bugs are liable to be fixed!
User-agent sniffing is the best all-round solution in my opinion. |
Further to Ross' answer, you can only target the Internet Explorer rendering engine with conditional comments; there is no similar construct for other browsers. For example, you can't write conditional comments that target Firefox, for example, but are ignored by Internet Explorer.
The way I achieve the same effect as your example above is to sniff the user agent string. I then deliver a suitable CSS file for that browser. This isn't perfect because sometimes people change their user-agent string for compatibility.
The other way to target different browsers is to utilise browser specific hacks. These are particularly nasty because they usually rely on bugs in the browser and bugs are liable to be fixed!
User-agent sniffing is the best all-round solution in my opinion. |
Further to Ross' answer, you can only target the Internet Explorer rendering engine with conditional comments; there is no similar construct for other browsers. For example, you can't write conditional comments that target Firefox, but are ignored by Internet Explorer.
The way I achieve the same effect as your example above is to sniff the user agent string. I then deliver a suitable CSS file for that browser. This isn't perfect because sometimes people change their user-agent string for compatibility.
The other way to target different browsers is to utilise browser specific hacks. These are particularly nasty because they usually rely on bugs in the browser and bugs are liable to be fixed!
User-agent sniffing is the best all-round solution in my opinion. |
I don't think you can remove the meta data, but you can obfuscate your code if you're looking to protect your IP. |
Whatever you do, don't change for the sake of changing.
If it's working for you and you're not having problems with it, I don't see any reason to switch.
|
Send-Q is the amount of data sent by the application, but not yet acknowledged by the other side of the socket.
Recv-Q is the amount of data received from the NIC, but not yet consumed by the application.
Both of these queues reside in kernel memory.
There are [guides][1] to help you tweak these kernel buffers, if you are so inclined. Although, you may find the default params do quite well.
[1]: http://www.speedguide.net/read_articles.php?id=121 |
I have about 1.5 years worth of experience with the RCP framework, I really liked it. We simply JUnit for testing...
It's sort of cliche to say, but if it's not easy to test, maybe the design needs some refactoring?
Java and the RCP framework provide great facilities for keeping GUI code and logic code separate. We used the MVC pattern with the observer, observable constructs that are available in Java...
If you don't know about observer / observable construct that are in Java, I would HIGHLY recommend you take a look at this: http://www.javaworld.com/javaworld/jw-10-1996/jw-10-howto.html, you will use it all the time and your apps will be easier to test. |
I used to use NUnit, but now tend to use MbUnit, for two key features:
1. The RowTest feature allows you to easily run the same test on different sets of parameters, which is important if you really want thorough coverage.
2. The Rollback feature allows you to run tests against your database while rolling back changes after every test, keeping your database in exactly the same state every time. And it's as easy as adding the [Rollback] attribute.
Another nice aspect of MbUnit is that its syntax is nearly identical to NUnit, so if you have a whole test bed already in place under NUnit, you can just switch out the references without the need to change any (very much?) code. |
I'm just guessing here because from your code it's not obvious where do you have definition of IPlugin interface but if you can't cast in your host application then you are probably having IPlugin interface in your host assembly and then at the same time in your plugin assembly. This won't work.
The easiest thing is to make this work is to have IPlugin interface marked as public in your host assembly and then have your Plugin assembly reference host application, so both assemblies use **the very same interface**. |
I'm just guessing here because from your code it's not obvious where do you have definition of IPlugin interface but if you can't cast in your host application then you are probably having IPlugin interface in your host assembly and then at the same time in your plugin assembly. This won't work.
The easiest thing is to make this work is to have IPlugin interface marked as public in your host assembly and then have your Plugin assembly **reference host application assembly**, so both assemblies have access to **the very same interface**. |
The Dotfuscator will stop your code from being able to be decompiled: <http://www.preemptive.com/dotfuscator.html>
**Edit:** I should have mentioned, that's the professional version, the free community version ships with visual studio <http://msdn.microsoft.com/en-us/library/ms227240(VS.80).aspx> |
A couple of tips that I've found lately.
1. It's much better to use the TableAdapter FillByDataXXXX() methods instead of GetDataByXXXX() methods because the DataTable passed into the fill method can be interrogated for clues:
- DataTable.GetErrors() returns an
array of DataRow instances in error
- DataRow.RowError contains a
description of the row error
- DataRow.GetColumnsInError() returns
an array of DataColumn instances in
error
2. Recently, I wrapped up some interrogation code into a subclass of ConstraintException that's turned out to be a useful starting point for debugging.
C# Example usage:
Example.DataSet.fooDataTable table = new DataSet.fooDataTable();
try
{
tableAdapter.Fill(table);
}
catch (ConstraintException ex)
{
// pass the DataTable to DetailedConstraintException to get a more detailed Message property
throw new DetailedConstraintException("error filling table", table, ex);
}
Output:
>> DetailedConstraintException : table fill failed
Errors reported for ConstraintExceptionHelper.DataSet+fooDataTable [foo]
Columns in error: [1]
[PRODUCT_ID] - total rows affected: 1085
Row errors: [4]
[Column 'PRODUCT_ID' is constrained to be unique. Value '1' is already present.] - total rows affected: 1009
[Column 'PRODUCT_ID' is constrained to be unique. Value '2' is already present.] - total rows affected: 20
[Column 'PRODUCT_ID' is constrained to be unique. Value '4' is already present.] - total rows affected: 34
[Column 'PRODUCT_ID' is constrained to be unique. Value '6' is already present.] - total rows affected: 22
----> System.Data.ConstraintException : Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
I don't know if this is too much code to include in a Stack Overflow answer but here's the C# class in full.
Disclaimer: this works for me, please feel free to use/modify as appropriate.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace ConstraintExceptionHelper
{
/// <summary>
/// Subclass of ConstraintException that explains row and column errors in the Message property
/// </summary>
public class DetailedConstraintException : ConstraintException
{
private const int InitialCountValue = 1;
/// <summary>
/// Initialises a new instance of DetailedConstraintException with the specified string and DataTable
/// </summary>
/// <param name="message">exception message</param>
/// <param name="ErroredTable">DataTable in error</param>
public DetailedConstraintException(string message, DataTable erroredTable)
: base(message)
{
ErroredTable = erroredTable;
}
/// <summary>
/// Initialises a new instance of DetailedConstraintException with the specified string, DataTable and inner Exception
/// </summary>
/// <param name="message">exception message</param>
/// <param name="ErroredTable">DataTable in error</param>
/// <param name="inner">the original exception</param>
public DetailedConstraintException(string message, DataTable erroredTable, Exception inner)
: base(message, inner)
{
ErroredTable = erroredTable;
}
private string buildErrorSummaryMessage()
{
if (null == ErroredTable) { return "No errored DataTable specified"; }
if (!ErroredTable.HasErrors) { return "No Row Errors reported in DataTable=[" + ErroredTable.TableName + "]"; }
foreach (DataRow row in ErroredTable.GetErrors())
{
recordColumnsInError(row);
recordRowsInError(row);
}
StringBuilder sb = new StringBuilder();
appendSummaryIntro(sb);
appendErroredColumns(sb);
appendRowErrors(sb);
return sb.ToString();
}
private void recordColumnsInError(DataRow row)
{
foreach (DataColumn column in row.GetColumnsInError())
{
if (_erroredColumns.ContainsKey(column.ColumnName))
{
_erroredColumns[column.ColumnName]++;
continue;
}
_erroredColumns.Add(column.ColumnName, InitialCountValue);
}
}
private void recordRowsInError(DataRow row)
{
if (_rowErrors.ContainsKey(row.RowError))
{
_rowErrors[row.RowError]++;
return;
}
_rowErrors.Add(row.RowError, InitialCountValue);
}
private void appendSummaryIntro(StringBuilder sb)
{
sb.AppendFormat("Errors reported for {1} [{2}]{0}", Environment.NewLine, ErroredTable.GetType().FullName, ErroredTable.TableName);
}
private void appendErroredColumns(StringBuilder sb)
{
sb.AppendFormat("Columns in error: [{1}]{0}", Environment.NewLine, _erroredColumns.Count);
foreach (string columnName in _erroredColumns.Keys)
{
sb.AppendFormat("\t[{1}] - rows affected: {2}{0}",
Environment.NewLine,
columnName,
_erroredColumns[columnName]);
}
}
private void appendRowErrors(StringBuilder sb)
{
sb.AppendFormat("Row errors: [{1}]{0}", Environment.NewLine, _rowErrors.Count);
foreach (string rowError in _rowErrors.Keys)
{
sb.AppendFormat("\t[{1}] - rows affected: {2}{0}",
Environment.NewLine,
rowError,
_rowErrors[rowError]);
}
}
/// <summary>
/// Get the DataTable in error
/// </summary>
public DataTable ErroredTable
{
get { return _erroredTable; }
private set { _erroredTable = value; }
}
/// <summary>
/// Get the original ConstraintException message with extra error information
/// </summary>
public override string Message
{
get { return base.Message + Environment.NewLine + buildErrorSummaryMessage(); }
}
private readonly SortedDictionary<string, int> _rowErrors = new SortedDictionary<string, int>();
private readonly SortedDictionary<string, int> _erroredColumns = new SortedDictionary<string, int>();
private DataTable _erroredTable;
}
}
|
Depending on how the "hidden window" application works, it might not be able to display a window. For example, services don't have a "main message loop", and thus are not able to process messages sent to windows in the process. i.e, the application displaying the window should have something like this:
while(GetMessage(&msg, NULL, 0, 0))
{
if(!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
in WinMain. |
Have a look at this [survey][1] it was done by a Windows Forms Contol Vendor in Australia.
Personally i have worked on two commercial projects in the last year that were using WPF to varying degrees.
The adoption of WPF is on the rise. Microsoft i believe is putting all their eggs into the wpf basket.
[1]: http://www.componentfactory.com/blog/?p=322 |
Absolutely - the adoption is tiny. There was lots of hype but it does not seem to have materialized.
I used WPF for one project and I can certainly say it left a very unfinished taste in my mouth. It was far too difficult to acheive simple things and the whole thing had very many rough edges - the reasons behind them certainly existed but were not obvious or even visible at all. The Visual Studio designer completely bugged out for most of my pages and I never did figure out why...
All in all, I'd say WPF is barely beta-quality from a developer friendliness standpoint. |
SWFAddress works in Flash & Javascript projects and lets you create bookmarkable URLs (using the hash method mentioned above) as well as giving you back-button support.
http://www.asual.com/swfaddress/ |
Au Contrare... you'll find C/C++ people flocking to structs a.k.a. value types.
An example would be data packets. If you have a large number of data packets to transfer/transmit, you'd use value structs to model your data packets.
reason: Turning something into a class adds an overhead of (approx 8-16 Bytes I forget) of **overhead in the object header** in addition to the instance data. In scenarios where this is unacceptable, value types are your safest bet
Another use would be situations where you need **value type semantics** - once you create-initialize a object, it is readonly/immutable and can be passed around to n clients.
|
Though WPF was introduced few years ago it was too raw to use it in the real world apps. Major problem that stops WPF from wide adoption is a lack of RAD tools and out-of-box components. Currently we have Blend, more or less working Cider, but usable versions of these tools came not so long ago. Another reason is a completely different architecture which leans to longer development time as compared with WinForms.
I think we will see rising of WPF in the next few years. |
Though WPF was introduced few years ago it was too raw to use it in the real world apps. Major problem that stops WPF from wide adoption is a lack of RAD tools and out-of-box components. Currently we have Blend, more or less working Cider, but usable versions of these tools came not so long ago. Another reason is a completely different architecture which leads to longer development time as compared with WinForms due to prolonged learning\adoption period for developers.
I think we will see rising of WPF in the next few years. |
@Darren Kopp
Be carefull with BETWEEN, check out [How Does Between Work With Dates In SQL Server?][1]
[1]: http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/how-does-between-work-with-dates-in-sql- |
Have you checked this out?
[Best practices for making web pages fast](http://developer.yahoo.com/performance/) from Yahoo!'s Exceptional Performance team
If you really are having trouble at the backend, this won't help. But we used their advice to great effect to make our site faster, and there is still more to do.
Also use the YSlow add-on for Firebug. You may be surprised when you see where the actual time is being taken up. |
I'm in the object oriented architects camp. It's not necessarily a crime to put code in the database, as long as you understand the caveats that go along with that. Here are some:
1. It's not debuggable
2. It's not subject to source control
3. Permissions on your two sets of code will be different
4. It will make it more difficult to track where an error in the data came from if you're accessing info in the database from both places |
@Darren Kopp - you can use
set @date2 = '20201001'
this will let you lose the cast.
footndale - you can use date arithmetic to remove the time as well. Something like
select dateadd(d, datediff(d, 0, CURRENT_TIMESTAMP), 0)
to get today's date (without the time). I believe this is more efficient than casting back and forth.
|
I think it's a business logic vs. data logic thing. If there is logic that ensures the consistency of your data, put it in a stored procedure. Same for convenience functions for data retrieval/update.
Everything else should go into the code.
A friend of mine is developing a host of stored procedures for data analysis algorithms in bioinformatics. I think his approach is quite interesting, but not the right way in the long run. My main objections are maintainability and lacking adaptability. |
The problem is to make the search engine use the fact that 'subversion' and 'svn' are *very similar* to the point that they mean the same 'thing'.
It might be attractive to compute a simple similarity between tags based on frequency: 'subversion' and 'svn' appear very often together, so requesting 'svn' would return SVN-related questions, but also the rare questions only tagged 'subversion' (and vice versa). However, 'java' and 'c#' also appear often together, but for very different reasons (they are not synonyms). So similarity based on frequency is out.
An answer to this problem might be a mix of mechanisms, as the ones suggested in this Q/A thread:
- Filtering out typos by suggesting tags when the user inputs them.
- Maintaining a user-generated map of synonyms. This map may not be that big if it just targets synonyms.
- Allowing multi-tag search, such that the user can put 'subversion svn' or 'subversion && svn' (well, from programmers to programmers) in the search box and get both. This would be quite practical as many users may actually try such approach when they do not know which term is the most meaningful.
@Nick: Agreed. The question is not meant to argue against tags. Tags have great potential, but users will face a growing issue if one cannot search 'across' tags.
@Steve: Maintaining an ever-growing *map* of tags is definitely not practical. As SO is accumulating an ever-growing *bag* of tags, how could we shade some light on this bag to make search of Q/A tags even more useful, in a convenient way?
@Espo: 'Ajax-powered' tag suggestions based on existing tags is apparently available on SO when creating a question. This is by the way very helpful to choose tags and appropriate spelling (avoiding the 'subversion' vs. 'sbversion' issue from Steve). |
|asp.net|mvc| |
Not entirely sure what's going on here; any help would be appreciated.
I'm trying to create a new .NET MVC web app. I was pretty sure I had it set up correctly, but I'm getting the following error:
The type 'System.Web.Mvc.ViewPage' is ambiguous: it could come from assembly
'C:\MyProject\bin\System.Web.Mvc.DLL' or from assembly
'C:\MyProject\bin\MyProject.DLL'. Please specify the assembly explicitly in the type name.
The source error it reports is as follows:
Line 1: <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
Line 2:
Line 3: <asp:Content ID="indexContent" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
Anything stand out that I'm doing completely wrong? |
|asp.net|asp.net-mvc|mvc| |
Are you using a CodeBehind file, I don't see CodeBehind="" attribute where you are specifying the Inherits from? Then you have to point inherits to the class name of the codebehind.
Example:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="MvcApplication4.Views.Home.Index" %>
Make sure the Inherits is fully qualified. It should be the namespace followed by the class name.
|
I don't think you have much choice other than using an class that implements IEnumerable<T>. Even if the DataSource property was smart enough to take a scalar object, it would probably convert it internally to a vector.
I would however consider using a simple array rather than a List<T> as this will result in fewer memory allocations. If you don't like the array syntax (and also to increase readability) you could use a helper method:
T[] DataSourceHelper::ToVector<T>(T scalar) {
return new T[] { scalar };
} |
I suppose you named one of your page "ViewPage" is that the case?
And like @Jonathan mentioned, this smells:
Inherits="System.Web.Mvc.ViewPage"
On my MVC application, _all_ the view pages have this instead:
Inherits="MySite.Views.Pages.Home"
Or something along the line. Your aspx page markup should have "Inherits" point to your code-behind class name, not the actual class that it is inheriting. The attribute name is rather misleading but its an artifact of earlier days. |
Stopping the timer doesn't mean that it won't be called again, depending on when you stop the timer, the timer_tick may still be queued on the message loop for the form. What will happen is that you'll get one more tick that you may not be expecting. What you can do is in your timer_tick, check the Enabled property of your timer before executing the Timer_Tick method.
|
I second superjoe30's suggestion: I had great success with musicplayer. The only (slight) negative is that it's a little older project and not as well skinnable as some of the alternatives (although you have the full source code, so - given some time - you can make it look exactly as you need it to). |
In the Singularity project, Microsoft research communicates with the singularity VM through a "loopback" adapter. Maybe that'd help?
Running it is easy so it may be something fun to do anyway. :)
http://research.microsoft.com/os/Singularity/ |
The Dotfuscator will stop your code from being able to be decompiled
http://www.preemptive.com/dotfuscator.html
**Edit:** I should have mentioned, that's the professional version, the free community version ships with visual studio |
i used vss for years until switching to svn about two years ago. my biggest complaints about vss were the poor network performance (that problem may be solved now) and the pessimistic locking of files. svn solved both those, is easy to set up (i use collabnet server and tortoisesvn client, although there are two good visual studio plugins: visualsvn - commercial, and ankhsvn - open source), easy to use and administer, and well documented.
it's tempting to say "if it's not broken then don't fix it" but you would get to learn a more modern source control tool and, perhaps more importantly, new ways of using source control (e.g. more frequent branching and merging) that the new tool would support. |
>I once came across a .Net app that was ported from ASP. The .aspx pages were totally blank. To render the UI, the developers used StringBuilders in the code behind and then did a response.write. This would be the wrong way to do it!
I've seen it done the other way, the code behind page was blank, except for declaration of globals, then the VBScript was left in the ASPX.
|
Could depend a bit how you obtain those 2 strings. Probably the secure, fireproof way to do that is what is in URI::URL or similar libraries, where all alternatives, including malicious ones, would be considered. Maybe slower, but in some environments faster will be the speed of a bullet going to your own foot.
But if you expect there something plain and not tricky could see if it starts with /, chains of ../, or any other char. The 1st would put the server name + the url, the 2nd chop paths from the base uri till getting in one of the other 2 alternatives, or just add it to the base url. |
<ol>
<li><p>What is the distinction between 0.0.0.0, 127.0.0.1, and [::]?</p>
<ul>
<li>0.0.0.0 indicates something that is listening on all interfaces on the machine.</li>
<li>127.0.0.1 indicates your own machine.</li>
<li>[::] is something I don't have, but my machine does have *:\* which shows that UDP ports don't really have a foreign address - they receive packets from any where. That is the nature of UDP.</li></ul>
</li>
<li> <p>How should each part of the foreign address be read (part1:part2)?</p>
<ul><li>part1 is the hostname or IP address</li><li>part2 is the port</li></ul>
</li> |
I think you are referring to the [Assembly Manifest][1]:
> Every assembly, whether static or
> dynamic, contains a collection of data
> that describes how the elements in the
> assembly relate to each other. The
> assembly manifest contains this
> assembly metadata. An assembly
> manifest contains all the metadata
> needed to specify the assembly's
> version requirements and security
> identity, and all metadata needed to
> define the scope of the assembly and
> resolve references to resources and
> classes.
One of the most important features of .Net assemblies is that they are self-describing components and this is provided by the manifest. So removing them will somehow defeat its purpose.
[1]: http://msdn.microsoft.com/en-us/library/1w45z383(VS.71).aspx |
Setting Nameservers - how? |
|dns| |
I understand how I can change the dns settings for my domains by editing my bind configs, when I run my own nameservers. I know that I can define the nameservers with my registrar via their online control panels. But I have no idea how that part works...
How does my registrar store the data about the nameservers? Is it something clever, like them having the authority to store NS records in the root nameservers?
I'm confused by this part, can anyone explain? |
@Jon Limjap
For label : textbox, neither divs nor tables are appropriate: `<dl>`s are |
I would recommend you take a look at the Managed Add-In Framework that shipped with .NET 3.5. The <a href="http://blogs.msdn.com/clraddins/">Add-In team</a> has posted some samples and tools at <a href="http://www.codeplex.com/clraddins">CodePlex site</a> as well.. |
.Net 3.5 has the system.Addin namespace.
This thread also has some good information for older versions of the framework:
h[ttp://forums.devshed.com/net-development-87/system-plugin-532149.html][1]
[1]: http://forums.devshed.com/net-development-87/system-plugin-532149.html |
One pattern you could follow is to have an asynchronous service that works on files on a shared file system location:
1. Place the file to be encrypted on a shared location
2. Call the service and tell it to encrypt the file, passing both the location and name of the file, and the addres of a callback service on the client
3. The service would encrypt the file and place the encrypted copy in a shared location (the same as where the unencrypted was placed or different, doesn't matter)
4. The service would call back to the client, giving the name and location of the encrypted file
5. The client can retrieve the encrypted file |
for the theory take a look at the [plugin pattern][1] in martin fowlers Patterns of Enterprise Application Architecture
for an interesting example take a look at this tutorial: [Plugin Architecture using C#][2]
[1]: http://www.martinfowler.com/eaaCatalog/plugin.html
[2]: http://www.codeproject.com/KB/cs/c__plugin_architecture.aspx |
The registrar is responsible for setting the Root DNS entry that says, "When someone asks for stackoverflow.com, tell them that the authoritative DNS is xxx.xxx.xxx.xxx". They have an interface that allows them to make changes to the records they own.
Then the requester must go to the authoritative DNS (Which is the one you specified to your registrar was your DNS) to find the IP for stackoverflow.com, any subdomain of it, email server, and other DNS records pertaining to that domain.
-Adam |
You can do this with a proxy, but I think Will Harris's answer is the best - use a subdomain. Much simpler, and it'll get rid of issues with relative links as well. |
@Dave Ward:
The use of RunOnce method works perfectly. This solve my problem without having the workaround to check first if handler already exist before attaching to an event.
I'll mark your answer as an accepted answer. Thanks again. |
There's also JGraph, but I'm not sure if that's only for graphs (i.e. nodes and edges), or if it does charts also. |
I'd recommend you stick with PuTTY too. You might find it useful to run Pageant in conjunction with Plink to avoid having to type in the passphrase.
But if you want to research alternatives you should review this Wikipedia resource:
[http://en.wikipedia.org/wiki/Comparison_of_SSH_clients][1]
[1]: http://en.wikipedia.org/wiki/Comparison_of_SSH_clients |
This is CS101, but since no one else has mentioned it, while loops evaluate their condition before the code block, and do-while evaluates after the code block, so do-while loops are always guaranteed to run their code block at least once, regardless of the condition. |