Click here to Skip to main content
12,882,806 members (36,547 online)

Comments by Duncan Edwards Jones (Top 131 by date)

Duncan Edwards Jones 26-Nov-16 7:52am View
Yup - even 4.0 demands a colon for the named argument -
Duncan Edwards Jones 26-Nov-16 7:42am View
Bizarre but it definitely demands a colon in VS2015 / .NET 4.6.2
If I hover over it the parameter name is suggested but it puts the colon in.

Shall raise defect report with MS
Duncan Edwards Jones 22-Sep-16 10:36am View
Nothing but I am doing a lot of post-processing of the settings which I don't want to have to do multiple times (wiring up delegates &c.)
Duncan Edwards Jones 15-Sep-16 8:35am View
You probably want to look at a technology such as AJAX... ?
Duncan Edwards Jones 4-Sep-16 17:53pm View
See this Microsoft documentation on the function DrawString that you ar eusing to print:-
Duncan Edwards Jones 4-Sep-16 17:47pm View
You are using PadRight to align text.
Don't use that.

Use StringAlignment.
Duncan Edwards Jones 6-Jul-16 5:16am View
So - looks like "both configurable" then.
Duncan Edwards Jones 29-Jun-16 9:27am View
What user is the windows service running as - and does that user have access to the printer and file system?
Duncan Edwards Jones 16-Jun-16 6:24am View
Either turn the tweet into one sentence or get the multiple sentiments and perform some rule to decide how to aggregate them.
Duncan Edwards Jones 16-Jun-16 5:36am View
It seems NLP is splitting the tweet into sentences. What does it give if you replace the full stops with commas?
Duncan Edwards Jones 18-May-16 7:44am View
Ok - there are actually a number of things you need to do so first I suggest reading this article:-

Then you need an "If Currentpage = 0 Then" block that prints the header and footer bit, and also makes the area to print the list in smaller.
Duncan Edwards Jones 18-May-16 4:38am View
"Subscription" is about paying (and setting payment limits) only.

"Administrator" is about creating/deleting etc. - so if you are administrator you can add an application from the portal. Press the [+] on the applications and follow that wizard.
Duncan Edwards Jones 17-May-16 12:33pm View
Do you want the header and footer on each page of the print, or just the first one?
Duncan Edwards Jones 5-May-16 5:53am View
I think you might need FILE_SHARE_READ access to read the device serial number?
Duncan Edwards Jones 27-Apr-16 11:28am View
Are you using the algorithm specified by the target API and the decryption key provided by them?
Duncan Edwards Jones 20-Apr-16 6:51am View
If you have found the answer, please post it here so others may also find it when they google your question...
Duncan Edwards Jones 22-Mar-16 7:56am View
Do you have a data contract attribute on the Defination class?
Duncan Edwards Jones 11-Mar-16 6:12am View
As an analogy - compare a bus (scale up) with many taxis (scale out).

For a given load a bus is cheaper to run but everyone on the bus has to wait for everyone else on the bus.

Taxis are more expensive but everyone gets to their destination as quick as possible irregardless of other people's destinations.

Then consider the difference between adding an extra 10 seats to a bus vs adding an extra 5 taxis. That is where the real reason for scale-out comes from!
Duncan Edwards Jones 26-Feb-16 10:12am View
Reason for my vote of 5 \n Excellent checklist
Duncan Edwards Jones 21-Feb-16 2:49am View
Set the printer status to paused until the whole job is in the spooler - there is also a flag in the advanced settings to prevent printing before the entire file is spooled.
Duncan Edwards Jones 19-Feb-16 6:22am View
In that case - I recommend you use scale out for new build from the start (unless there is a real non-parallel business situation) and use scale up when your architecture is already built around a monolithic design because it is really difficult to parallelise a design that wasn't built to be parrallelised.
Duncan Edwards Jones 22-Jan-16 11:18am View
is this actually a question? Maybe add some explanation of why you do this and post it up as a tip?
Duncan Edwards Jones 21-Jan-16 4:18am View
I would second the recommendation to use PrintDocument yourself - that way you get full programmatic control over how the output looks.

