Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Huragok
Sep 14, 2011

aBagorn posted:

Ok, what do you guys consider to be the best map API, Google or otherwise, for .NET?

If you're talking about web stuff, I like Bing personally.

Adbot
ADBOT LOVES YOU

Shameproof
Mar 23, 2011

aBagorn posted:

Ok, what do you guys consider to be the best map API, Google or otherwise, for .NET?

poo poo man you are AMBITIOUS

Chunderstorm
May 9, 2010


legs crossed like a buddhist
smokin' buddha
angry tuna
edit: solved, removing for sake of scrolling

Chunderstorm fucked around with this message at 08:23 on Feb 20, 2012

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!
You are probably never instantiating the private member Room.npcs. So the line
code:
 get { return npcs; }
returns null, you try to call Add on it, and you get your error. In the constructor for Room you should have the following line:

code:
npcs = new List<NPC>();

Chunderstorm
May 9, 2010


legs crossed like a buddhist
smokin' buddha
angry tuna

Eggnogium posted:

You are probably never instantiating the private member Room.npcs. So the line
code:
 get { return npcs; }
returns null, you try to call Add on it, and you get your error. In the constructor for Room you should have the following line:

code:
npcs = new List<NPC>();

Sure enough. Looked through my code, found I had:
code:
exits = new List<string>();
items = new List <Item>();
and was just missing that line. Thanks!

Combat Pretzel
Jun 23, 2004

No, seriously... what kurds?!
I initially wanted to use SQL CE for an application I'm about to write for Windows 8, but I can't find poo poo about availability of it. The current list of WinRT APIs and supported .NET ones don't list any Data namespaces at all, or anything suggesting SQL database support in any way.

I'm not particularly a fan of LINQ, since in my mind, hammering a bunch of lambdas and function calls into a processing queue, that sit on top of SQL CE, doesn't sound quite efficient.

Is my perception wrong?

The reason I want to go with SQL CE to begin with is that I can define a schema with FK constraints and hope to have a second layer that makes sure that data's correct.

But it looks currently like I have to accept the idea that LINQ-to-XML is the way to go, hoping SQL CE will be ported to WinRT, letting me switch out database engines.

--edit: I tried some LINQ to XML stuff. How the gently caress is this intuitive in any way?! :psyduck:

Combat Pretzel fucked around with this message at 16:03 on Feb 20, 2012

cannibustacap
Jul 7, 2003

Brrrruuuuuiinnssss
I seem to be having trouble connecting to my local SQL Compact database.

I am in Visual Studio 2008, C# and trying to do the following:

code:
string connectionString = "Data Source=\"BCNAccounts.sdf\"; Password=''";
using (SqlConnection connection = new SqlConnection(connectionString))
{
	connection.Open();
}
And everything hangs on connection.Open(). Plus, when I do a quick view on the connection variable, it says the state is closed.

Anyway, I just started my project so everything seems standard. But this is the first time I am using SQL with my C#. I also tried the help files here http://msdn.microsoft.com/en-us/library/d7469at0%28v=vs.90%29.aspx but it doesn't seem to help.

Any set up things I could have been missing? Or are there any guides out there that will take me from start to finish creating a sample application that uses SQL Compact?

I'm almost thinking its a issue of connecting my app to the sql compact "server"?

