15,609,415 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Python questions
View Javascript questions
View C++ questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Sander Rossel (Top 200 by date)
Sander Rossel
16-Nov-20 7:07am
View
Happens to the best of us! :)
Sander Rossel
13-Nov-20 4:07am
View
This should work, assuming TextBox1 and Label3 are the correct TextBox and Label.
What doesn't work?
Do you get an error?
Sander Rossel
12-Nov-20 4:59am
View
"Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems." - Jamie Zawinski :)
A valid solution though.
Sander Rossel
19-May-20 13:24pm
View
Well, if it looks stupid and it works then it ain't stupid :D
Sander Rossel
19-May-20 8:51am
View
Yeah, it's been a while since I did that and I don't have Jenkins right now, but this should give you an idea on how to do that: https://stackoverflow.com/a/40225216
At least I know it's possible.
One other consideration.
I've worked with such setups like you describe, one model to rule them all.
Also named a canonical data model.
I'm not a fan of them myself.
It basically tightly couples all your services to each other.
I'm a fan of each service having its own model.
It gives you complete control over each service and it's hardly extra work since you have to change every service every time anyway.
Maybe you need it, maybe you don't, but it's too much work to change it now, but ask yourself if you really need it and if you have any alternatives.
Sander Rossel
19-May-20 6:42am
View
Hi pk, didn't see your comment because you replied to yourself instead of me :)
Anyway, I'm not sure how to set up a private NuGet feed on your own server, but I know you can host NuGet packages in Azure DevOps (https://docs.microsoft.com/en-us/azure/devops/artifacts/get-started-nuget?view=azure-devops).
Another option, by the way, one that I've used in the past, is to always check out two repositories in the same folders.
So let's say you have a folder myprojects.
Inside that folder you have your repositories.
projectA, projectB, projectC and sharedProject.
A, B and C reference sharedProject at /../../sharedProject/sharedProject.csproj (or something like that).
Of course A, B and C won't build unless shared is at that exact location.
However, if you check them out like that in Jenkins, which should be possible, it will build and updating sharedProject could trigger the builds of A, B and C.
Whether you'd want that is up to you.
Sander Rossel
18-May-20 15:45pm
View
Sounds like you could use a private NuGet repository with your own package that contains the POCO classes and reference that in all projects?
You wouldn't have to change your Jenkins builds because it's just another package in NuGet.
Is that a possibility?
Sander Rossel
17-Jun-18 15:23pm
View
I'm not looking for changes over time, just the best/easiest way to store the percentages.
Sander Rossel
23-May-17 17:25pm
View
Hi, not only are you replying to the wrong message, you're replying to a message from 2011 (6 years old!) that has long been resolved... Appreciate the help, but please look more closely what you're replying to :-)
Sander Rossel
24-Mar-17 12:40pm
View
I'm getting the following error: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
Gone when I change HTTP to HTTPS. Until I get it again and need to change HTTPS back to HTTP.
I can't find anything on the server.
I haven't tried requesting it using a browser. I'll try when the error occurs again.
Sander Rossel
24-Mar-17 12:35pm
View
I thought it was something with the server or network as well, but because other people do not have the problem (at the same time) it seems to be a local problem.
Sander Rossel
24-Mar-17 10:16am
View
Nope, just a server we have standing around somewhere (I can't access the hardware though).
Sander Rossel
31-Oct-16 4:43am
View
Call it simple... Algorithms aren't my strong point...
Why can't you talk Dutch? It's such a simple language (said the Dutchie).
Just saying that not everyone's like you :-)
I KNOW how to use a debugger, but I DON'T know how a quicksort works (well, I've figured that out now).
What bothered me more was that you answered my question, but never actually mentioned the quicksort that it was all about (except that it's not stable, which I already stated in my question)... :-s
Got that part figured out though, see my answer :-)
Sander Rossel
18-Oct-16 7:14am
View
I just noticed your update.
I'm simply setting the value of ints[4] to that of ints[size - 1] to assure I have a duplicate value (with different id's).
For debugging purposes it's easier to have a fixed list rather than Math.random(), but I just wrote the example to show that the algorithm doesn't work.
The problem is with the quicksort function, not the code that tests it.
I'm actually starting to think the problem may be that if the values are the same, but the indexes aren't I should not only not skip the value, but also check if the index is higher or lower and then swap based on that. I tried it, but it didn't work, so perhaps I'm missing something else as well.
What I'm not missing is the headache this gives me though... Algorithms never was my strong point.
I've currently got another, much slower, implementation that's stable, but not quite so quick...
Sander Rossel
18-Oct-16 3:09am
View
for*...
Sander Rossel
17-Oct-16 11:33am
View
So... Your advice is to "fix" a while loop (that isn't even in my algorithm) and keep trying? That's not really the "help" I was hoping for...
I do know how debuggers work (and, unfortunately, Chrome is not my definition of a good debugger), I've successfully used them for years (and sometimes, like now, less successful).
And I also know quicksort in its simplest form isn't stable, hence my attempt to get it that way.
I guess I'll try again tonight with a fresh look on the matter.
Sander Rossel
19-Nov-15 3:20am
View
"Simply" creating a tree-structure is easier said than done :)
And no, my source may not be well-formed, it's turning out to be quite a PITA... :(
Sander Rossel
18-Nov-15 13:31pm
View
Thanks, that gave some good ideas!
Marked as solution and rated 5.
Sander Rossel
18-Nov-15 10:30am
View
All objects that are not enclosed by start/end markers go into some anonymous marker (a placeholder if you like).
Multiple objects could go in the same anonymous marker.
Sander Rossel
18-Nov-15 6:35am
View
I can't change the underlying data structure, that would present a whole lot of problems (code-wise, project-wise, financial-wise, etc...).
I'm getting the data how it is and it's up to me to do anything with it.
Sander Rossel
8-Nov-15 17:00pm
View
Well, it was worth a shot. Solved a problem of mine that I'd been working on for hours once...
Good to see you've got it fixed ;-)
Sander Rossel
8-Nov-15 9:07am
View
Not trying to be a smartass, but have you tried restarting the computer?
Sander Rossel
31-Oct-15 12:17pm
View
Thanks! :-)
Sander Rossel
16-Jul-15 4:21am
View
That was one of the resources I found, but didn't fully understand.
Man, making a simple backup sure isn't simple :-p
I got why the log backup isn't working though, so that's something I can fix.
Thanks for your help!
Sander Rossel
16-Jul-15 4:06am
View
Oh, right! I think what I failed to mention is that I delete all files after they've been moved to another location, so each backup creates a new file.
That's fine for the full and differential backup, but I shouldn't delete the log backup file and instead just append to it each time (until a new full backup is taken).
That's why it's giving me the error (I only have the very latest log backup).
Sander Rossel
15-Jul-15 11:23am
View
Thanks for your reply.
I'm not sure I get what you mean. What do you mean with 'device'? The data isn't in one file, right? It's in three files, the full, diff and tran files.
File by file would work, but I don't understand the error I get.
If I simply get all the latest files it should be alright, right?
Sander Rossel
31-Mar-15 16:54pm
View
What's not fun about it? If you think creating well designed, fast, responsive, yet readable and maintainable applications that help your customers do whatever it is that needs doing isn't fun then perhaps you've chosen the wrong profession.
Sander Rossel
25-Feb-15 13:18pm
View
It wasn't so much about the CTE as it was about returning data in that format :-)
But thanks for your comment. CTE's are indeed great for readability and often performance too.
Sander Rossel
25-Feb-15 7:47am
View
Thanks for the link, but it's not quite what I'm looking for :-)
Sander Rossel
25-Feb-15 3:57am
View
Step 1 did not solve my issue.
This is not on the web (database running on Windows Server).
I'm going to stick with just calling a batch file from my job. That does seem to work.
Sander Rossel
25-Feb-15 3:54am
View
Thanks for your answer. Unfortunately it did not solve my problem.
I tried using && between commands and putting them all on the same line, but it said the syntax was not valid.
Perhaps I should use a proxy account?
Too much hassle... I'll stick with executing a seperate batch file. That seems to work...
Sander Rossel
24-Feb-15 13:54pm
View
I'm trying to create a job that makes a backup of the database (step 1) and then zip that backup file (using 7zip) and move it to an FTP server (using WinSCP) (step 2). I'm trying to realize step 2 using a batch script.
So I'm having a little difficulty getting the batch script to run. Well, actually I got it now by executing a file directly (rather than put the contents of that file in my step).
Sander Rossel
24-Feb-15 11:03am
View
That would be useful! How does that work?
The file currently looks like this:
%BACKUP_DIR%7za.exe a %BACKUP_DIR%zips\%DATABASE_BACKUP_NAME%.zip %BACKUP_DIR%%DATABASE_BACKUP_NAME%
%BACKUP_DIR%winscp.exe /script=%BACKUP_DIR%winscp-synchronize-script.txt /parameter %BACKUP_DIR%zips\ %SFTP_ROOTDIR%/SQLServer
The variables are simply set at the top of the file.
I've never worked with this before and I simply want to zip and move a database backup to an FTP.
I'm currently just calling the script from my job, but I'm still curious why I can't just use those commands directly.
Sander Rossel
24-Feb-15 10:58am
View
I figured that out. I already deleted that part.
I did that because I have no clue how this stuff works and I found it on the internet.
If I knew I wouldn't be here ;-)
Sander Rossel
16-Feb-15 9:48am
View
The article by Erland Sommarskog helped me find the problem and solutions. One problem was indeed ARITHABORT, but that was not all. Parameter sniffing was the real culprit. Created a local variable inside my function, assigned it the value of the parameter and used that in the query. Problem solved. Took me almost an entire day, but it was worth it :-)
Sander Rossel
13-Feb-15 15:21pm
View
I've created an index which helped pretty much for the times it runs instantly.
I think darker forces are at work here. I think the articles provided by Richard Deeming will help solve this issue :D
Can you believe I know people who think developers shouldn't touch the database? Try to have a DBA with no programming knowledge solve this... (and that's actually what those people expect will happen too!)
Sander Rossel
13-Feb-15 15:03pm
View
Perhaps because the date was indexed? In my experience dates are usually pretty slow, because they're (almost) never a primary key and people don't bother creating other indices :-p
Sometimes tables are heavily queried on date because users often want to see records for a specific date, month or year and if you have some bright guys those date fields will be indexed making your queries on dates go a lot faster :-)
Sander Rossel
13-Feb-15 14:41pm
View
Won't it simply look at what indexes are available and pick the one it can work with best?
Sander Rossel
13-Feb-15 14:34pm
View
Awesome, thanks! I actually had a similar problem a few months back and wasn't able to solve it back then. This may be just what I need!
I'm going to look at this first thing next monday :)
Sander Rossel
13-Feb-15 11:58am
View
Yeah, I prefer ordering in my application too, but it shouldn't make the function come to a grinding halt either...
Sander Rossel
9-Feb-15 15:26pm
View
Actually I'm using Entity Framework for this. I don't really need data binding and such as I have to convert my result to ISomething to pass into an ExcelConvertor. I'm trying to go for one ordered result set so I can simply do a foreach loop and restore the master-detail relationship in my objects. If I get a user the next result is either another user or a detail of that user, etc. I could use LINQ, but with large datasets I'd potentially have to loop A LOT to get everything back together and I need all the performance I can get.
Sander Rossel
9-Feb-15 14:56pm
View
Ok, I was trying to play this nice and promise you shiny points.
Truth is I don't care about your rep, but I really like to close my questions. Not doing so feels like leaving open ends ;-)
Now I'd feel bad for selfishly giving you points :-p
Sander Rossel
9-Feb-15 14:39pm
View
Nice! Post it as an answer so I can accept (you were the first to confirm, so I guess you deserve the points) :-)
Unless someone is going to point out issues after all, in which case I'd have to downvote you to oblivion ;-p
Sander Rossel
9-Feb-15 14:37pm
View
Keys and indexes, sure. But some constructs are performance killers by default :-)
I've made my query go from 5 minutes to 4 seconds simply by moving a join from a subselect to the overall select statement. Both were indexed, but having to join once is a lot quicker than having to join a 1000 times (that slipped my mind for a second) :-)
By rewriting this particular query I made something go from 10 minutes to 2-3 seconds by the way, so I guess it's a WIN situation either way :laugh:
Sander Rossel
9-Feb-15 14:34pm
View
You mean have the procedure return two result sets?
I'm using .NET and I'm very well familiar with my options.
I'm just not sure if this is the right way to go for my SQL query ;)
Sander Rossel
12-Jan-15 16:09pm
View
Thanks for your reply.
I tried that, but even that didn't work.
It seems the value is set per thread, so if I set it on a different thread the value on my main thread won't be updated...
Sander Rossel
13-Nov-14 5:06am
View
Added the generated code.
Sander Rossel
12-Nov-14 14:43pm
View
I'll see what I can do when I'm at the office tomorrow (it's a problem at work).
Sander Rossel
12-Nov-14 14:43pm
View
Nope, it's not.
Sander Rossel
5-Nov-14 15:01pm
View
I think you're right that it'll cost too much of our time. This is a work related issue. As such I'm not allowed to post our codebase or model (which is Dutch anyway, so I'd have to translate). I'd have to create it from scratch, probably using different terminology.
I think I'll let it rest for now, but I might be back in the future :-)
Thanks for trying to help anyway!
Sander Rossel
5-Nov-14 13:56pm
View
Then what do you suggest? Without changing the database...
I'm a bit stuck here.
Sander Rossel
5-Nov-14 11:28am
View
Yeah, I do, but that would mean I can't use properties (I think).
Sander Rossel
5-Nov-14 10:23am
View
Well, you're right, nothing is impossible, but this hard-coded value isn't the problem (or maybe it's a small part of the overall problem or maybe a symptom of the problem). Moving it to the database won't make me popular with my boss or with the client though. So I see no reason to change this after 20 years of hard-coding this value. If I wanted to fix the domain model we're probably looking at a few million $ project and years of coding...
I was just looking for a method or pattern or something to make my code more clean and readable.
Sander Rossel
5-Nov-14 4:10am
View
You are correct that Quality is an option. The product here is food and the quality of the food is an option (in particular meat, is the animal the meat came from fat and healthy, did it eat grass in a meadow or has it lived in a factory, all those factors decide the quality). So we can have two steaks, one of good quality and one of mediocre quality.
So yes, you could say my product was a car and the quality is actually a color (it's the same scenario). The user picks a car (or brand and type) and can then pick some additional options, like color. Some brands or types may not be ordered in any color and some have a default color or only one color. Replace car with the more general 'product' and color with quality and you have the scenario I'm having.
Unfortunately it's really not possible to not hard-code those values. They're hard-coded in many tables, stored procedures and applications. As a rule if (something) { quality = x }, I have little to say about the matter. I'll be gone here in two months, so I'm not going to fight for it either ;-)
Sander Rossel
4-Nov-14 13:47pm
View
I'm afraid that won't change much to the readability of my code. While I agree it could work for one or two properties, will it work for twenty? And I also need to raise the PropertyChanged event whenever a value changes or my binding won't read the change.
Sander Rossel
4-Nov-14 13:44pm
View
Thanks Sergey, you are absolutely correct in that I know the technology.
The goal of the application is actually pretty simple! I can't change the domain model, so that's a given.
Basically I have a form with fields like product, quality, productiondate, order, etc. The user chooses a product (all other fields are disabled) and the next field (in this case quality) is enabled. If the product can be deliverd in multiple qualities the user has to pick a quality and the other appropriate fields are enabled. If the product supports only one quality that quality is chosen for the user and the other appropriate fields are enabled.
Next to that there's some other properties, like the product has a production product and some other properties that are set automatically.
There are some fields on the form that show the value of a product OR an order OR an assignment, dependent on whether the user has chosen an order and/or assignment. The difficulty here lies mostly in the domain model that makes no sense on certain points, but I can't change that.
But in essence it's the user fills out a field and some other fields are filled with a default value dependent on the field the user edited. Repeat with other field.
And that's where my example comes from: Product fills Quality fills Price, but also Product fills Price. Result: filling a product fills Price twice. Solution: don't fill Price on Product. Problem to solution: not transparent, forget to empty Price when emptying Product, or emptying Product and Quality while Quality is emptied by Product...
Sander Rossel
4-Nov-14 13:29pm
View
Agreed. I know events and I know how they can help. I just don't feel that they offer much in the situation I'm currently having.
I'm having a hard time doing, as you put it, "the general code design, analyze the application aspects first" though.
Sander Rossel
4-Nov-14 11:39am
View
I have no idea how I would do that (yes, I am very much aware of how inheritance works, but there's actually a property that indicates what qualities may be used, but only if the product is of a specific type, really you don't want to know). Ultimately there may be one quality (which I have to hard-code since it somehow doesn't fit in the model) or up to five qualities that the user can pick.
Next to that I don't know what I would get out of that... The user still needs two lookups, one to pick the product and one to pick the quality.
Sander Rossel
4-Nov-14 11:24am
View
Well instead of having a property like this
set
{
_MyProp = value;
// Do stuff...
}
I now get:
set
{
_MyProp = value;
// Raise event.
}
void OnMyPropChanged(object sender, EventArgs e)
{
// Do stuff...
}
So nothing would change, except that I'd put it in an event.
Except maybe the PropertyChanged event (ALL my properties raise PropertyChanged to update my bindings). Also see my comment to Sergey's answer.
Sander Rossel
4-Nov-14 11:08am
View
Wouldn't that simply move my code from the setters and into the event handlers? Except that I've now created an extra layer of notifications...?
Sander Rossel
4-Nov-14 11:05am
View
In this case a Product can have different qualities. So the user has to pick one, but not change the actual (default) quality of the product. Ultimately I need to create a record that says the user picked product X with quality Y.
And stuff gets even more complicated... I have a property which comes from product, but after that the user can pick an order that can override that property. It's so bad that I have four sources for the same value! And some take precedence over the other. So the product says it's A, but the order says it's B, then there's an internal order that says it's B, but some assignment that says it's actually A. And these are actually customer specifications.
I had no say in the domain model, I'm just trying to work with it...
Sander Rossel
4-Nov-14 10:51am
View
So how am I going to bind editable fields to read-only properties?
I don't think I understand your solution...
Sander Rossel
4-Nov-14 10:35am
View
I'd need to call Initialize every time I set a Property? Anyway, my WinForms binding isn't going to call an Initialize method.
Sander Rossel
4-Nov-14 10:32am
View
Well I would say it's a common problem, although I understand your comments.
In my case I have a property Product, which has a default Quality. So when I set Product then the Product setter sets Quality. When I have Product and Quality I can calculate the default Price, so I need to calculate the price when either Product or Quality changes, except I know Product already sets Quality and Quality sets the Price, so now I won't set Price in Product because I let Quality handle that.
It seems like a common scenario that when the value of a property or a group of properties changes that other properties need to change which causes a sort of chain reaction.
So you say the 'general design' of my code is problematic. How would you handle this scenario?
I've been thinking to use the PropertyChanged event, but that would move almost all my business logic into a single event and I would need to work with strings, as that is what PropertyChanged gives me. At least it would make me say something like if (propertyName == "Product") { // set Quality } if (propertyName == "Product" || propertyName == "Quality") { // set Price }
And in that case I could maybe even keep a list with methods to execute. So in this case Price would be set twice (once by Product and once by Quality), but if Quality notices a SetPrice is already scheduled it could skip the SetPrice.
Sander Rossel
4-Nov-14 10:11am
View
Yes, I would make a single method, but not all properties need to set the same other properties. So there isn't really a single method...
Having flags like _updatingPropB and then saying if (!_updatingPropB) { ... } doesn't make the code much better. I now have even more variables to worry about!
In my particular case it's pretty easy since I can check if the current value is different from the new value, but it still doesn't feel good that I have to do that kind of thing.
Sander Rossel
4-Nov-14 10:07am
View
So how do I set property B if property A changes and all I have is my binding?
I know this solution has some problems, but I haven't heard anything better yet ;)
Sander Rossel
14-Oct-14 14:39pm
View
But where will you find that one stored procedure? Was it file one, or file two, or...? ;-)
Sander Rossel
13-Oct-14 16:38pm
View
That will leave us with a lot of files! That won't make it any more clear I'm afraid...
Sander Rossel
8-Oct-14 7:10am
View
Yeah, we didn't want to do that because we already have about 30 SP's with those kind of names... So changing that would mean we'd have to change other SP's and software too.
Sander Rossel
8-Oct-14 5:46am
View
Yeah, you can, but in the underlying edmx file the function names get changed causing your (self-named) function imports to lose their mappings.
Sander Rossel
29-Jun-14 5:45am
View
Good question. This is a problem I also encountered when first starting with the Entity Framework. Please see my solution for a full explanation :-)
Sander Rossel
29-Jun-14 5:44am
View
Your answer does not help the op. The problem is not that he doesn't know how to add or update, the problem is that the table is not created in the model.
Please see my answer for an explanation of the problem and a solution.
Sander Rossel
18-Jun-14 11:54am
View
Thanks for the comments Paulo. With all the answers and comments combined I think I'm getting an idea of how you could solve such problems :-)
Your help is much appreciated.
Sander Rossel
18-Jun-14 11:49am
View
I think I pretty much get the point (although writing something like that is a complete different matter) :-)
Thanks again for your help. It is very much appreciated.
Sander Rossel
17-Jun-14 16:33pm
View
Hi Paulo, thanks for your answer.
Let's take your advice into my example.
I would have a Room object which has some rules: VisitedAtLeastOnceBeforeMission and VisitedAtLeastOnceAfterMission?
So my character enters the room and the code goes:
if (!???.MissionCompleted && !room.VisitedAtLeastOnceBeforeMission)
{ scene... }
else if (???.MissionCompleted && !room.VisitedAtLeastOnceBeforeMission)
{ scene... }
else { ... }
perhaps 'room' can be replaced by 'this' if the code is running in the Room object.
That can't be right.
VisitedAtLeastOnceBefore/AfterMission could be stored in the Room object (perhaps in different states, like Sergey suggested), but where would the MissionCompleted come from? The player Object perhaps?.
Am I understanding you correctly?
Sander Rossel
17-Jun-14 16:22pm
View
Have you read Sergey's answer and my follow-up question? Is that the kind of state (machine) you're talking about?
So suppose I have a magical chest and the only way to open it is by telling it the magic word. The only way of knowing the magic word is by talking to some guy at the other end of the world. The magic word isn't something in my loot that I can iterate through. The only way of knowing if I talked to that guy is probably some flag somewhere, right?
So wouldn't you get something like:
if (talkedToMagicWordGuyFlag)
{
trunk.Open();
}
?
Perhaps I'm very stuck in thinking in if-statements...
Sander Rossel
17-Jun-14 16:09pm
View
Thanks Sergey. A naive question is often an understandable question. And everyone understands non-technical talk.
Posting my train of thought and questions that arise from it probably gives me better answers than to type some technical words, like state machine, that I don't fully understand.
It might get the reader on the wrong foot and I won't get the answer I'm looking for.
I'm not so sure if I'm happy with being called a beginner though.
Well, in game-development I guess I'm not even beginning, let alone beginner :-)
I've already posted a follow-up question. I hope to get to the bottom of this (this state business is already very interesting and I might know where to successfully apply it in my every day job).
Sander Rossel
17-Jun-14 15:59pm
View
Hi Sergey, thanks for your answer. It just so happens I read something about the FSM (and some other state machines), but didn't see how they would solve the problem.
Let's take my example. Would it be correct to say the game has the following states:
1. Pre-mission, pre-enter room state.
2. Pre-mission, post-enter room state.
3. Mission state (this is probably a part in the game where you can't even get to the room).
4. Post-mission, pre-enter room state.
5. Post-mission, post-enter room state.
Or would the following be more suitable?
1. Pre-mission state.
3. Mission state (this is probably a part in the game where you can't even get to the room).
3. Post-mission state.
Where the fact if you have entered the room at least once is stored in a flag in the Pre- and Post-mission states? A scene is triggered using a regular if-statement.
That basically eliminates the need to keep a flag if you have completed the mission (which will probably save a lot of if-statements, for example for every reaction of the people in the room).
On top of that many flags can be contained in a state (where the flag makes sense), rather than as some global variable. For example the enteredRoom flag is meaningless in the Mission state.
But that still leaves a lot of room for variables that can't be tracked by state.
For example, suppose there is a chest in the room. You can open it before the mission and the chest will still be open after the mission (so it's basically a variable that travels with states, or perhaps is state-less). Would this still be some global variable and a piece of code at Room_Load() { if (chestOpened) { DrawChestOpen(); } else { DrawChestClosed(); } or some such?
Sander Rossel
23-May-14 17:22pm
View
Do you realize that the * symbols aren't your ACTUAL server, database, username and password and that they have to be replaced by what your server, database, username and password REALLY are?
Sander Rossel
21-May-14 8:31am
View
My 5. You're suggesting the same solution as me, but you just beat me to posting it :)
Sander Rossel
20-May-14 16:35pm
View
Thanks, one of the finest I've written :-)
Sander Rossel
15-May-14 15:06pm
View
My vote of 1, you just beat me to it (j/k gave a 5)! ;-)
I guess more or less the same solution as I have, just written differently :-)
Sander Rossel
8-May-14 10:40am
View
That did the trick! I was first using a CAST, but I knew CONVERT should be the solution somehow.
I still get the error that there's an error validating my formula, but I'm ignoring it and everything is fine.
Thanks!
Sander Rossel
6-May-14 16:20pm
View
Thanks, but no time is exactly what I have. I hope to spend a few hours a week on it and web development is quite a bit different than desktop development. But I wanted to learn it sometime soon anyway and at least now I have an actual life project that can be used in practice :-)
Sander Rossel
6-May-14 15:01pm
View
Thanks for the article. I'm somewhat familiar with MEF. I've used it once, as a test, so I sort of know what problems it solves.
For now it's not really applicable. Let's see if I can build a non-extensible website first ;-)
I'll keep it in mind for later though. I've already bookmarked it.
Sander Rossel
6-May-14 14:40pm
View
Thanks again for your comments. I've decided to go with ASP.NET MVC. Seems like a good place to start.
Sander Rossel
6-May-14 14:38pm
View
Thanks for your answer! For this project I'm going with ASP.NET MVC. Although it looks like I'll need to learn some PHP later too.
I'm the only developer here. I feel like this is a good chance to learn something new, but I don't want to start from scratch either, so .NET is a good choice. The application needs to be quickly made and simple at first, but might chance A LOT over time. The size and complexity will be small now, but I'm not sure how this will work out. I might be asked to write a complete web app later :-)
I'm simply going to ignore the stuff you said to confuse me because, well... It confuses me ;-p
Sander Rossel
6-May-14 14:34pm
View
Thanks for your answer. Those look like good articles. I've bookmarked them for later reading.
I've already looked at the feature list and taken into account what has already been said here I've decided to go for ASP.NET MVC.
Sander Rossel
6-May-14 5:55am
View
Nope. I want to develop for the web so it's accessible from a mobile phone or tablet.
Sander Rossel
5-May-14 17:24pm
View
It's not so much about having to learn things, it's a more general question on what direction I should take. What techniques I should consider etc. The ASP.NET vs. PHP is something to consider. I updated my question to make this clearer.
I'm not accepting right now (don't worry, I will. I know how it works) because I like to hear some more people. If I accept they can still add answers, but they might not look at answered questions.
Sander Rossel
5-May-14 17:08pm
View
Hi Sergey, thanks for your answer. It's been a while ;-)
You're right about learning what needs to be learned, but I need a little boost to get me started ;-)
Thanks for the tip on ASP.NET and PHP. I'll keep it in mind. I'll be sure to check if ASP.NET is supported by the host.
Sander Rossel
5-May-14 6:20am
View
Right, so I can get the endpoints from my configuration and create a new client instance with the specified endpoint. Very nice! I had never used it like this before.
My current code looks like this:
_client = new MyServiceClient(new InstanceContext(this)); // Grabs the default/only endpoint I guess?
Should be something like:
_client1 = new MyServiceClient(new InstanceContext(this), "MyEndpoint1");
_client2 = new MyServiceClient(new InstanceContext(this), "MyEndpoint2");
And I'll probably be doing that in a loop. The specification states that the service needs to be installed on x servers. Starting with one, but in the future possibly two or three (or even more).
Many thanks for your answer! :-)
Sander Rossel
5-May-14 5:59am
View
Thanks. That was helpgul :-)
Sander Rossel
3-May-14 2:16am
View
Thanks. Looked at your answer. Makes sense :-)
Sander Rossel
3-May-14 2:15am
View
Good tips. It's weird to have a table for each possible tradable item. Although the OP does want some additional info with each item. I suggest he uses a text field for this (so the trader can just describe his item as he wishes) or an XML field with a specific format for each pre-defined item type.
But a complete database re-design (and probably re-taking some SQL courses) couldn't hurt in this case.
Have my 5.
Sander Rossel
27-Mar-14 8:14am
View
Yes, pretty nice read. But it doesn't explain why SELECT *, in my case, sometimes is lightning fast (6 seconds faster than just some columns!) and sometimes just 'chokes'...
I'd never use SELECT * in an production environment.
Sander Rossel
27-Mar-14 7:42am
View
We all do a bit of DBA'ing here and today I'm the DBA of choice ;-)
I've checked the index and there seems nothing wrong with it.
Sander Rossel
27-Mar-14 7:30am
View
It's mostly index seek and some index scans on smaller tables. I'm allright with indexes I'd say...
Sander Rossel
27-Mar-14 7:28am
View
I've checked the estimated execution plan for the SELECT *, but there's nothing wrong with it. Lots of index seeks (afaik it doesn't get faster than that!), nested loops, merge joins, a few key lookups, a few sorts... More or less the same as the regular query.
The problem is that just now SELECT * ran perfect again!
I just rewrote the query, but starting with a different (more logical) FROM table. Guess what? SELECT * doesn't work at all and SELECT some field is just pretty slow again. The query plan shows the same as above with 66% of the cost in an index seek...
I really don't know what is going on anymore!
Sander Rossel
28-Feb-14 11:23am
View
Hi Dave,
Thanks for your reaction. I'll take your advice into account.
Sander Rossel
18-Feb-14 12:57pm
View
Hello Mehdijafari,
Taking someone's text without referencing them is considered plagiarism and in many cases and countries even illegal (imprisonment may follow! not for copying a few lines from the internet though :-) ).
Now that you've added some references and interesting links I've decided to rate your answer a 5. Those are some good reads!
Sander Rossel
18-Feb-14 5:57am
View
Thank you!
Sander Rossel
17-Feb-14 13:21pm
View
Thanks for pointing that out.
I looked up the Edward Waite Marshall thing and I did actually found it in a printed book as well: http://magic.aladdin.cs.cmu.edu/2005/08/06/higher-order-perl/
I found some other theories as well. Yours still seems to make most sense.
Sander Rossel
17-Feb-14 13:10pm
View
Thank you Pete. That sounds reasonable.
One more question though. When talking about threads do you mean something like the main thread and a worker thread in an (.NET) application? If so would it matter if the language was managed or unmanaged? So in C#, for example, does the OS take care of the marshaling or is it something that .NET does every time you synchronize between threads (for example by calling the Invoke method on a Control)? Why would an event not be suitable for invocation on another thread?
Sander Rossel
15-Jan-14 9:51am
View
Thank you Pete. I'll discuss this with my managers and see if this will help me and the company.
Sander Rossel
15-Jan-14 7:12am
View
Thanks for your answer.
That sounds reasonable. So in a call to my dll I do the following:
1. Check if our software version table is present in the database.
2. If it isn't create it.
3. Check if the record for the current dll + version is in the table.
4. If it isn't create the record with the correct version and put all database infrastructure for the dll in place.
5. If it is present, but the version is out of date update the record and update the current database infrastructure for the dll.
6. If it is present and up to date, do nothing.
Those steps should ideally be handled by a seperate dll that can perform those steps for every dll that needs a specific database infrastructure.
Speaking of release management, do you know any good books I should read?
So far our company has been manually copying dll's to our customers computer and so far this was never a problem.
More recently our company started to embrace more object oriented principles and we now split common functionality in dll's for re-use.
Unfortunately our release 'strategy' is not always suffient anymore and we need a more structured and automated approach.
If you know of some good book(s) I'll certainly look into it in more detail.
There are more aspects that could certainly use improvement (even though they aren't a problem yet).
Sander Rossel
5-Jul-13 13:59pm
View
Thanks :)
Sander Rossel
16-Mar-13 8:15am
View
Thanks :)
Sander Rossel
1-Feb-13 18:24pm
View
I think the disrespect for VB is a bit unfair... You should ask yourself if C# and .NET would've been so awesome if VB1-6 hadn't been around :-)
Sander Rossel
1-Feb-13 17:13pm
View
Now we're getting to the problem... Which is the following line of code:
Dim gun As BigGun = ammo.Load(Of BigGun, BigAmmo)()
That does NOT compile. I repeat, does >>>NOT<<< compile.
VB only takes one type parameter, so it should have been the following:
Dim gun As BigGun = ammo.Load(Of BigGun)()
This line of code is exactly what I would have expected in C# too. Since ammo.Load(Of BigGun) could NEVER be of another Ammo type than BigAmmo (because BigGun is a Gun(Of BigAmmo) and not another Ammo). If you know what I mean...
Sander Rossel
1-Feb-13 14:03pm
View
I don't know what line exactly, but there are a few code blocks in my question. It should be one of them. Right under 'UPDATE 2'.
Sander Rossel
1-Feb-13 11:05am
View
Have you seen my updated question? I have coded an entire sample in VB and C# and shown the differences. It compiles perfectly and you can test it yourself by copy/pasting. Of course you will need VB to test it in VB yourself...
So what I don't understand is why my example isn't good for you and why it should work?
Sander Rossel
1-Feb-13 4:29am
View
I don't understand what you mean. In your example C# and VB work exactly the same and I can't prove differently. However, in my sample, which is pretty different from yours, C# and VB DO work differently yet you say they don't. So far you have not backed up your claims or proven me wrong. VB.NET will NOT allow me to use two generic parameters and C# WILL force me to use two. I have given you my code sample to prove that VB and C# work differently in inferring generic types. I don't really care that the same IL is emitted. I code in C# or VB, not IL.
Sander Rossel
1-Feb-13 2:29am
View
Thanks for your example. Unfortunately it's still not accurate. You have added type constraints, but the contraint on First does not include Second, so Second can never be inferred from First... In my example TGun is always of type Gun(Of TAmmo), so if TGun is BigGun which is a Gun(Of BigAmmo) then TAmmo can never be anything else than BigAmmo. VB understands this, C# does not.
In your example, if First is SomethingDisposable that still says nothing about Second. So both C# and VB cannot infer the type of Second.
I have updated my question with a full C# and VB example and IL (which is the same for both languages, cannot correctly roundtrip to VB).
Sander Rossel
31-Jan-13 17:45pm
View
The Dictionary case is something completely different... There are no type constraints on TKey and TValue, so TValue could never be inferred from TKey (or vice versa).
In my example I have given a type constraint on both TGun and TAmmo. Since TGun should be a type of Gun<tammo> TAmmo could always be inferred from TGun.
And actually I have given you code where you can see VB does exactly that, infer the type of TAmmo.
I have not only shown you the definiton of Load, I have shown you what it does, I have shown you Ammo, Gun<ammo> and how to use the extension method in both VB and C#...
I have tested this with just the code you see above and I am VERY sure there is ONLY ONE definition of Load... There are absolutely no fragments I am not showing you.
You can copy/paste all of the code above and see for yourself that it does, in fact, work differently for C# and VB...
Sander Rossel
31-Jan-13 17:19pm
View
I have added some code in my question for you to copy/paste.
Go and see for yourself that C# really DOES work differently than VB at this point.
Before yesterday I would've said the same as you, "VB and C# are equivalent at this point". Imagine my surprise :-)
Sander Rossel
30-Jan-13 17:44pm
View
I'll double check this tomorrow, but I'm positively sure there's a difference between VB and C# here. I didn't believe it today until I re-build and re-referenced all my assemblies in both VB and C# projects. Tomorrow I'll even give you some sample code if I can reproduce it.
Sander Rossel
30-Jan-13 17:39pm
View
I don't know much about ISO and ECMA. I'm not bothered by standards to much... If millions of users worldwide have used VB for more than two decades then who is ISO or ECMA to say that it's not a standard? Not being a standard hasn't stopped VB or its users from delivering software to customers and solving many problems and, more importantly than any standard in the world, making customers happy. So as standards is concerned I see no problem.
But I also believe each programmer should at least know C-based syntax, such as C# or Java. I am as proficient with C# as I am with VB. I recently read some C++ code samples (a language I've never used) and I didn't realize it until the fourth sample or so. Many code samples on the internet are C# too. VB is hard to find, so it's almost a must to know C# anyway.
My only problem with VB is that many of its users come from a time when OOP was not standard yet. And many modern VB code is written exactly like that too. WinForms with thousands lines of code, 'safe' casting functions that simply concatenate empty strings to any object, on error resume nexts, gotos, lots of global variables etc... Especially old VB code is often a mess like that. Often even ported from VB1 to VB2... All the way to VB.NET. VB.NET has a history and it shows. If only in the attitude people have towards VB.
I think such an attitude to any serious language is misplaced though. A language is merely a tool and as good or bad as the programmer using it. I've seen C# code that is just as messy.
I must admit that I've been using C# quite intensively lately and I'm beginning to like it a bit more than before :-)
Sander Rossel
30-Jan-13 15:23pm
View
Because it's the first language I learned at my job where everyone codes VB.NET. I actually prefer it over C# which, to me, sometimes reads like {{{{{{}}}}}}}} :-)
Let me ask you a counter question. Why are you NOT using it? It can do everything C# does. Sometimes a bit less, sometimes a bit more and sometimes a bit differently. To me it's mostly a matter of syntax. And I slightly prefer VB syntax over C# syntax. Probably because it's my first language.
Sander Rossel
30-Jan-13 15:19pm
View
VB.NET simply says there's only one type parameter, which is TEntityItem. Whenever I specify the type of TEntity it gives an error saying there is only one type parameter.
In C# I have the exact opposite. I have to specify two and if I only specify one it gives me the error that there is no constructor with only one type parameter.
I find it very confusing that VB.NET and C# work so differently at this point. That's why I thought I might be missing something.
Sander Rossel
30-Jan-13 13:33pm
View
I'm not TRYING to write only one in VB.NET, I'm FORCED to write only one in VB.NET.
Appearently VB.NET can infer the type of TEntity since it's the same as the type of TEntity in TEntityItem.
C#, however, can't infer the type and you have to specify it.
This just struck me as odd since there is no reason why C# can't infer it while VB can.
Not having to type in the type which is already exposed in TEntityItem seems logical to me and gives quite a bit of comfort and cleaner code.
Sander Rossel
22-Jan-13 9:55am
View
Well, Sergey, today I finally found a solution to my problem. I went for a different solution, which is: whenever a HeaderBarComponentBase descendant is dragged onto a Form designer the HeaderBarComponent is automatically put into the HeaderBar (whatever that may be).
I gave my HeaderBarComponentBase a Designer (Inherits System.Windows.Forms.Design.ControlDesigner) and override the following methods as follows.
I just thought I'd share the solution since you put quite some effort into it as well and might be interested in the solution :-)
private IComponent _host;
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
{
defaultValues["Parent"] = _host;
base.InitializeNewComponent(defaultValues);
}
public override void Initialize(IComponent component)
{
base.Initialize(component);
this.FindHeaderBarHost((component.Site.Container as IDesignerHost).RootComponent);
}
private void FindHeaderBarHost(IComponent parentComponent)
{
IHeaderBarComponentHost host = null;
Control parent = parentComponent as Control;
while (host == null && parent != null)
{
host = parent as IHeaderBarComponentHost;
parent = parent.Parent;
}
if (host != null)
{
host.HeaderBarComponents.Add(this.Control as HeaderBarComponentBase);
_host = host.HeaderBarComponentHost;
}
else { throw new InvalidOperationException("A headerbar component cannot be added to a container that does not implement IHeaderBarComponentHost."); }
}
Sander Rossel
21-Jan-13 17:31pm
View
Well, you make all valid points here. I'm going to accept your answer.
Thanks for the interesting discussion :-)
Sander Rossel
21-Jan-13 16:58pm
View
Well, that's good and all, but it doesn't solve my problem. And I can't tell my boss and colleagues, who have been using WinForms for years, "well guys, let's just don't do this anymore". I'll be keelhauled :-)
I also don't see how things are repeated? Controls have a huge inheritance hierarchy (which hints to some re-use) and other than that it's just a huge list of constructor calls and setting properties. Now something that could've been avoided by a for loop or something.
Anyway, by saying "I understand why design time creates the problem here" do you agree with me that my idea of looping through types in an assembly is simply not possible or desired? :-)
Sander Rossel
21-Jan-13 16:07pm
View
The problem is that I am creating a development tool. A base form for our programmers to make their life easier and to force them into a direction that ensures a common style among forms. That means the assemblies are loaded at design time. If an assembly is loaded you cannot simply replace or rebuild it, which means the assembly should be unloaded first. How would you do that since assemblies can't be unloaded unless they're in a seperate appdomain? And how to trigger the unloading? And if the appdomain is unloaded will the application still work since it now uses objects from assemblies that aren't loaded? And if I get all that right how do I tell my less skilled colleagues how to create and load plug-ins... I am actually re-writing this thing because it was too abstract for my colleagues to work with. They needed something simpler.
That's why I went with the idea to simply load the types from the assembly you're currently working on, but then I stumbled upon the problem that this assembly is not loaded, and for a good reason. From there it kind of escalated to the point where we are now :-)
I like your idea of using assembly attributes by the way. I will certainly be using that in the near future. Unfortunately I still don't see how it helps in this scenario.
Sander Rossel
21-Jan-13 6:27am
View
You're leaving a smiley, but no answer? That's not something I can smile about... You were my only hope for success!
Of course I know better than that. You will come with an answer that will blow my mind and all of my problems will be solved, right? :-)
Sander Rossel
21-Jan-13 3:48am
View
Ahhhhhh! NOW I understand what you mean. I am indeed stuck in a certain train of thought and perhaps I should just move out of it :)
Allright, so here it goes again.
I am creating a base Form for my compnay. Now I have a component called the HeaderBar which is basically just a FlowLayoutPanel. In this HeaderBar you must be able to put Controls that Inherit from HeaderBarComponentBase (which Inherits from Control). This Control, of course, does some stuff which is HeaderBarComponent specific such as regulate the size of the component.
Now the thing is I want programmers to be able to Inherit from this HeaderBarComponentBase after which their own HeaderBarComponent can be placed in the HeaderBar. HeaderBarComponents should not be placed on the Form, company policy to enforce certain layout rules.
So to accomplish this I am working with a custom CollectionEditor which loops through the types in an Assembly and checks for HeaderBarComponentBase types. If HeaderBarComponents are found you can add them using the CollectionEditor whose collection notifies the Form which places them in the HeaderBar.
The difficulty lies in that HeaderBarComponents cannot be dragged in the HeaderBar because the HeaderBar is part of the base Form and is not accessible to inheritors.
Sorry I couldn't explain this earlier. I was to focused on looping through types in an Assembly.
Perhaps I have indeed chosen a wrong approach and I need to let go of the idea to check for types in Assemblies.
Your idea's are greatly appreciated and more than welcome.
Sander Rossel
18-Jan-13 15:35pm
View
While I appreciate your help and good advice you never mentioned anything about design time Reflection and Assemblies, though I did mention design time in my question. So I gave you a 5 for the information, but it did not actually solve my problem.
Are my goals still not clear? Unfortunately I can't make them any clearer in words, so my apologies for that. Formulating a correct question can sometimes be as hard as finding the correct answer to that question :)
I'll give it another shot.
I have two assemblies, A and B. B references A. Assembly A has a Control which has a list of IHeaderBarComponents. When you click on the 'edit' icon in the property window (WinForms) you get the default collection editor. Now what I want is that the user is able to select ALL types that inherit from IHeaderBarComponent in both assemblies A and B. That would require me to loop through all types in Assembly B, which is the project I am currently working on. Unfortunately this Assembly is not loaded in the AppDomain and as such I cannot get information on the types in that Assembly. Loading Assembly B manually would result in not being able to compile it anymore because it's running.
So that's why it's not possible to iterate over every type in Assembly B from Assembly A.
well, that was a final try at describing my problem. I'll try to keep future problems a bit simpler to explain and answer... ;)
Sander Rossel
18-Jan-13 6:28am
View
Hi Sergey,
I'm sorry for my belated reply. I've been busy, but I've also found out why it is not possible what I want. See my own answer for details.
If you have any questions or remarks you're welcome to ask. If you still want a prototype for personal interest let me know and I'll create one for you which explains the problem.
Thanks for your help. It is greatly appreciated.
Sander Rossel
14-Jan-13 4:23am
View
Thanks Sergey, I have updated my question to make my ultimate goal more clear. If you have any questions I will try to explain it further.
Once again your help is greatly appreciated.
Sander Rossel
14-Jan-13 4:22am
View
Hi Sergey,
Thanks for your answer. I didn't know the IsAssignableFrom method. Exactly what I needed. However, this still does not fix my problem. All my methods, and also your recommendations, seem to work perfectly well at run-time, but my code executes at design-time.
Also, the Assembly which checks for types of IHeaderBarComponents is referenced by an Assembly from which the IHeaderBarComponents come from. Somehow it does not recognize the IHeaderBarComponent Type from the other Assembly.
I have updated my question, hopefully this will make the problem, and my goal clearer.
Sander Rossel
8-Jan-13 11:04am
View
Exactly what I was looking for!
Sander Rossel
4-Jan-13 13:22pm
View
Thanks. I hate it when people find solutions to their problems, but don't tell what that solution is. I did not intend to do that ;)
Sander Rossel
4-Jan-13 6:43am
View
No, I mean I added all the Controls in the Winforms designer, but my function was called in InitializeComponent (the designer generated code) before all the Controls were added to the Form. The EndInit of ISupportInitialize is called at the end of InitializeComponent (after all the Controls are added to the Form) and fixed my problem.
Sander Rossel
2-Jan-13 1:21am
View
Thanks Sergey. And a happy new year to you too!
Sander Rossel
23-Dec-12 10:43am
View
Accepted :)
Sander Rossel
23-Dec-12 7:55am
View
Compile options are exactly the same for the projects that work correctly and the project that doesn't. 'Enable optimazations' is off for all projects.
So I turned it on for the project that wasn't working correctly and it works again. When I turn optimazations off again it keeps working...
Good to know compilation is basically a game of Russian roulette... =/
Thanks for the help! You should add this as a solution so I can accept it as an answer.
Sander Rossel
24-Nov-12 12:02pm
View
I'd say it's not a win or loss for either language. You just have to know how it works :)
Sander Rossel
24-Nov-12 5:57am
View
Thanks for the answer. Going all the way to IL surely proves the point ;)
I'm still surprised that it doesn't matter wether I declare j in or outside a For loop though. At least in VB (the same goes for C#, but unlike VB you're forced to assign a starting value to a variable before doing anything with it, eliminating the chances of still having a previous value).
Sander Rossel
24-Nov-12 5:52am
View
Guess I missed that part... But it is exactly what I'm experiencing.
Sander Rossel
18-Oct-12 2:04am
View
Quite possibly some code in your event... If you could post the event here too someone might have an idea. Use the improve question button in the right lower corner of your question.
Sander Rossel
30-Sep-12 17:03pm
View
Sorry, that's not what I understood from your question. Anyway, if all you need to do is backup files I'd say the only thing you need to send through the network is the date of the file and the file if the dates differ. AFTER you've compared the dates you can send the file and compare it. I can't help you with the algorithm necessary to compare two files. This is specialized work and if I could do it I would probably be making a lot more money at some big company :)
Sander Rossel
30-Sep-12 11:49am
View
Very good answer, my 5! Interesting to know how and why Mono works. Good links too.
On an unrelated note, it seems you've given two answers to this question, one which was unintended :)
Sander Rossel
30-Sep-12 11:47am
View
Thanks :)
Sander Rossel
30-Sep-12 10:58am
View
It is? ;p
Actually it's how our living room is organized.
V = Television
C = Chair
H = Couch
T = Table
V C
H
TT H
TT H
C
Something like that. Works wonderfully well :)
Sander Rossel
30-Sep-12 10:11am
View
Television goes in the corner, couch facing it, a chair facing the couch diagonally, table in the middle...
Sander Rossel
30-Sep-12 5:52am
View
Thank you :)
Sander Rossel
30-Sep-12 5:49am
View
Good answer and nice link, my 5.
Sander Rossel
22-Sep-12 3:47am
View
Actually I would not use the Validated Event at all. The only thing it allows you to do is trap the user in a Control (e.Cancel), it's the most annoying and user UNfriendly thing I've ever seen and used. Better is to look at the ErrorProvider Component (http://msdn.microsoft.com/en-us/library/system.windows.forms.errorprovider.aspx) and the IDataErrorInfo Interface (http://msdn.microsoft.com/en-us/library/system.componentmodel.idataerrorinfo.aspx). You can neatly do your validations in your business layer (where I think they belong) and clearly, but non-intrusively, show any errors to your users (without trapping them in a Control).
Sander Rossel
21-Sep-12 18:53pm
View
How about when the user clicks the 'Next' or 'Close' button (or FormClosing Event of the Form)? :)
Simply loop through the Rows of the DataTable until a DataRow.RowState returns anything else than Unchanged.
Sander Rossel
21-Sep-12 18:51pm
View
There's a few issues with this approach. First, it only works on TextBoxes, while I'm sure there might be some ComboBoxes, CheckBoxes, RadioButtons, etc. on an average form. Second, it won't work for Controls in any ContainerControls such as Panels, GroupBoxes, TabControls and SplitContainers. The latter is easily fixed by making your method a recursive one. The first isn't so easily fixed. You could use something like the Validated Event for each Control.
The following code fixes these issues (untested):
Private Sub AddValidatedHandlers(Byval c As Control)
If c IsNot Nothing Then
For Each ctrl As Control In c.Controls
AddValidatedHandlers(ctrl)
Next
AddHandler c.Validated, AddressOf Control_Validated
' Alternatively: AddHandler c.Validated, Sub (sender, e) changed = True
End If
End Sub
Now simply call the function as follows:
AddValidatedHandlers(Me)
My biggest problem with this approach, however, is that the moment values are changed 'in the background', or through some other means (for example a pop-up form) your logic is flawed. Only one Object knows if it has been changed or not, and that is the Object you're binding to. In this case the DataRow (which conveniently already tracks if it has been changed for you!). I really suggest you handle logic such as this in the 'business layer' rather than your UI layer.
Sander Rossel
3-Aug-12 14:54pm
View
My apologies if I sounded rude. The reason you might find that people on forums such as this are a bit rude and first answer you should use Google is also the answer to your last question: "Do you really think somebody asks a question like this without first looking for the answer on their own and coming up empty?".
Yes, they do. All the time. We get questions like "What is a Singleton pattern?" (which is covered in 100's of tips, tricks, articles, websites, books...) or "I need a program that sends rockets into outer space, can someone give me code?" (which requires years of experience in the field and can only be achieved by months of intensive labour).
Seriously, we get those questions! You would be surprised how many people come here and don't even ask a comprehensible question!
Also, you shouldn't forget that people are here to help you on your way, not to do your work for you. If you want to convert PDF to TIFF I can point you in the right direction (and I can't be sure of the direction you're heading), but I'm not going to spent hours and do your work for you. So posting a link to an article (even if it's not free) or even Google is not as ridiculous as you might think it is. At least it's something and as mentioned many people didn't even try Google before coming here.
If you searched Google for hours and didn't find what you wanted then I am not going to find it for sure (unless you're a very lousy Googler).
I only know non-free PDF to TIFF converters, but you can probably Google those yourself...
Sorry I couldn't be of more help than that. Good luck in your find.
Sander Rossel
3-Aug-12 13:59pm
View
You really subscribed to CodeProject to downvote an answer I gave over 7 months ago that even the poster of the question didn't respond to? Wow...
The trial of the software discussed in the article is free and could have sufficed in the case of the OP (we'll never know).
Anyway, it seems you took the time to subscribe to CP to criticize me, but you didn't take the time to get to the second part of my answer "Google yourself".
Here's a few more links I got from 1 minute of Googling. Who knows they might help.
http://pdfsharp.com/PDFsharp/index.php?option=com_frontpage&Itemid=1
http://pdflib.codeplex.com/
http://freeimage.sourceforge.net/
http://www.pdf-to-image-converter.net/pdftotiff.htm
http://www.codeproject.com/Articles/38434/TIFF-and-PDF-What-s-the-Difference-and-How-to-Conv
Etc. Etc...
Sander Rossel
27-Jul-12 4:51am
View
Thanks for your answer. We have decided to go for the IIS solution. I'll be converting my Service Library to a Service Application, so far the first tests seem to work.
Sander Rossel
26-Jul-12 8:18am
View
Yeah, I figured out the command line. Still nothing though. Keeps giving me a BadImageFormatException. I even tried running on a 32-bit machine, but without luck.
The only thing I haven't tried yet is developing the whole thing on a 32-bit machine (it's not the developing that's the problem, it's getting a 32-bit machine with both BarTender and VS2010). Right now it looks like it'll be the only option...
If you have any other suggestions I'd be pleased to hear them. Thanks for your help in any case.
Sander Rossel
26-Jul-12 3:50am
View
I'm hosting in a custom host, so both solutions sound like they should work. Unfortunately they don't. Still the same error...
I'm not using IIS, so that's not an option (yet).
Sander Rossel
15-Jul-12 2:42am
View
DON'T SHOUT! It's rude.
As for the answer... Google is your friend.
Sander Rossel
15-Jul-12 0:56am
View
By the way, on an entirely unrelated note, have you seen my latest article? It's about IL, Emit and Expression Trees. As I recall you were recently working on a Serializer using IL. I'm curious what you think of it :)
If you're interested you can find it in my articles, it's called "A Look under the hood of the .NET Framework".
Sander Rossel
15-Jul-12 0:52am
View
The first example was added to show the OP that his problem was not really a problem. The advice on the return value and Exception was the real answer. The PropertyInfo example was just added for a bit of fun :)
Sander Rossel
15-Jul-12 0:50am
View
I agree that it has nothing to do with Generics. Somehow the OP seemed under the impression that Generics were the problem here, so I showed him that it was not. I sincerely hate a success flag. I've worked on software where a 'SaveToDB' method would go 5 or 6 functions deep and every function returned a success boolean... Unless there are very good reasons not to throw an Exception (and there never is) you should simply throw one if stuff goes awry. It makes life a lot easier :)
Sander Rossel
15-Jul-12 0:45am
View
Thanks!
Sander Rossel
14-Jul-12 11:55am
View
Take heed that Reflection performs less than 'regular code'. Plus, as I already mentioned, in this case you will lose design time error checking.
See my comment above. It is the preferred method.
Sander Rossel
14-Jul-12 11:53am
View
I was talking about doing something like the following:
int i;
if (ge.SetValue(value, i)) {otherClass.A = i;}
That's probably the best you can do. It has design time type checking, does not incur the performance hit of Reflection and is pretty clear to read.
Sander Rossel
14-Jul-12 11:21am
View
My 5. Much much easier :)
Sander Rossel
14-Jul-12 11:21am
View
My 5. That does simplify things (not as simple as WesAdays answer though).
Sander Rossel
14-Jul-12 11:15am
View
I did not understand your question, but now that I see your own proposed solution I think I got it.
I think using an 'out' or 'ref' parameter is bad design 99 out of 100 times. Personally I never needed it.
Anyway, you can still use 'out' or 'ref' when using Generics. See my answer for an example.
Sander Rossel
14-Jul-12 10:33am
View
Is there even a question in there? I mean, one that us humans can understand?
Sander Rossel
13-Jul-12 14:39pm
View
Of course, 5'd :)
Sander Rossel
13-Jul-12 14:35pm
View
Reminds me of this: http://www.codeproject.com/lounge.aspx?msg=4282805#xx4282805xx :laugh:
Sander Rossel
13-Jul-12 13:33pm
View
Of course :)
Sander Rossel
13-Jul-12 13:33pm
View
5'ed. The IL is indeed the same for both (I recently wrote an article about it). The automatic private setter is a nice addition. As far as I know it's not possible in VB (which I use in my day-to-day job).
Sander Rossel
13-Jul-12 13:31pm
View
5'ed. Capitalization matters indeed :)
Sander Rossel
13-Jul-12 3:50am
View
KISS! :)
Sander Rossel
13-Jul-12 3:09am
View
Why not simply try it out...? I think the answer is yes, yes, yes, yes...
Sander Rossel
13-Jul-12 3:08am
View
Added a code block for readability.
Sander Rossel
13-Jul-12 3:07am
View
My 5. Things don't always have to be that complicated :)
Sander Rossel
13-Jul-12 1:38am
View
Thanks :)
Sander Rossel
12-Jul-12 11:49am
View
What do you mean? A PictureBox is a simple, standard, .NET WinForms Control (http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.aspx)... Anyone could drag one onto a Form and set its picture. It's not something you should 'make' yourself.
If you really did make one yourself we will need to see a bit of code to see what you've done and where you could possibly have gone wrong.
Sander Rossel
11-Jul-12 3:19am
View
Thank you!
Sander Rossel
11-Jul-12 1:54am
View
I wanted to make a point about how articles can be of great help so I needed some articles on a topic the OP would probably need. Since the OP mentioned he was going to do some database work, which in C# usually requires the use of ADO.NET techniques, I decided to look up some ADO.NET articles. Of course they could've been articles on whatever the OP needs, but other than ADO.NET I wouldn't know. Unless maybe some introductions to the C# language, but when the OP sees some examples of real code I don't really think he needs that since he should already be familiar with the syntax :)
Sander Rossel
11-Jul-12 1:51am
View
Thank you :)
Sander Rossel
10-Jul-12 19:12pm
View
By the way, it's less obvious, and you shouldn't rely on it, but I've tracked down numerous bugs by looking at the StackTrace of an Exception. For example:
at ParseField2(String)
at ParseFields(String())
at FromString(String)
The StackTrace clearly shows the Exception was thrown when trying to Parse field 2. This should be the result of good coding practices rather than a goal for debugging purposes though :)
Sander Rossel
10-Jul-12 19:08pm
View
That doesn't really change anything I've said :)
Anyway, an Exception that has a lot of detail always comes in handy ("Object not set to an instance of an Object"... WHAT OBJECT!?!?!?).
In this case you should wonder why thing could go wrong though. For example, if the String only contains numerics little could go wrong. You can throw an Exception saying "Invalid string. String contains non-numeric characters". That will be enough for most developers. If each of the elements needs a very specific format like (1st element) a hash sign, 5 numerics, a pipe (|), another numeric and a letter (just to name something weird) a more detailed Exception message would definitly help the programmer using your class.
Sander Rossel
10-Jul-12 17:48pm
View
That bold line was a hard find...
Sander Rossel
10-Jul-12 11:29am
View
UserControls definitely get my 5 :)
Sander Rossel
10-Jul-12 11:09am
View
Simple, yet effective. My 5.
Sander Rossel
9-Jul-12 17:38pm
View
Glad I could be of help :)
Sander Rossel
9-Jul-12 1:27am
View
Please show us the code of your Button.Click Event.
You are making calls to an object that is not initialized. There is no way for us to tell you which object it is.
Sander Rossel
9-Jul-12 1:25am
View
I've posted a possible solution to your problem. Although you're making a best effort at explaining the problem I'm afraid the code doesn't really help. So I hope my answer correctly addresses the problem and provides a satisfactory solution.
Sander Rossel
28-Jun-12 6:20am
View
Thank you.
Sander Rossel
28-Jun-12 6:20am
View
Thanks! So that's what SA stands for :)
Sander Rossel
16-Jun-12 5:55am
View
I really have no idea what you're trying to say...
Sander Rossel
16-Jun-12 5:30am
View
I gave you an example... Read my answer.
Just replace // Do something else with Label1.Text = "An unexpected error has occured." or something similar.
Sander Rossel
16-Jun-12 5:00am
View
By the way, I edited your answer for readability.
I can now also see you copied my code and edited it...
Sander Rossel
16-Jun-12 4:58am
View
Why globally if you only need it locally? You should keep the scope of your objects as small as possible.
Making it global makes little sense...
Sander Rossel
16-Jun-12 4:57am
View
Yes, I understand. But you must see that if the HttpWebResponse was not properly initialized for whatever reason you cannot use it.
The best you can do in that case is show something like a more general error message.
Sander Rossel
15-Jun-12 18:04pm
View
Thank you :)
Sander Rossel
15-Jun-12 15:49pm
View
Glad it helped. I have edited my solution for a little more detail and how to work around this problem :)
Sander Rossel
15-Jun-12 15:44pm
View
Indeed, use the Count or Length (extension) method or Property of collections to make sure there are enough objects in the collections before trying to access one.
I will update my answer with this :)
Sander Rossel
15-Jun-12 14:33pm
View
Yep :)
Show More