Have a look at: to start with.
Duncan Edwards Jones 4-Jan-16 16:50pm View
You need to do a multiple-step process whereby: first you create a copy of the table structure but with the identity field, then you set IDENTITY INSERT ON for the table, then you copy the data from the source table and finally rename source and target tables so you are left with your new table having the identity field.
Duncan Edwards Jones 3-Jan-16 7:32am View
Why are you using HTML to do the print part for a windows forms application?

There are lots of good examples for printing data grids here that don't use HTML - I think that is a better route to go down?
Duncan Edwards Jones 26-Dec-15 12:58pm View
Thank you - that helped

The VB.NET resulting code is therefore:

Private Shared Function ToReturnStatement(ByVal valueToReturn As IdentityGroupClassification) As CodeStatement

Dim expression As CodeExpression = Nothing
Dim EvaluationResultExpression As CodeExpression = New CodeTypeReferenceExpression("EvaluationResult")
If (valueToReturn = IdentityGroupClassification.Exclude) Then
expression = New CodeFieldReferenceExpression(EvaluationResultExpression, "Exclude")
ElseIf (valueToReturn = IdentityGroupClassification.Include) Then
expression = New CodeFieldReferenceExpression(EvaluationResultExpression, "Include")
expression = New CodeFieldReferenceExpression(EvaluationResultExpression, "Unchanged")
End If
If (expression IsNot Nothing) Then
Return New CodeMethodReturnStatement(expression)
Return New CodeMethodReturnStatement()
End If

End Function
Duncan Edwards Jones 11-Dec-15 15:08pm View
edited as above.
(You can't include a table name in an alias...) therefore "As [AD].AdsDesc " is not allowed.
Duncan Edwards Jones 10-Dec-15 18:23pm View

SUBSTRING([AD.AdsDesc],1,50) as AdsDesc,
FROM [ads] as AD JOIN UserInfo as IUS
WHERE AD.[Country] = @Location
AND IUS.[approv]='Y'
Duncan Edwards Jones 26-Nov-15 7:59am View
I don't think there is any limit - are you sure there was no error (duplicate key insert, missing mandatory field etc.) when doing the import?
Duncan Edwards Jones 20-Nov-15 5:37am View
An executable is a PE file ( see )
Duncan Edwards Jones 19-Nov-15 10:09am View
I missed braces - try with them..
Duncan Edwards Jones 18-Nov-15 9:02am View
I don't see where you are setting the current principal for the running thread (although this may be elsewhere in the code)...

Duncan Edwards Jones 4-Nov-15 10:16am View
Does the menu "Build -> Transform All T4 Templates" do any magic for you?
Duncan Edwards Jones 4-Nov-15 7:34am View
1) Is there any error logged in the event viewer (run "eventvwr.exe" on the server)?

2) Are you closing down your application cleanly or killing it with task manager?

3) What 3rd party tools?
Duncan Edwards Jones 1-Nov-15 15:03pm View
There's probably a good explanation on the reason this happens to do with the window message handler that every UI thread has to have and how it keeps the UI responsive, but the takeaway message is "Don't dig the garden in your dancing shoes" (i.e. Don't do heavy work in the UI thread)
Duncan Edwards Jones 30-Oct-15 12:02pm View
What happens if you use a BackgroundThreadWorker to run it in a non UI thread from the windows form?
Duncan Edwards Jones 28-Oct-15 3:37am View
You need to set a breakpoint on "Public SnippetsFolder As String = Application.StartupPath & "\Snippets\"" and step through to see what line the code stops on
Duncan Edwards Jones 21-Oct-15 12:31pm View
I would suggest you have a data quality issue if these are in fact the same company?
Duncan Edwards Jones 12-Oct-15 4:52am View
OK - currently your data in the data grid is there by Data Bindiing - this type of binding can also be done for all other windows controls (text boxes, list etc.) .. see for example.
Duncan Edwards Jones 12-Oct-15 4:20am View
Windows Forms or WPF (or Silverlight?)
Duncan Edwards Jones 12-Oct-15 4:08am View
Printed form, or on-screen type of form?
Duncan Edwards Jones 7-Oct-15 5:05am View
If the type manager can't derive it (like here where you have no explicit parameters of TEntity) you can explicitly state it. e.g. to get a guery result of Customer:-