(PS. I tried to work this with Linq originally but apparently Linq to SQL Classes only work with SQL server or something?... I couldn't get that to work either)


EDIT: after talking to someone in a group nearby, I believe the problem may be the SQL connection issue. They recommended I used an XML database. Never done that yet, so looking for information on XML databases now


EDIT2: But you know, something doesn't make sense here. I thought the whole idea of SQL Compact is I don't need to worry about server set ups and stuff like that. I just set up a little SQL database in Visual Studio and it automatically links to my application... I think I am missing a point here since this ought to be more seamless...

cannibustacap fucked around with this message at 20:02 on Feb 20, 2012

Chasiubao
Apr 2, 2010


I'm sorry, but :psyduck:

If the problem is a connection issue with the SQL database, isn't the solution to fix that, as opposed to throwing it all away for an XML database instead?

cannibustacap
Jul 7, 2003

Brrrruuuuuiinnssss

Chasiubao posted:

I'm sorry, but :psyduck:

If the problem is a connection issue with the SQL database, isn't the solution to fix that, as opposed to throwing it all away for an XML database instead?

Well for the purpose of this application, I'd rather the database be a flat file, no server or connection issues to go through.

Chasiubao
Apr 2, 2010


cannibustacap posted:

Well for the purpose of this application, I'd rather the database be a flat file, no server or connection issues to go through.

Well if it's a requirements thing then I understand. I was just really :stare: about the idea of 'throw the whole thing away instead of solving the actual issue'.

cannibustacap
Jul 7, 2003

Brrrruuuuuiinnssss

Chasiubao posted:

Well if it's a requirements thing then I understand. I was just really :stare: about the idea of 'throw the whole thing away instead of solving the actual issue'.

Nah, apparently in my company, to set up a database server on the company network, our group would have to give $1000+/month to the IT dept.

So the way around it is to use flat databases while still developing.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

cannibustacap posted:

Nah, apparently in my company, to set up a database server on the company network, our group would have to give $1000+/month to the IT dept.

So the way around it is to use flat databases while still developing.

That's... retarded. If the end product is going to use a relational database, it should be developed against a relational database for integration testing purposes.

Also, I'd recommend against LINQ to SQL as an ORM solution... Microsoft has pretty much openly stated that L2Q is dead. Entity Framework is actively being developed, whereas L2S is not.

aBagorn
Aug 26, 2004

Ithaqua posted:

That's... retarded. If the end product is going to use a relational database, it should be developed against a relational database for integration testing purposes.

Also, I'd recommend against LINQ to SQL as an ORM solution... Microsoft has pretty much openly stated that L2Q is dead. Entity Framework is actively being developed, whereas L2S is not.

This, exactly.

Find some way to virtualize or grab some old machines and make a development LAN for yourselves (that's actually what I'm doing).

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

aBagorn posted:

This, exactly.

Find some way to virtualize or grab some old machines and make a development LAN for yourselves (that's actually what I'm doing).

Hell, as long as the schema is source controlled and updated as part of each release, there's nothing wrong with having a local SQL instance to develop against. You can even use SQL express at that point, which has a 2 GB database size limit.

aBagorn
Aug 26, 2004

Ithaqua posted:

Hell, as long as the schema is source controlled and updated as part of each release, there's nothing wrong with having a local SQL instance to develop against. You can even use SQL express at that point, which has a 2 GB database size limit.

Yes I forgot to mention that, which is funny because I'm doing exactly that with an application I'm beta testing on our help desk. The website AND db are both hosted on my workstation.

cannibustacap
Jul 7, 2003

Brrrruuuuuiinnssss

aBagorn posted:

Yes I forgot to mention that, which is funny because I'm doing exactly that with an application I'm beta testing on our help desk. The website AND db are both hosted on my workstation.

But what about SQL Compact? Isn't that a flat file "virtual" database system? How come that is giving me grief when I try to connect to it?

boo_radley
Dec 30, 2005

Politeness costs nothing

cannibustacap posted:

I seem to be having trouble connecting to my local SQL Compact database.

I am in Visual Studio 2008, C# and trying to do the following:

code:
string connectionString = "Data Source=\"BCNAccounts.sdf\"; Password=''";
using (SqlConnection connection = new SqlConnection(connectionString))
{
	connection.Open();
}


Is your database actually encrypted?
If not, I think you're freaking SQLCE out by specifying a password (even though it's blank).
If it is, include "Encrypt Database=True" into your connection string.

cannibustacap
Jul 7, 2003

Brrrruuuuuiinnssss

boo_radley posted:

Is your database actually encrypted?
If not, I think you're freaking SQLCE out by specifying a password (even though it's blank).
If it is, include "Encrypt Database=True" into your connection string.

I've tried like every combination, including the password field, putting a full path to the datasource. The "connection" variable still reports it being closed.

I even followed these instructions to the T http://msdn.microsoft.com/en-us/library/bb655884%28v=vs.90%29.aspx


EDIT: I even tested the connection within the Visual Studio "Modify Connection" dialog box and it connects just fine..

Does this help:

((System.Exception)(connection.ServerVersion)).StackTrace
" at System.Data.SqlClient.SqlConnection.GetOpenConnection()\r\n at System.Data.SqlClient.SqlConnection.get_ServerVersion()"

cannibustacap fucked around with this message at 23:20 on Feb 20, 2012

cannibustacap
Jul 7, 2003

Brrrruuuuuiinnssss
I think I may have stumbled on the answwer.

code:
            string connectionString = @"Data Source=""BCNAccounts.sdf"";";
            using (SqlCeConnection connection = new SqlCeConnection(connectionString))
            {
                if (connection.State == ConnectionState.Closed)
                {

                    connection.Open();

                }
            }
