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
Potassium Problems
Sep 28, 2001

gariig posted:

Also, Microsoft agrees with you because JSON.Net will be the JSON serializer when Web API ships
You can install System.Json from NuGet now, but it's still beta status & probably not fit for production yet.

Adbot
ADBOT LOVES YOU

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
A slightly more involved alternative if you don't want to pull in JSON.NET is to write a JavaScriptConverter subclass and pass it off to the JavaScriptSerializer which is all JsonResult uses under the hood. You can customize field names via JavaScriptConverter, though if you want to support anonymous types you'd have to do some reflection to discover what the converter is being given at runtime.

uXs
May 3, 2005

Mark it zero!
Because I want to test (almost) everything, I find that I have to use interfaces. A lot. For almost everything I make, I have to define an interface, and use that instead of the concrete class in other classes (or interfaces).

Now this is all fine, but it's getting very annoying that every single time I add a function or a property or an event or anything, I have to update the interface as well. Is there a way so I don't have to do this manually, or am I just going to have to suffer?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

uXs posted:

Because I want to test (almost) everything, I find that I have to use interfaces. A lot. For almost everything I make, I have to define an interface, and use that instead of the concrete class in other classes (or interfaces).

Now this is all fine, but it's getting very annoying that every single time I add a function or a property or an event or anything, I have to update the interface as well. Is there a way so I don't have to do this manually, or am I just going to have to suffer?

ReSharper has a "pull member up" function that will add a method to an interface with like 2 clicks.

PhonyMcRingRing
Jun 6, 2002

uXs posted:

Because I want to test (almost) everything, I find that I have to use interfaces. A lot. For almost everything I make, I have to define an interface, and use that instead of the concrete class in other classes (or interfaces).

Now this is all fine, but it's getting very annoying that every single time I add a function or a property or an event or anything, I have to update the interface as well. Is there a way so I don't have to do this manually, or am I just going to have to suffer?

Are you only doing the interfaces specifically for mocking? You could mark members as virtual and mock it that way, too.

wwb
Aug 17, 2004

Or just avoid mocking the poo poo out of everything -- I think that worm as swung over too far in some places. I totally appreciate mocking / stubbing out / faking external dependencies but mocking every class something interacts with is overkill. Especially when the other classes have tests to ensure they work correctly and your code is reasonably clean as to not have wacky dependencies.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

wwb posted:

Or just avoid mocking the poo poo out of everything -- I think that worm as swung over too far in some places. I totally appreciate mocking / stubbing out / faking external dependencies but mocking every class something interacts with is overkill. Especially when the other classes have tests to ensure they work correctly and your code is reasonably clean as to not have wacky dependencies.

I agree. Plus, if the code is reasonably well-written in the first place, it's generally fairly painless to refactor later on if you need to decouple further.

PhonyMcRingRing
Jun 6, 2002

Ithaqua posted:

I agree. Plus, if the code is reasonably well-written in the first place, it's generally fairly painless to refactor later on if you need to decouple further.

I also agree. At work we generally have to write every single thing to an interface "just in case we need to swap it out some day", and I'd say 99% of those interfaces only have one concrete implementation. I understand the whole technical debt thing, but worrying about potentially change a class some day is annoying.

boo_radley
Dec 30, 2005

Politeness costs nothing
Active directory manipulation:
code:
using (var childGroup = GroupPrincipal.FindByIdentity(ouContext, groupName) ?? new GroupPrincipal(ouContext, groupName))
        {
          foreach (var personUserName in groups[groupName])
          {

            if (string.IsNullOrEmpty(personUserName))
            {
              continue;
            }
            using (var thisUser = UserPrincipal.FindByIdentity(domainContext, personUserName))
            {
              if (thisUser == null) continue;
              if (childGroup.Members.Contains(thisUser)) continue; 
              childGroup.Members.Add(thisUser);
              childGroup.Save();
              i++; 
              if (i % 100 == 0) Console.WriteLine(i);
            }

          }
        }
Right now the System.DirectoryServices.AccountManagement calls in this loop are 90% of this program's execution. I'm looking for ways to speed up this set of loops. I don't know if there's a way to intelligently cache AD objects, or if there's a different API that would lend itself better to the task.