var test = LINQDynamic<customer>.GetQueryResult();

You should also make the return type of GetQueryResult be TEntity rather than object.

public class LINQDynamic<tentity> where TEntity: class

public static TEntity GetQueryResult(object pkKey,TEntity type, params object[] pkKeys)

Duncan Edwards Jones 25-Sep-15 5:00am View
Put a breakpoint on the third line. Is PrintDocument1 initialised when it gets there (I think it is not)
Duncan Edwards Jones 23-Sep-15 12:26pm View
Where is "PrintDocument1" declared or initialised?
Duncan Edwards Jones 14-Sep-15 3:54am View
What is the data type of the field in the database in which you are saving the record - is it a Boolean or a character field?
Duncan Edwards Jones 4-Sep-15 5:43am View
If there was a way to alter an executable so the AV didn't block it then the virus writers would do that too - so obviously there isn't. You need to configure your AV to allow that file through...
Duncan Edwards Jones 4-Sep-15 3:51am View
OK - so it can never equal "Nothing". Therefore you need to check if the field is null and only if not then try and set the value. Do what F-ES Sitecore suggested.
Duncan Edwards Jones 28-Aug-15 6:06am View
Suggest you add that question to the comments article itself so the article author gets it.
Duncan Edwards Jones 28-Aug-15 6:06am View
Suggest you add that question to the comments article itself so the article author gets it.
Duncan Edwards Jones 24-Aug-15 5:58am View
Not as far as I can see ( )
Duncan Edwards Jones 19-Aug-15 11:08am View
Where do you want this image displayed?
Duncan Edwards Jones 24-Jul-15 2:33am View
Yes - but "foreach" always starts at the first row. You need to use an integer row index (initialised in the _BeginPrint) instead.
Duncan Edwards Jones 17-Jul-15 2:47am View
No - I obviously needed to clarify my question. I don't want to do anything with IDisposable - I just want to do what it does in the IDE.
Duncan Edwards Jones 16-Jul-15 12:41pm View
When you are in Visual Studio with a VB class open and you type "Implements IDisposable [return]" it pastes in all that stuff above.

if you type in "Implements IDuncansInterfaceThing" it only pastes in the method/property signatures - no comments or other boilerplate.

(Maybe it is not possible for me to do)
Duncan Edwards Jones 16-Jul-15 11:40am View
Yes - the code snippet that automatically triggers when someone implements my interface. (Like what IDisposable does)
Duncan Edwards Jones 30-Jun-15 7:22am View
Why are you creating the whole file in memory before writing it? Maybe use a Stream and write it one line at a time to the file...If you want it to be cancellable then you need to use WriteAsync - see
Duncan Edwards Jones 13-Jun-15 17:51pm View
Ah - I meant Modelling.Diagrams.TextField - - there doesn't seem to be a NoteField equivalent.
Duncan Edwards Jones 4-Jun-15 12:34pm View
I don't think square brackets around parameter names are legal? Can you try take the space out of the parameter name and then remove the brackets?
Duncan Edwards Jones 4-Jun-15 8:35am View
What do you have as the group "keep together" settings on the report definition? (See
Duncan Edwards Jones 4-Jun-15 5:43am View
This looks like a scenario for Azure Webjobs - see
Duncan Edwards Jones 19-May-15 12:16pm View
Does the receiving side of the web request already exist - i.e. is the external server set up and has some URL that you need to send the file to?
Duncan Edwards Jones 12-May-15 4:13am View
Do you mean how to structure code files in a folder structure (and classes in namespaces) or do you mean how to format the code within each file?

The main thing to bear in mind when writing code is: do the thing that makes it easiest for a human to read.
Duncan Edwards Jones 14-Apr-15 4:10am View
What type of database? (MS SQL Server, Oracle, Access, Sybase??)
Duncan Edwards Jones 13-Apr-15 13:03pm View
Not better than the Java docs themselves:-
Duncan Edwards Jones 18-Mar-15 10:47am View
In what context? Do you mean "sounds through a microphone" or "randomness in a data set"?
Duncan Edwards Jones 25-Feb-15 12:17pm View
if your current picture is not the last one, set e.HasMorePages = True
Duncan Edwards Jones 16-Feb-15 8:42am View
Were you recently in a room where a number of people were facing in one direction writing things whilst one person was facing towards them talking?

That person is probably the one who you should ask for help on this.
Duncan Edwards Jones 16-Feb-15 8:38am View
Basically (very simplified explanation) the Task syntax explains what you want the program to do whereas the Thread syntax explains how you want it to do it...and also the async/await keywords are part of that.
Duncan Edwards Jones 12-Feb-15 9:07am View
Do you mean like clippy or that (strange) dog that came with Windows XP?

The Microsoft Agent ( product is discontinued so really this might not be a good use of your time?
Duncan Edwards Jones 3-Feb-15 18:35pm View
What is the data type of the (in) parameter of the stored procedure - shouldn't it match the column data type that is being returned?
Duncan Edwards Jones 8-Jan-15 8:47am View
What is the "dmp printer" - does it use a standard windows printer driver?
Duncan Edwards Jones 2-Jan-15 10:45am View
If you aren't going to show it, why have a form at all - why not just have a method that takes your selected data row and prints it?
Duncan Edwards Jones 10-Dec-14 4:59am View
Reason for my vote of 4 \n Useful - lets the compiler lend a hand..
Duncan Edwards Jones 8-Dec-14 6:54am View
Not in the detail - how is scrambling/unscrambling different to encryption/unencryption?

Perhaps you could go one step up and describe what you are trying to achieve and why?
Duncan Edwards Jones 1-Dec-14 5:24am View
Do you have any existing programming language experience (i.e. how do I convert from language x to c#) or are you looking to start programming from scratch using C#?
Duncan Edwards Jones 27-Nov-14 6:29am View
1) SQLEXPRESS is (typically) a local database so if you want your application to run from a server then that server will need to have the database installed on it.

2) Using integrated security means that whatever user/account is running the code needs to have access to the database. This will be a system account so you need to give that account access.
Duncan Edwards Jones 27-Nov-14 5:52am View
1) Can you post the actual text of the error message?