Using SqlCeConnection and that If() statement. Now the database reports as open and I don't see any errors within the object. I'll let you know

Hurray! That seemed to work.

cannibustacap fucked around with this message at 23:54 on Feb 20, 2012

epswing
Nov 4, 2003

Soiled Meat

Ithaqua posted:

You can even use SQL express at that point, which has a 2 GB database size limit.

I think it's 10gb.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

epswing posted:

I think it's 10gb.

Ahh, I was wrong in two ways! It used to be 4GB, 2008 R2 is 10GB.

raminasi
Jan 25, 2005

a last drink with no ice
I want to put a little spinning "busy..." icon in the corner of a WPF app when it's doing it's thing. What's the easiest way to do this? What keywords should I be searching for? It seems like the kind of thing that has eight billion terrible ways to do it, so I want to avoid those.

e: I know absolutely nothing about images and graphics and whatever in WPF. I've only used controls like text boxes and buttons and stuff. I do have the event stuff set up - I just need the graphics end.

raminasi fucked around with this message at 00:49 on Feb 22, 2012

Sedro
Dec 31, 2008
Here's one: Better WPF Circular Progress Bar

Put that in your view and bind its visibility to some property on your view model which indicates that your program is doing its thing.

Hibame
Feb 20, 2008

GrumpyDoctor posted:

I want to put a little spinning "busy..." icon in the corner of a WPF app when it's doing it's thing. What's the easiest way to do this? What keywords should I be searching for? It seems like the kind of thing that has eight billion terrible ways to do it, so I want to avoid those.

e: I know absolutely nothing about images and graphics and whatever in WPF. I've only used controls like text boxes and buttons and stuff. I do have the event stuff set up - I just need the graphics end.

In Silverlight I use a BusyIndicator so I would imagine there is a similar WPF version.

Zhentar
Sep 28, 2003

Brilliant Master Genius

GrumpyDoctor posted:

What keywords should I be searching for?

Throbber.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Something interesting came up today. I have some ideas about how to approach it, but I want to bounce it off of other folks.

We have a WCF service that exposes its configuration via a service. The configuration client requests the current configuration from the service, which is delivered as XML. The XML is deserialized and presented via a UI. Make some changes, save it, XML is serialized and sent back to the service, which validates it and reloads the configuration.

Some of you are already thinking of what I realized today: What if User A and B both get the same configuration file, but then both change settings and save them? Answer: Whoever hits "save" first loses their changes.

So, obviously, we want this to not have users' changes get mysteriously "eaten", but be as frictionless as possible.

Option #1: The easiest option is to version the XML file at the root element. Service can check the version on a save request, and say "I sent you version 1234, but now I have version 1240. Save failure!", discard the changes, and the client can be alerted that an error condition occurred.

That would work and be pretty low-effort, but we have the very real use case of multiple, independent pieces of configuration data that simply don't have any bearing on one another.

So, option #2: Put a GUID fingerprint, an "IsDirty" attribute, and a version on every element. Write a bunch of code to match everything up and merge what's safe to merge, fail the entire transaction if there's an irreconcilable change. I hate this option.

Option #3: I'm not entirely sure about the feasibility of this last one (I'm going to write some POC code before bed!), but it seems like it would be easier to just send the dirty elements as XML fragments, assuming the fragments contain a fingerprint and a version. It's the same basic idea as #2, except less XML parsing/traversal fuckery on the server side.

I'm leaning toward option 3, but I can be convinced otherwise. Does anyone have an option #4?

Sedro
Dec 31, 2008
I am facing a similar problem currently, and I think the best solution is somewhere in between. Break down your data into arbitrary units (whatever works best for your data). Each unit is versioned and saved individually. Have a save method like this (pseudocode):
code:
Save:
    object ElementToSave
    boolean ForceSave
Usage:
code:
Save(element, false) // error/fault if the element was saved by some other process since the last read

Save(element, true) // overwrites the previous save if necessary
Merging is a possibility but that gets really complicated. Think about the amount of effort vs. how many people will realistically configure this service concurrently.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
#1, but merge the changes and only reject it if there's actually any conflicting changes. This requires storing every previous version, but you probably want to be doing that anyway. Appropriately formatted xml diffs very well.

Maybe-not-comedy-option: store the config as a xml file in a git repo and let git do this for you.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Sedro posted:

Merging is a possibility but that gets really complicated. Think about the amount of effort vs. how many people will realistically configure this service concurrently.

Unfortunately, the answer is probably "quite a few". This application is going to be seeing widespread release, so if even 1% of the users do it, it's still potentially thousands of people.