Mongolian Queef
May 6, 2004

boo_radley posted:

Active directory manipulation:
code:
using (var childGroup = GroupPrincipal.FindByIdentity(ouContext, groupName) ?? new GroupPrincipal(ouContext, groupName))
        {
          foreach (var personUserName in groups[groupName])
          {

            if (string.IsNullOrEmpty(personUserName))
            {
              continue;
            }
            using (var thisUser = UserPrincipal.FindByIdentity(domainContext, personUserName))
            {
              if (thisUser == null) continue;
              if (childGroup.Members.Contains(thisUser)) continue; 
              childGroup.Members.Add(thisUser);
              childGroup.Save();
              i++; 
              if (i % 100 == 0) Console.WriteLine(i);
            }

          }
        }
Right now the System.DirectoryServices.AccountManagement calls in this loop are 90% of this program's execution. I'm looking for ways to speed up this set of loops. I don't know if there's a way to intelligently cache AD objects, or if there's a different API that would lend itself better to the task.

Is there no way to add a range of Users? Did you try saving after adding all of them instead of after each addition?

PhonyMcRingRing
Jun 6, 2002

boo_radley posted:

Right now the System.DirectoryServices.AccountManagement calls in this loop are 90% of this program's execution. I'm looking for ways to speed up this set of loops. I don't know if there's a way to intelligently cache AD objects, or if there's a different API that would lend itself better to the task.

I dunno if it'd add any performance benefit, never worked with ActiveDirectory, but storing the user in a dictionary might help some.

code:
// I'm assuming thisUser is a UserPrincipal type.
var userCache = new Dictionary<string, UserPrincipal>;

using (var childGroup = GroupPrincipal.FindByIdentity(ouContext, groupName) ?? new GroupPrincipal(ouContext, groupName))
{
  foreach (var personUserName in groups[groupName])
  {

	if (string.IsNullOrEmpty(personUserName))
	{
	  continue;
	}
	UserPrincipal thisUser;
	if (!userCache.TryGetValue(personUserName, out thisUser)) {
		thisUser = UserPrincipal.FindByIdentity(domainContext, personUserName);
		if (thisUser == null) { continue; }
		else { userCache.Add(personUserName, thisUser); }
	}
	
	if (childGroup.Members.Contains(thisUser)) continue; 
	childGroup.Members.Add(thisUser);
	childGroup.Save();
	i++; 
	if (i % 100 == 0) Console.WriteLine(i);
  }
}

foreach(var kvPair in userCache) {
	kvPair.Value.Dispose();
}

aBagorn
Aug 26, 2004

PhonyMcRingRing posted:

I dunno if it'd add any performance benefit, never worked with ActiveDirectory, but storing the user in a dictionary might help some.

code:
// I'm assuming thisUser is a UserPrincipal type.
var userCache = new Dictionary<string, UserPrincipal>;

using (var childGroup = GroupPrincipal.FindByIdentity(ouContext, groupName) ?? new GroupPrincipal(ouContext, groupName))
{
  foreach (var personUserName in groups[groupName])
  {

	if (string.IsNullOrEmpty(personUserName))
	{
	  continue;
	}
	UserPrincipal thisUser;
	if (!userCache.TryGetValue(personUserName, out thisUser)) {
		thisUser = UserPrincipal.FindByIdentity(domainContext, personUserName);
		if (thisUser == null) { continue; }
		else { userCache.Add(personUserName, thisUser); }
	}
	
	if (childGroup.Members.Contains(thisUser)) continue; 
	childGroup.Members.Add(thisUser);
	childGroup.Save();
	i++; 
	if (i % 100 == 0) Console.WriteLine(i);
  }
}

foreach(var kvPair in userCache) {
	kvPair.Value.Dispose();
}

This is pretty much what I would suggest, as well.

uXs
May 3, 2005

Mark it zero!

Ithaqua posted:

ReSharper has a "pull member up" function that will add a method to an interface with like 2 clicks.

Is there something similar in CodeRush? We have licences for that + I tried ReSharper too and didn't like it that much.

PhonyMcRingRing posted:

Are you only doing the interfaces specifically for mocking? You could mark members as virtual and mock it that way, too.

