Ketsuekiame 860 Master Poster Featured Poster

If you really really want to go ahead with C# as your single language, you should look up TAO GL

Without making the COM calls to the Windows API yourself, this is about as good as it gets.

If I were you, pick up an existing game engine (Unity/Unreal) and start there.

Ketsuekiame 860 Master Poster Featured Poster

Make sure you're running it in Debug mode. In Release this could have been optimised away because you're not using the variable.

ddanbe commented: Great! +15
Ketsuekiame 860 Master Poster Featured Poster

In C# you can think of all classes as references (pointers)

Like ddanbe said above, if you really want the pointer, you can use the unsafe keyword and then use it like C++. A more safe way is to marshall it out into an IntPtr object, but this is generally reserved for interop (Win32 API) code.

Given that your code looks to be self-contained you don't need the actual pointer reference.

Quick overview:

Nearly all objects are of two basic types; value and reference. A reference type can be treated almost identically to the pointer type in C++ and value types are the same as normal definitions and primitives (such as int, float, long CMyClass)
A quick easy rule as to whether something is a value type or reference type;
structs are value types and classes are reference types.

You can also say that anything that inherits Object is also a reference type but there are special rules around this too (such as boxing and unboxing).

To make it relevant to your code:

List<CAccount> list = new List<CAccount>(); in C# is the equivalent of
std::vector<CAccount*> list; in C++

ddanbe commented: Could not have explained it better. +15
Ketsuekiame 860 Master Poster Featured Poster

Like I said, uniqueness may not be relevant for your scenario, however, you should look at ways to stop things being duplicated (such as constraints against having the same Name for example)

Ketsuekiame 860 Master Poster Featured Poster

Only two things strike me as a little off.

  1. You have no way of uniquely identifying a single "Fact". This could be important, might not be, up to you.
  2. Lists shouldn't be publically accessible. You should allow readonly access to your lists and manage them internally via class methods.
Ketsuekiame 860 Master Poster Featured Poster

If you don't want to be able to "read" your serialised list, or to be able to import from a common format, don't use XML. It can be quite slow once you get into large amounts of objects.

Have you considered using SQL Express? That way you can have a "LocalDB" that is deployed with your application and can be used to store your data. It might also be worth looking at Document Databases for something like this. A local store is small, powerful and can be updated in real-time. Using file based storage, this would be tricky (but possible, leading to a lot of disk IO)

ddanbe commented: Good advise +15
Ketsuekiame 860 Master Poster Featured Poster

Depends what you want to do with it. What scenarios are you looking for?

Ketsuekiame 860 Master Poster Featured Poster

If you look at the available constructors for StreamWriter you will see that one of them can be used to indicate you want to append to the file.

Ketsuekiame 860 Master Poster Featured Poster

You could use Username/Password based authentication over TLS, but that's not as secure as having a certificate solution in my opinion. But it's a better solution if money is a problem or you can't establish a valid certificate chain.

WCF can be configured in code or in web.config, so technically speaking, you could implement the certificate solution in code ;)

Ketsuekiame 860 Master Poster Featured Poster

There's a couple of ways.

As well as using TLS (standard SSL solution) you can also use Certificate based authentication (effectively enforcing that both client and server have valid certificates)

You can also use Username and Password based authentication (including domain authentication if you have that available)

The easiest, if you ask me, is using certificates in a Client/Server auth process. As you're using Server-Server communication, I would recommend this.

Additionally, if you're worried about MITM attacks, you can encrypt and sign your messages in addition to the transport.

I should point out that client/server cert authentication is pretty easy to set up so don't let the idea of using certificates put you off.

Ketsuekiame 860 Master Poster Featured Poster

DHEC alone wont authenticate the server. For example, after establishing a key, you still need to make sure you established it with the right person! Though it is often used in conjunction with signing (which involves certificates unfortunatly).

True, but this isn't the requirement as far as I read it. The requirement being "I want to encrypt some data on the connection". If you want any kind of server validation (which is generally why TLS is used) then some information must have been exchanged beforehand.

Attempts to do so will be vunerable to a MITM attack. It doesn't matter how you look at it.

Agreed, but at least with ECDH they have to have intercepted the start of the exchange to make it easy. It's not perfect, but if you don't want/can't have pre-shared information it's the best place to start.

Additionally, we are using the WAN to establish a connection, but the WWW isn't really in use. If we're verifying that the server is correct, the server should also verify that the client is correct.

Finally, it's important to note that certs aren't the be-all and end-all of security. Any cryptographically strong pre-shared key would suffice as a mechanism of client/server validation. Certs just happen to contain this information. The downside is that you need to pay for them and that might not be necessary, depending on your requirement.

For example; if you had a crypto pre-shared key of 512 bytes, you could use the …

Ketsuekiame 860 Master Poster Featured Poster