Nurbs
Aug 31, 2001

Three fries short of a happy meal...Whacko!

Ithaqua posted:

Unfortunately, the answer is probably "quite a few". This application is going to be seeing widespread release, so if even 1% of the users do it, it's still potentially thousands of people.

This smells to me like a larger issue. Is it impractical to have a configuration per user?

Zhentar
Sep 28, 2003

Brilliant Master Genius
Option #4: Use a database.

Sedro
Dec 31, 2008
Using a database won't magically solve those problems.

ljw1004
Jan 18, 2005

rum

Ithaqua posted:

I'm leaning toward option 3, but I can be convinced otherwise. Does anyone have an option #4?

Yes. Don't re-invent what is a VERY standard and well-solved problem!

I read an interesting blog recently from a game developer who faced the same problem with multiple artists on the team modifying entities in his 3d world. So he abandoned XML, switched to a diff-friendly text format, split his configuration stuff up into more smaller files, spent some effort designing a storage format that was going to be friendly to standard diff tools, and went with that.

Alternatively: your option 1 is a pretty standard solution to the same problem.

Sedro
Dec 31, 2008
I need to perform an action one time after my assembly is loaded, before the assembly is used. The action is to configure a third-party library, so not my horror. This is not an executable so I don't have an entry point I can rely on. Is there a good way to handle this?

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

Sedro posted:

I need to perform an action one time after my assembly is loaded, before the assembly is used. The action is to configure a third-party library, so not my horror. This is not an executable so I don't have an entry point I can rely on. Is there a good way to handle this?

You could use a static constructor but it's only called right before a static member is referenced. The code using your assembly could use the AppDomain.AseemblyLoaded event to call a setup method on your assembly which seems clunky.

Just curious why can't you put the setup code in your classes constructor? If there are multiple classes have one base class that does all the setup with the third party configuration

Sedro
Dec 31, 2008
My solution right now is to call a setup method in the cctor of every class which uses the third-party library. But I just made a new class and forgot to have it run the setup method, so it would be nice to have it all in one place.

I don't know how I could use the assembly load event, because I would need a single point of entry to attach an event listener.

Edit: I don't want to put this logic in the executable which uses the assembly.

Malacola
Apr 19, 2002
Since I haven't gotten to this chapter in The Art of Unit Testing yet... say I want to refactor a class that currently takes some UserControl from a third party charting library as a parameter, sets up its datapoints, and sets a whole bunch of properties on it.

There's a bunch of logic in here that I'd imagine I'd want covered by unit tests before I go mucking about, but of course by its very nature it's coupled to a UserControl - the class basically exists just to set properties on this hulking third party UI element.

Am I kind of SOL here? Would mocks be of any help? Since it's a third party component this doesn't really seem like something I could mock, unless maybe I were to wrap the UserControl itself in a class and then make that implement some interface that I'd pass instead of the control itself...

And anyway, it seems a large part of what I actually want to test is that I'm not doing something stupid with the chart control's API, which seems pretty heavily dependent on the chart control behaving like a chart control. Which I guess means this isn't really unit testing at all, it'd be more of an integration test.

Eh. I guess I don't get what real world unit testing looks like yet, since I'm the only one doing it where I work. I'm just sort of making it up as I go. What does unit testing start to look like once you start mixing in big third party libraries?

The Gripper
Sep 14, 2004
i am winner

Sedro posted:

I need to perform an action one time after my assembly is loaded, before the assembly is used. The action is to configure a third-party library, so not my horror. This is not an executable so I don't have an entry point I can rely on. Is there a good way to handle this?
You could create another assembly that just wraps loading of the third-party assembly, running any pre-setup action there (and keeping the logic separate to the rest of your code).

Sedro
Dec 31, 2008

Malacola posted:

Since I haven't gotten to this chapter in The Art of Unit Testing yet...
I wouldn't unit test that I am using the third-party charting control properly--that is integration testing. I would unit test that I am populating it with the correct data. Create an interface around the charting API such that it's easy to replace it with another implementation (you should do this anyway). Then write a mock of it and make sure it gets configured as expected.

Adbot
ADBOT LOVES YOU

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

Sedro posted:

I need to perform an action one time after my assembly is loaded, before the assembly is used. The action is to configure a third-party library, so not my horror. This is not an executable so I don't have an entry point I can rely on. Is there a good way to handle this?

Can't you just wrap all access to the 3rd party stuff in your own wrapper class(es) and make sure to correctly initialize it there?

  • Locked thread