Yeah, that's possible too. But then I have to make everything virtual. Apart from that being work as well, you also risk executing code that you forgot to mark as virtual.

I can see it now: 'public void ClearTable() { ... }'.

Oops.

wwb posted:

Or just avoid mocking the poo poo out of everything -- I think that worm as swung over too far in some places. I totally appreciate mocking / stubbing out / faking external dependencies but mocking every class something interacts with is overkill. Especially when the other classes have tests to ensure they work correctly and your code is reasonably clean as to not have wacky dependencies.

I like mocking. It makes it easy to make sure that the code under test doesn't do anything unexpected, and you can check if the right calls and stuff were received.

Besides, a lot of things you need to test ultimately depend on some database or filesystem or whatever, and you have to mock those.

Anyway, I'll check again if I really need to mock everything.

adaz
Mar 7, 2009

My C# is nearly non-existent, but it looks like you're trying to iterate through all the members of one group and add them to another group?

If that's the case you can eliminate nearly all the System.DirectoryServices.AccountManagement calls by just retrieving the base directory entry of the group to start with. That way you already have the members and can add them to the child group without calling UserPrincipal.FindByIdentity every time.

I don't know enough C# to write it out but here is the VB equivalent.

code:
dim deGroup as New directoryservices.directoryentry("LDAP://CN=test,ou=blah,ou=hi,dc=zombo,dc=com")
dim childGroup as new directoryservices.directoryentry("LDAP://CN=childtest,ou=blah,ou=hi,dc=zombo,dc=com")
for each userDN in deGroup.properties("member")
   if childgroup.properties("member").contains(userdn) = False Then
       childGroup.add("LDAP://" & userDN)
   End if
next

adaz fucked around with this message at 20:14 on Apr 4, 2012

PhonyMcRingRing
Jun 6, 2002

uXs posted:

Yeah, that's possible too. But then I have to make everything virtual. Apart from that being work as well, you also risk executing code that you forgot to mark as virtual.

I can see it now: 'public void ClearTable() { ... }'.

Oops.


I don't know enough C# to write it out but here is the VB equivalent.

code:
deGroup = new-object directoryservices.directoryentry("LDAP://CN=test,ou=blah,ou=hi,dc=zombo,dc=com")
childGroup = new-object directoryservices.directorentry("LDAP://CN=childtest,ou=blah,ou=hi,dc=zombo,dc=com")
for each userDN in deGroup.properties("member")
   if childgroup.properties("member").contains(userdn) = False Then
       childGroup.add("LDAP://" & userDN)
   End if
next

[/quote]

What is this "new-object" and lack of Dims?

boo_radley
Dec 30, 2005

Politeness costs nothing
:ssh: powershell

adaz
Mar 7, 2009

PhonyMcRingRing posted:


What is this "new-object" and lack of Dims?

I just fixed it :sweatdrop: . So used to doing all my AD stuff in powershell that I apparently half wrote that in powershell

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Do you guys know of a way to embed a webkit browser in a WFP application without buying Awesomium?

Paul MaudDib
May 3, 2006

TEAM NVIDIA:
FORUM POLICE
Once again I am having a :wtc: moment.



As you can see, this is ye olde threadpoole done with tasks. Start a task, it enters WorkerThread. As the domain of i is 0-1, the domain of clientId should be 1-2. So why is clientId 3 in the first line of workerThread? It produces the first task normally, it shows up as clientId = 0, but then the second task gets value clientId = 3. If I start three tasks, they get clientIds 2,4,and 4, or sometimes 2,3,4 or 4,4,4.

I don't see where else it could be altering the value of i, and I'm checking the value immediately after entering WorkerThread, so it's gotta be something in the Main. The program flow looks exactly as expected, though.

:wtc:

e: It's gotta be some weirdness I'm not understanding about tasks, everything goes as expected if I switch to an array of threads instead of tasks.

e2: I bet it's somehow considered a reference when I pass the variable into the task. I figured the lambda would insulate me from the outer scope, I guess not.

Paul MaudDib fucked around with this message at 21:18 on Apr 4, 2012

Zhentar
Sep 28, 2003

Brilliant Master Genius
That's how closures and loop variables work (at least, until C#5). I'll just let the good man Eric Lippert explain.