They don't get installed into a browser, they're installed in the computers certificate store. (either by user or by machine)

Certificate/SSL Certificate no difference. Certificates are produced to a well defined standard and they include a key of a certain size along with descriptor information. That is a certificate. You could make one yourself with the right knowledge of the protocol :)

Encrypting a connection still involves using a key to encrypt data and relies on the secrecy of said key for it to be secure (otherwise known as the private key)

There is something that exists called the Diffie-Hellman Elliptic Curve. This is a good place to look for connection based, non-certificate based symmetrical encryption.

ECDH relies on generating a private key and sending a public key to the client. The client starts the ECDH process by using the public key to generate their own private key. The server responds with its own public key and the client generates the same private key. These private keys can be used to encrypt over the wire without ever being sent to one another.

Example;

// Client Side

public byte[] GeneratePrivateKey()
{
    using(var keyGenerator = new ECDiffieHellmanCng())
    {
        keyGenerator.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
        keyGenerator.HashAlgorithm = CngAlgorithm.Sha256;

        byte[] clientPublicKey = keyGenerator.PublicKey.ToByteArray();
        byte[] serverPublicKey = myService.ExchangeKey(clientPublicKey);

        byte[] privateKey = keyGenerator.DeriveKeyMaterial(serverPublicKey);

        return privateKey;
    }
}