2) Can the remote machine see "MNT-PC\SQLEXPRESS" ?
Duncan Edwards Jones 25-Nov-14 11:21am View
and does the path exist on the server?

(If not and you intend "request.Method = WebRequestMethods.Ftp.MakeDirectory;" to do that, don't forget you have to issue the request with "FtpWebResponse response = (FtpWebResponse)request.GetResponse();" before you continue...)
Duncan Edwards Jones 23-Nov-14 5:19am View
Cool - I didn't know that.

The real solution is probably to not hard-code SQL statements in C# but rather use a data access layer...
Duncan Edwards Jones 2-Oct-14 7:02am View
I think that this is not possible. Can you imagine how bad spam could be if every time you visited a web page it printed something out?
Duncan Edwards Jones 25-Sep-14 5:43am View
Why are you catching the exception and not doing anything with it? Surely if something goes wrong you want to be told about it?
Duncan Edwards Jones 16-Sep-14 9:56am View
I've updated my idea a bit - mapReduce is probably overkill
Duncan Edwards Jones 16-Sep-14 8:53am View
My guess would be that this is probably for research/training purposes, not primary care...
Duncan Edwards Jones 16-Sep-14 7:12am View
Yes - it is going to need manual oversight/intervention. What sort of volume of records are you talking - 10s, or 1000s?
Duncan Edwards Jones 16-Sep-14 7:11am View
Yes - it is going to need manual oversight/intervention. What sort of volume of records are you talking - 10s, or 1000s?
Duncan Edwards Jones 12-Sep-14 4:01am View
Why are you storing a date in an NVarchar column - why not use the appropriate data type?
Duncan Edwards Jones 11-Sep-14 5:22am View
Reason for my vote of 4 \n Tidy explanation
Duncan Edwards Jones 8-Sep-14 11:50am View
Are you using the above referenced spool file viewer code to view the spool file?
Duncan Edwards Jones 4-Sep-14 9:26am View
Is the System.Data.Linq DLL listed in the references dialog box?
Duncan Edwards Jones 27-Aug-14 11:49am View
No indeed - but the event is only raised under certain circumstances and I want to test that - i.e. circumstances not met, no event was raised. Circumstances met, event was raised.

I am testing the class in isolation.
Duncan Edwards Jones 27-Aug-14 5:45am View
I think you need to compare the fonts used in the SSRS template with the fonts installed on the server - I think it is very unlikely the server itself is deciding to use a different font if the expected font is available on the server...however it is also possible that some settings in the PDF writer are different between the two servers?
Duncan Edwards Jones 27-Aug-14 5:23am View
I'd imagine the report template uses a font that is not installed on server B and it is falling back on one of the other two fonts?
Duncan Edwards Jones 25-Aug-14 6:05am View
The performance counter classes (linked above) can be used to read performance counters. I'd suggest you do that, then pass it across to the ASP.NET application to display. If you are using an MVC type of architecture then your model needs to be populated from the performance counters.
Duncan Edwards Jones 25-Aug-14 4:00am View
Performance data from the web page server or the client?
Duncan Edwards Jones 19-Aug-14 17:15pm View
..but that is the whole point - you can't call the code externally, you have to convince the third party application to call it.

To use a metaphor - your "dll injection" is like you posted a note through your neighbours door. Now for that note to have an effect, you have to convince him/her to read it - you can't read it to him outside the door.
Duncan Edwards Jones 19-Aug-14 13:08pm View
We need a great deal more information:-
1) What did you write the DLL in (is it .NET or C/C++)
2) What is the third party application
3) Does the third party application have any plug-in model