Edit: looks like you figured it out in edit 2.

ljw1004
Jan 18, 2005

rum

Paul MaudDib posted:

Once again I am having a :wtc: moment.

Your for loop is equivalent to the following:

code:
int i;
for (i=0; i<2; i++) {
   Threadpool.Run(() => f(i+1);
}
Note that there's only a single variable "i" which is shared by all the lambdas you created. Your code will finish its for loop promptly (ending because i==2), and then the scheduler will start running your lambdas. By this time, remember, each lambda is capturing the same "i" which has the value 2.

If you're written the same code in VB, you'd have got an warning message: "Using the loop control variable in a lambda may lead to unexpected side effects. Consider assigning it to a temporary."

In C#5/VB11 we changed the behavior of foreach (but not for) so that it allocates a fresh instance of the local variable for each iteration. Thus, the following code in C#5/VB11 will do what you want:

code:
foreach (var i in Enumerable.Range(...)) {
   Threadpool.Run(() => f(i+1);
}
And in C#4/VB10 or below, following the advice given by VB's warning message, consider this:

code:
for (int i=0; i<2; i++) {
  var j = i;
  Threadpool.Run(() => f(j+1));
}

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
Your problem is that the lambdas are closing over the variable i, not the value of i at the time the Task is created. When the for loop exits i has a value of 2, and when the Task actually gets around to executing it looks at the value of i (2) and does it's work based on that value.

You need to introduce a new per-loop variable like this
code:
for(int i=0; i< num_threads; ++i)
{
  int j=i; // this is the local copy of i that will get passed into Task
  cancel_tokens[i]=new CancellationToken();
  worker_tasks[i] = new Task(()=>WorkerThread(j+1, program_filename, cancelTokens[j]);
  worker_tasks[i].Start();
}
I read that this behavior may get changed in C# 5.0 since it's a common but confusing error. (e2: apparently for foreach but not for loops)

e: beaten while typing

PDP-1 fucked around with this message at 21:29 on Apr 4, 2012

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
You have an issue where your counter variable is changing within the scope of your closure.

Copy "i" into a different variable within your loop and the problem should go away.
Ex:

code:
for(int i=0;i<threads;i++)
{
    cancel_tokens[i] = new CancellationToken();
    var iTmp = i;
    worker_tasks[i] = new Task(()=>WorkerThread(iTmp+1), cancel_tokens[iTmp]);
    worker_tasks[i].Start();
}
[edit]
Super-beaten! :argh:

Let me pimp ReSharper again: It warns you about problems like that.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Paul MaudDib posted:



Here's the problem: Closures (like that anonymous function you're passing to new Task() close over variables, not values.

All your tasks are seeing the current (i.e. last) value of i, not whatever that value was when you created the task. Except sometimes they don't, because they might start executing before the loop in Main finishes.

ljw1004
Jan 18, 2005

rum

Paul MaudDib posted:

code:
new Task(..).Start(..)

I encourage you to use Task.Run() instead! We think it's a better API. Stephen Toub wrote: "There's 0 reason to use 'new Task(...).Start()". It provides no benefit over Task.Run, is more error prone, and actually has a bit more overhead."


Well, more precisely, there are just a few niche scenarios where you can't use Task.Run and have to use new Task.Start: http://blogs.msdn.com/b/pfxteam/archive/2012/01/14/10256832.aspx -- see #8.

edmund745
Jun 5, 2010
Today it is graphics.......

I am writing a VB.net program that draws some interactive images to a [public] bitmap (on a module) and then displays them in a picturebox.

I can put all the GDI stuff in a {Using,,,, End Using} statement so the graphics is disposed in the sub that does the drawing. Where should the bitmap be disposed? I am guessing,,, in the program's main FormClosed event?

The bitmap must be used the entire time the program is running. I've already seen that if I dispose it when it is in a picturebox, that triggers a break on an invalid parameter reference.


(.....I am using a bunch of public variables on the module already-- I never got the hand of encapsulating everything, and I'm just doing this for fun anyway)

Zhentar
Sep 28, 2003

Brilliant Master Genius
If its lifespan is equivalent to your process's lifespan, it doesn't matter. It's going away when your process dies whether it's disposed or not.

edmund745
Jun 5, 2010
Okay here is a vb.net graphics trivia question for y'all. It is no longer a problem because I already found the solution (which I will relate) but still a question remains:

I needed to draw an image with text--so I made a picturebox, set the background to white, set up a bitmap to draw on, drew some test lines and text on the bitmap, and sent the bitmap to the picturebox. A screencap of that is below-



All of the above examples were with the FontStyle set to regular, NOT bold.

My PC has Win7, but the program I am writing will probably end up on computers running WinXP. I found that the "MS UI Gothic" looked just fine, but that it was not present on WinXP, so I began testing other fonts and fontfamilies that could carry over.... And they all looked like crap. I know a couple things about fonts, and it appears as though the hinting is not being used properly in all but the top one.

Well I looked around and found this page-
http://stackoverflow.com/questions/3418283/graphics-drawstring-looks-nice-in-picturebox-but-horrible-in-a-bitmap

-where somebody else had a similar problem, and someone there put a link to this page-
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/9a66c7a2-79ad-4c9b-91cc-361ec72d13de
-that gives the solution: when you try to render text onto a bitmap that has a transparent background, there is no background color for the font's hinting to dither to. So first you need to set the bitmap's background color to [something other than transparent], and then any font you use should hint properly.



But one question still remains.......



Why did the MS UI Gothic font look PERFECT, even when there was no background color for it to dither to? I tried a bunch of different fonts before finding out about the background color issue, and MS UI Gothic was the ONLY font that looked right against a transparent background....?

I have not found any info that says the OS considers it to be any different than other fonts.... Most information I find about it only says that it is a standard Win7 kanji font. The Microsoft page even shows the example in kanji.
http://www.microsoft.com/typography/fonts/font.aspx?FMID=1612

boo_radley
Dec 30, 2005

Politeness costs nothing

aBagorn posted:

This is pretty much what I would suggest, as well.

These were good suggestions! The cacheing overhead has its own impact at around 7,000 users that seems to outweigh the time to do a raw query. However it seems like we're just doing too much in one monolithic process: 35,000+ users and 2 to 10 AD groups per user averaging 12s/1,000 group-users will take a bit over 8 hours to run. We're just doing too much with too many people all at once. :sigh:

edmund745
Jun 5, 2010
Below is a screencap of the difference (after coloring the bitmap background white).
Also by zooming in it is demonstrated that the MS UI Gothic font looks clearer, because it is acting like a bitmap font--it isn't dithering at all?



(I changed the text on the last line, but none of them look like crap here. They all look like they're supposed to...)

Zhentar
Sep 28, 2003

Brilliant Master Genius

edmund745 posted:

Also by zooming in it is demonstrated that the MS UI Gothic font looks clearer, because it is acting like a bitmap font--it isn't dithering at all?

Because that's what MS UI Gothic is designed to do.

The rest of your text looks like it isn't being grid fit. You should probably use a TextRenderingHint that includes GridFit (or stop forcing it to one that isn't).

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

boo_radley posted:

These were good suggestions! The cacheing overhead has its own impact at around 7,000 users that seems to outweigh the time to do a raw query. However it seems like we're just doing too much in one monolithic process: 35,000+ users and 2 to 10 AD groups per user averaging 12s/1,000 group-users will take a bit over 8 hours to run. We're just doing too much with too many people all at once. :sigh:

Could you divide the workload (by, say, first character of last name) across multiple machines and domain controllers to cut down on run time?

aBagorn
Aug 26, 2004
Ok, another newbie question regarding browser compatibility with ASP WebForm controls. I posted this on StackOverflow but figured it wouldn't hurt to widen my net.

have 2 radio buttons on an asp.NET Web Form that determine the way a user queries a database.

The asp for them is this:

code:
<asp:RadioButton ID="nameButton" runat="server" Text="Search by Tech" 
    OnCheckedChanged="nameButton_CheckedChanged" AutoPostBack="True" />
<asp:RadioButton ID="addressButton" runat="server" Text="Search by Site Address"
    OnCheckedChanged="addressButton_CheckedChanged" AutoPostBack="True" />
The code behind (C#) has a bunch of UI hide and seek. Specifically, when the nameButton is checked, a dropdown appears and users can search from a list of names. When the addressButton is checked, a textbox appears and the users can enter a full or partial address.

This all works fine in IE (7-8-9) and Firefox. However, when testing in Chrome, the radio buttons are not clickable.

Is this something I should be using jquery for?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

aBagorn posted:

Is this something I should be using jquery for?

It's probably bad markup somewhere in the page. When you have a weird issue in an existing codebase, find the simplest reproduction you can. Start commenting out chunks of HTML until it works. Then start uncommenting chunks until it doesn't. You'll eventually find the chunk that's your culprit.

But regardless, you should be using MVC and jQuery. :)

aBagorn
Aug 26, 2004

Ithaqua posted:

It's probably bad markup somewhere in the page. When you have a weird issue in an existing codebase, find the simplest reproduction you can. Start commenting out chunks of HTML until it works. Then start uncommenting chunks until it doesn't. You'll eventually find the chunk that's your culprit.

But regardless, you should be using MVC and jQuery. :)

Found the bad markup. Just some extraneous HTML.

Yes I need to learn MVC, I know I know.

redleader
Aug 18, 2005

Engage according to operational parameters
I'm trying to figure out WPF ValidationRules and bindings and whatnot.

In my project, Validations.cs contains a validation rule. In MainWindow.xaml, I have a TextBox that should use this custom validation rule. However, I can't quite figure how to get the right XAML to actually bind the two. I think it looks something like:
code:
<TextBox Name="fooText">
    <Binding>
        <Binding.ValidationRules>
            <Something.Goes.Here.But.I.Don't.Know.What />
        </Binding.ValidationRules>
    </Binding>
</TextBox>
How do I bind the control defined in MainWindow.xaml (with associated code file MainWindow.cs) to the ValidationRule in Validations.cs?

More generally, is there a good introduction to WPF bindings and whatnot? I feel I'm missing out on some major elements of WPF by not understanding bindings and what they can do.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

redleader posted:

I'm trying to figure out WPF ValidationRules and bindings and whatnot.

In my project, Validations.cs contains a validation rule. In MainWindow.xaml, I have a TextBox that should use this custom validation rule. However, I can't quite figure how to get the right XAML to actually bind the two. I think it looks something like:
code:
<TextBox Name="fooText">
    <Binding>
        <Binding.ValidationRules>
            <Something.Goes.Here.But.I.Don't.Know.What />
        </Binding.ValidationRules>
    </Binding>
</TextBox>
How do I bind the control defined in MainWindow.xaml (with associated code file MainWindow.cs) to the ValidationRule in Validations.cs?

More generally, is there a good introduction to WPF bindings and whatnot? I feel I'm missing out on some major elements of WPF by not understanding bindings and what they can do.

Validation
Data binding

For the record, I found both of those in about 5 seconds on Google.

redleader
Aug 18, 2005

Engage according to operational parameters

Ithaqua posted:

Validation
Data binding

For the record, I found both of those in about 5 seconds on Google.

I had a look at those before I posted here. After some investigation, it turns out I needed to add a xmlns:foo="clr-namespace:MyShittyNamespace" bit before Intellisense could pick up my validation classes.

Once I added this, I started getting a XamlParseException which has something to do with the default binding mode of a TextBox being "TwoWay". Changing the mode to "OneWay" allows the project to compile without errors, but the validation of the TextBox contents doesn't work. I think I'm going to need to do a lot more reading to get this to work.

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!
This is more of a Win32 question but my solution is in C# so this seems as good a place to put it as any.

I'd like to exercise some code that can manipulate the value returned by GetUserDefaultLocaleName to test an API that calls into it. Don't really care about changing the locale in any other meaningful way.

I've tried P/Invoking SetLocaleInfo but none of the parameter combinations I've tried has worked. Also tried modifying HKEY_CURRENT_USER\Control Panel\Internationa\LocaleName but no luck there either.

Anyone familiar enough with these APIs to know how to do this? This is Windows 7 by the way.

Adbot
ADBOT LOVES YOU

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
I just installed .NET 4.5 but can't get it to work with VS2010 C# Express. There's no option to target 4.5 and the async/await keywords aren't recognized. Is there something else you need to do to make the IDE aware of the new libraries?

  • Locked thread