// Server Side
public byte[] ExchangeKey(byte[] clientPublicKey, out byte[] privateKey)
{
    using(var keyGenerator = new ECDiffieHellmanCng())
    {
        keyGenerator.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
        keyGenerator.HashAlgorithm = CngAlgorithm.Sha256;

        byte[] serverPublicKey = keyGenerator.PublicKey.ToByteArray();

        privateKey = keyGenerator.DeriveKeyMaterial(clientPublicKey);

        return …
Ketsuekiame 860 Master Poster Featured Poster

In terms of geometry isn't a dimension simply an axis that is perpendicular to all other axes?

Quaternion mathematics for rotation for example.

Also I don't believe in time as a dimension but as an artifact of something else. If time were a spatial dimension, why do we get relativity issues when approaching the speed of light? Seeing as even at the speed of light we're still travelling in 3 dimensional space.

Ketsuekiame 860 Master Poster Featured Poster

You can use a Binding Converter to get what you need. It will allow you to do pretty much anything to the data before it is used.

Very useful, very powerful and not too hard to get the hang of :)

Ketsuekiame 860 Master Poster Featured Poster

When you set up EF, did you use Code First or Database First design methods?
It looks like hex_srv_start is the wrong variable type for what you're trying to enter. Is the variable definitely a string type? If so, it may be that you're recording too much data.

Example;
21st Jan 2014 has 13 characters
21/01/2014 00:00:00 has 19 characters

Ketsuekiame 860 Master Poster Featured Poster

Are there any hard coded paths? You need to list what the runtime errors are.

Ketsuekiame 860 Master Poster Featured Poster

What does the EntityValidationErrors property contain?

Ketsuekiame 860 Master Poster Featured Poster

If the host doesn't have any documentation, find another host. If you pay for a simple development website that uses ASP.NET, they often come with database hosting. i realise you're looking for free but they can have some rather aggressive limitations.

Connecting to a SQL instance is done via ConnectionStrings. This site is good for figuring out connection strings. Typically you need the server address and the Instance name. You then treat it exactly as you would the local one, although expect latency.

Ketsuekiame 860 Master Poster Featured Poster

I would do a little re-design there. Whilst const ought to be flagged by Obsolete, I would redesign and make a public property that returns your const. Mark the property as obsolete and it should flag it.

Ketsuekiame 860 Master Poster Featured Poster

Maybe it was a cache/refresh thing, but to me it looks the same as you've typed it...

d5f3daab889e7e5b28e890cac5f0f315

Ketsuekiame 860 Master Poster Featured Poster

I would like to add that this is not only DW exhibiting the issue (for me). This also occurs is Battlelog (for Battlefield 4). Because of the size of the application involved, the problem is extremely exaggerated compared to the problem with DW. It is enough to bring my entire machine to a standstill.

This appears to happen only with Chrome on Windows 8.1 and the latest update (again for me)

My work machine is Windows 7 running Chrome 32.0.1700.102m and does not appear to exhibit the issue.

Ketsuekiame 860 Master Poster Featured Poster

Given that it works elsewhere, just not on your machine, indicates a possible issue with your machine. The graphics drivers perhaps. Unfortunately, beyond this, I'm out of ideas.

Ketsuekiame 860 Master Poster Featured Poster

When you reinstalled your OS, did you copy the entire source folder to backup? Inside there's an obj directory. Try deleting that folder and rebuilding.

Ketsuekiame 860 Master Poster Featured Poster

Google for dxwebsetup and download the one directly from Microsoft. This will ensure you're up to date.

Ketsuekiame 860 Master Poster Featured Poster

Have you check the value for videoid is a valid value? Did you also run the query against the database manually and check the result?

What type of object is viewerlist?

Ketsuekiame 860 Master Poster Featured Poster

I don't really understand your question. Could you try and explain it again please?

Ketsuekiame 860 Master Poster Featured Poster

Have you tried updating DirectX?

Ketsuekiame 860 Master Poster Featured Poster

Probably means the join is failing. Check that your User table contains SiteIDs that are contained in your Sites able where the firstname is equal to what you're searching for.

Also, when you execute this look at what LINQ to SQL is generated using SQL Profiler. You can execute this against the database and see if you're getting any results.

If you aren't, then there is probably a problem with your data. For comparison, running the following query is equivalent;

select
    u.FirstName,
    u.LastName,
    u.Username,
    u.Password,
    s.SiteName,
    u.Active
from [Users] u
inner join [Sites] s on u.SiteID = s.SiteID
where u.FirstName = 'Name to search for';

If you run this, you should get some results, if you don't, then it is definitely a data issue :)

Ketsuekiame 860 Master Poster Featured Poster

Your padding is unecessary as you are parsing it to an int. 000001 simply becomes 1 once parsed. If you need to retain the leading 0s then you need to store the data as a string, not a number.

Also, you could use String.Format("{0:000000}", row[0]); as it looks a little neater, but this is personal preference. Using PadLeft is generally more correct as the intention behind the code is clearer. This won't fix the problem though, just another way of doing what you're currently doing.

Ketsuekiame 860 Master Poster Featured Poster

You could try installing the VB6 runtime. It's a long shot but it might be a corrupt/missing library issue: Click Here

Ketsuekiame 860 Master Poster Featured Poster

So what exactly happened when you were debugging?

Ketsuekiame 860 Master Poster Featured Poster

I can't reproduce your first (screenshot) issue, but I agree with the second one. Does the same for me too. The URI Id is different by 1 between each post.

Ketsuekiame 860 Master Poster Featured Poster

Depends what you mean by interactive!

Technically an accounting program is interactive, but often that's not what people mean :)

But a simple yet fun project...How about creating a multiplayer (keyboard sharing) game of Battleship?

The rules are simple, it's sufficiently easy to design and implement, yet complex enough to stretch some of your initial skill set. I also presents room for modification later as your skills improve (such as networked multiplayer or increased number of players etc)

Ketsuekiame 860 Master Poster Featured Poster

An error like that could mean something blew up in the Window constructor for your WPF Form. (Could be a method or child method or child constructor, there's a lot of possibilities)

I would do a debug step through so you can see exactly where in your code it leaves for the framework and then collapses. That's probably the best place to start.

Ketsuekiame 860 Master Poster Featured Poster

If you don't add it to source control it will still exist on disk. Part of the build process, though, will be to copy your localdb to the correct location.

If you add your local db as a file in your project, then set it as "Copy to Output path" it should copy it to your Debug/Release folder when you build.

If you're using VS Online, do you have Azure? Set up a small SQL Web server and use that during development. Once you've finished development, you can copy the schma, seed your localdb and deploy as normal.

Ketsuekiame 860 Master Poster Featured Poster

IIS tends to ignore those settings. Why? Who knows... However, it will pull them from the AppConfig if you set them.

<add key="loginUrl" value="~/login/" />
<add key="defaultUrl" value="~/unauthorized/" />

If you add those into your config, it should work.

Ketsuekiame 860 Master Poster Featured Poster

The error you have means that the XAML is missing a closing tag somewhere.

Unfortunately, I couldn't compile your application because it couldn't find any of your resources.

Your delegate command seems ok.

Ketsuekiame 860 Master Poster Featured Poster

The XAML seems valid and my IDE is happy enough with it. It may be one of your supporting resource libraries that's invalid.

Where are you storing your style resources?

Ketsuekiame 860 Master Poster Featured Poster

Can you post the entire XAML? I think you're missing a </resources> tag somewhere.

Ketsuekiame 860 Master Poster Featured Poster

Did you try cleaning the solution and doing a full rebuild? This might be an issue with cached build objects.

Ketsuekiame 860 Master Poster Featured Poster

If EnumerateDirectories ends after trying to access a directory it cannot then you're going to need to create your own search function.

EnumerateDirectories will give you all the directory names for the folder it is currently searching. With the AllDirectories flag it will search all sub directories as well. Your exception will be raised when it tries to enter a sub-directory it doesn't have permission to do so, in this case, you're going to have to re-implement this behaviour yourself.

Retrieve a list of the directories at the current level, then one by one enter the sub-directories. When you hit one you can't enter, just skip it and move to the next.

Ketsuekiame 860 Master Poster Featured Poster

Ketsuekiame:
It seems that you dont understand what the thread starter is asking.

What he wants is when selectedvalue does not exist in the list of items he want the selectedindex = 0 or selectedvalue is "-- Select --".

So the best way to do that is:

Before fetching a data from the database do this:

ComboBox1.Items.Add("-- Select --");
Fetch the data from the database.
No data from database then, ComboBox1.SelectedIndex = 0;
Simple,am I right?

I understood perfectly what he said; unfortunately your solution isn't viable as the OP is using databinding. You cannot modify the list after it is bound. So, the only way would be to insert it into the data items before the control gets bound.

The other problem with your method is that you're treating a valid selection as in in-valid one. An index of 0 is a perfectly valid selection. If you're trying to deselect an item, you must set the SelectedIndex to -1.

From the MSDN:

To deselect the currently selected item, set the SelectedIndex to -1.

This unsets the selected item and invalidates the control. The fact that the control is no longer valid is important is ASP.NET validation.

Unfortunately, my way doesn't work either. As the list is databound, you cannot set the Text property of the ComboBox. It is unset (reset) and made read-only.

The only way to get what the OP wants, is to dirty the actual data, or simply pre-process …

Mike Askew commented: This +7
Ketsuekiame 860 Master Poster Featured Poster

No it is a bug. This Hotfix should work

Unfortunately, it means that you need to include this hotfix with your application redist.

Edit: Reading the bug report there is a workaround - Add the style as a dynamic resource reference or add it as a static resource to the xaml resource dictionary.

ddanbe commented: Whish I had this WPF knowledge +15
Ketsuekiame 860 Master Poster Featured Poster

If you interfaced it out, you could easily check the permissions of screens below the parent. Alternatively you could go action based and link your roles to actions rather than screens. This would probably require more maintenance but give you more flexibility.

Ketsuekiame 860 Master Poster Featured Poster

In that case no, your only real option is to match the Ids of your screens to the roles required, in your DB.

Ketsuekiame 860 Master Poster Featured Poster

Are you thinking about storing the screen class name mapped against one or more roles?

Or use attributes. But the attributes would have to match your DB permissoin names and any changes would have to be retrospective too...

Ketsuekiame 860 Master Poster Featured Poster

A general, generic system would have you define a table to store your groups, a table to store what permissions that group has and a table to assign users to groups.
I would then translate that into C# and assign roles to your screens.
The other option is to be more database driven and record the permissions for each screen as a table. Personally, if you're doing simple CRUD permissions I would use interfaces and mark your screens.

ie. MyScreen : IRequiresWrite, IRequiresRead

Otherwise if you need to make it more complicated;

MyScreen : IRequiresPermissions

And then load the permissions required from the DB

You would need to write your own middleware for the permissions authentication. I'm not sure of anything out of the box.

Ketsuekiame 860 Master Poster Featured Poster

Firstly, although MyClass inherits IComparable the compiler doesn't know that it can be converted (sometimes the compiler is dumb). If you change your original definition from MyClass[] mine = new MyClass[5] to IComparible[] mine = new MyClass[5] that will be fine.

Finally, you can only pass an assignable value with the explicit ref keyword. new MyClass(8) isn't assignable, you would need to put this into a variable first and then pass it through.

Strictly speaking, however, you can drop the ref keyword. Your object is being passed by reference anyway.

For Completeness:

When you pass an array into a method, you're passing the pointer to it by value. What this means is that any changes to the contents of the array will be reflected in the original object, however, re-assigning the array will not. That's why you needed the ref keyword. You don't need the ref keyword on the second parameter as it is already passed by reference.

Ketsuekiame 860 Master Poster Featured Poster

I would question the fact your design requires you to call two different methods with, or without, a parameter.

Essentially in this case, you could keep your second definition and just handle the case for when obj == null

If you need to call two different methods (with different names) then that's simply a separate command. If you need to put two commands onto a single use case, then you need to go back to your design and see what's going on. If I ended up in that scenario, I would assume my design to be incorrect.

If you really want to go in your direction, then use a pattern whereby the delegate is merely a proxy to the method you really want to call.

(object obj) =>
{
    if(obj == null)
    {
        MakeCall();
        return null;
    }

    return MakeCall(obj);
}

Or you could try generic delegates (slightly clearner imo):

public delegate T CommandDelegate<T>(T inParam);

However, I'm going to question the design on this one. I really don't think something like this should be necessary.

I realise I'm criticising you, but I don't mean it in a nasty way.

Ketsuekiame 860 Master Poster Featured Poster

Set your combobox Text property to the default value you want to display.

If the selected index doesn't exist in the DB, set your SelectedIndex on the combo box to -1. This will revert it to your default text.