Bottom line is that you can't force your code into another application and convince it to run it if the application was not designed with that in mind - you can probably understand why that is the case?
Duncan Edwards Jones 19-Aug-14 6:20am View
Check that the property INDEXVALUE is actually being mapped to the field of the same name in your model?
Duncan Edwards Jones 12-Aug-14 9:04am View
Try stepping through the code in debug mode - does it get to the "WritePrinter" line?
Duncan Edwards Jones 24-Jul-14 5:34am View
Ah - if you aren't allowed to install an exe (which makes sense, I suppose) then you are probably going to have to add a method to your web server that does the work. You can then trigger that by sending an HTTP command by a scheduled task - from the web panel or from some outside scheduled app.

As mentioned below you also need to find out if you can send emails from the shared server.
Duncan Edwards Jones 24-Jul-14 5:15am View
Are you allowed to install scheduled tasks on the shared server?
Duncan Edwards Jones 21-Jul-14 12:07pm View
Reason for my vote of 5 \n Smart - I like it...
Duncan Edwards Jones 17-Jul-14 7:20am View
It does support Win7 - that's what I use.

Make sure in pPrinter you are passing the new status value, not a pointer to the new status value...
Duncan Edwards Jones 16-Jul-14 12:47pm View
So - when your printer has printed a line you want the paper to move back so the next line will go over the top of the current line?
Duncan Edwards Jones 16-Jul-14 12:30pm View
1) How are you doing the printing at the moment - by .NET PrintDocument or by direct printer commands? Please put some code for us to see.

2) What is the make and model of the printer?
Duncan Edwards Jones 15-Jul-14 4:57am View
It is free but restrictions exist on "high volume" services. You can't use this to just cycle through all the words that exist to see if they are registered, for example. Other "whois" servers also exist - each national top level domain registrar has them.
Duncan Edwards Jones 14-Jul-14 11:33am View
object obj;

This object never gets assigned to anything. It is like you have got a fresh sheet of paper from the notepad and handed it to someone to read - but they can't because you have not written anything on it.
Duncan Edwards Jones 7-Jul-14 12:07pm View
Are you passing bmpData.Scan0 by value, not by reference? (i.e. the address held in Scan0, not the address of the variable Scan0)?
Duncan Edwards Jones 7-Jul-14 4:50am View
But a date is not a varchar - if you have a date and the parameter type on the table/database is a date don't convert it back and forth through a string.
Duncan Edwards Jones 7-Jul-14 4:47am View
Have you copied your batch file (C:\New.bat) onto the server(s) that this process is running on?
Duncan Edwards Jones 4-Jul-14 8:46am View
Excellent thanks - I had completely forgotten the new() constraint.. many minds make code work :-)
Duncan Edwards Jones 1-Jul-14 4:20am View
* What kind of form is this - a PDF or something internal to your own application?
* How are save and print triggered - is it menu items you have coded?
Duncan Edwards Jones 26-Jun-14 6:09am View
Do you want this header and footer to appear on the form itself (on screen) or on a printed document that comes from the form?
Duncan Edwards Jones 16-Jun-14 8:01am View
This loop :-

While True
Dim client As New ClientConnection(TCPListener.AcceptTcpClient)
End While

Doesn't seem to do anything with the received client connection. Is there something in the constructor that does or..?
Duncan Edwards Jones 13-Jun-14 6:43am View
It does if you set it to true - see updated code sample.
Duncan Edwards Jones 12-Jun-14 7:18am View
is it that the form's mouse methods are not fired when you are over the picture box?
Duncan Edwards Jones 11-Jun-14 9:23am View
Reason for my vote of 4 \n Nice tip - thanks
Duncan Edwards Jones 10-Jun-14 8:47am View
In that case it is looking good. I tend to specify the type of the record key as well as the record type rather than passing an object (e.g. ) .. but this is a personal style thing.
Duncan Edwards Jones 10-Jun-14 7:01am View
GetDescription() only ever returns the description of the first item in the repository - is this what you intend?
Duncan Edwards Jones 10-Jun-14 6:41am View
Wow - never heard of that - what is your subscription/billing status? (i.e. your account hasn't expired?)
Duncan Edwards Jones 10-Jun-14 5:39am View
What does the status say on the Windows Azure console?
Duncan Edwards Jones 19-May-14 10:43am View
Is the CPU being read from _within_ that process?
If so, maybe it can only be read when that process has (some of the) the CPU and so it will therefore not reflect the true reading...?
Duncan Edwards Jones 18-May-14 17:13pm View
Is the CPU being read from _within_ that process? If so, maybe it can only be read when that process has (some of the) the CPU and so it will therefore not reflect the true reading...?
Duncan Edwards Jones 18-May-14 12:13pm View
Is your display on the performance monitor application set to "Current" or "Average" and does the CounterType of your code performance counter match that?
Duncan Edwards Jones 16-Apr-14 17:17pm View
Can you post your API declaration code - CreateFile is definitely a member of the Kernel32 exports..
Duncan Edwards Jones 26-Mar-14 13:09pm View
yeah - WCF it is... corrected.
Duncan Edwards Jones 7-Feb-14 7:18am View
That would be extremely useful - it is to go in this:- - so that my events getting saved don't have to be Serializable()...
Duncan Edwards Jones 7-Feb-14 6:33am View
No - encryption and compression not going to be needed.
Speed of access might be... but I'm not going to read (or look for) just the one property so the name-value part doesn't need to be indexed.
Duncan Edwards Jones 7-Feb-14 6:21am View
Aha - maybe BinaryFormatter is what I'm looking for, yes.

Looking to store these as a set of name-value pairs in a database table...
Duncan Edwards Jones 7-Feb-14 6:12am View
Ah - I didn't explain myself very well.
I want to serialise to/from a dictionary instead of to/from XML.
The class being serialized doesn't have any dictionaries in it.
Duncan Edwards Jones 7-Feb-14 5:20am View
Yes - neither this class nor the inherited class have a constructor without parameters.

<pre lang="vb">
Public Sub New(ByVal currencyFrom As AggregateIdentity.CurrencyAggregateIdentity.ISO_3Digit_Currency,
ByVal currencyTo As AggregateIdentity.CurrencyAggregateIdentity.ISO_3Digit_Currency,
ByVal fxRate As Decimal,
ByVal rateDate As Date,
ByVal derived As Boolean)
' Set the FX rate aggregate identifier
MyBase.New(currencyFrom, currencyTo)
' and set the other properties
m_rate = fxRate
m_pricedate = rateDate
m_derived = derived
End Sub

Currently I am saving it to XML then reading the XML into the name/value dictionary and vice versa but it is very clumsy...
Duncan Edwards Jones 7-Feb-14 5:02am View
Basically yes - the System.Runtime.Serialization DataContractSerializer can take the above and turn it to XML and then recreate it from that XML.

..but how does it create the object it is deserializing given no public constructor it can use??

Advertise | Privacy | Mobile
Web02 | 2.8.170422.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid