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
Kekekela
Oct 28, 2004
Does anybody know a way to check the architecture of a DLL consistently?
http://msdn.microsoft.com/en-us/library/system.reflection.module.getpekind%28VS.80%29.aspx

Adbot
ADBOT LOVES YOU

boo_radley
Dec 30, 2005

Politeness costs nothing

Rocko Bonaparte posted:

Does anybody know a way to check the architecture of a DLL consistently? I am particularly interested in a way to overtly tell if a DLL was built with the "Any CPU" target. All I can figure is I can dumpbin the DLL on a 32-bit OS, and then against on a 64-bit OS. If the target architecture changes to be compatible, then it must be capable of both. This is a bit of a pain in the rear end though, given I'd have to run this on large directory trees.

http://stackoverflow.com/questions/495244/how-can-i-test-a-windows-dll-to-determine-if-it-is-32bit-or-64bit

ljw1004
Jan 18, 2005

rum

Rocko Bonaparte posted:

Does anybody know a way to check the architecture of a DLL consistently? I am particularly interested in a way to overtly tell if a DLL was built with the "Any CPU" target. All I can figure is I can dumpbin the DLL on a 32-bit OS, and then against on a 64-bit OS.

Just a heads-up... with Win8, there's going to be a new kind "AnyCPU32bitPreferred".

http://stackoverflow.com/questions/7508965/what-does-the-prefer-32-bit-compiler-flag-mean-for-visual-studio-11-managed-ap

(sorry... I can't find official MS documentation on this just yet)

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I had seen the Stack Overflow thread previously. It looks like all the solutions there don't account for the "Any CPU" type. I think all those solutions will choose the target architecture whenever an Any Cpu DLL comes along. I haven't heard of Module.GetPEKind() so I'll try to write a little utility with it to see what it can do for some known targets. Thanks.

boo_radley
Dec 30, 2005

Politeness costs nothing

ljw1004 posted:

Just a heads-up... with Win8, there's going to be a new kind "AnyCPU32bitPreferred".

http://stackoverflow.com/questions/7508965/what-does-the-prefer-32-bit-compiler-flag-mean-for-visual-studio-11-managed-ap

(sorry... I can't find official MS documentation on this just yet)

Will VS11 let us Edit and Continue with 64 bit projects?

ray2k
Feb 7, 2004

Puppet scum beware!

Rocko Bonaparte posted:

Does anybody know a way to check the architecture of a DLL consistently? I am particularly interested in a way to overtly tell if a DLL was built with the "Any CPU" target. All I can figure is I can dumpbin the DLL on a 32-bit OS, and then against on a 64-bit OS. If the target architecture changes to be compatible, then it must be capable of both. This is a bit of a pain in the rear end though, given I'd have to run this on large directory trees.

Use Corflags

Lhet
Apr 2, 2008

bloop


I'm a bit curious about the cleanness/stability of a sort of technique/mini design pattern I've been using recently. I basically figured it out on my own when dealing with multiple OnPaints, so I have no idea if it's common & useful or terrible. I mostly use it as way to try to keep any new UI controls I make as independent as possible.
I needed to modify a 'generate excel' dialog to take range parameters, and we have a custom range selection control, so I made a static method in a factory class to take a Delegate and max Range as parameters.
Code looks something like this: http://pastebin.com/6udUV6Hv

Is this good/bad/slow? Is there a cleaner way to do it?

Lhet fucked around with this message at 04:02 on Oct 18, 2011

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm running into a weird error regarding rebinding a gridview after editing the data source that it pulls from. After editing the gridview in another panel and hitting the save button, the gridview's data is repulled from the database, but in Chrome and IE8 on the server (but NOT on localhost) the gridview defaults to edit mode with the changed data item as the selected row for editing.

Edit: Figured it out, had to set EditIndex = -1;

Uziel fucked around with this message at 20:15 on Oct 18, 2011

Sub Par
Jul 18, 2001


Dinosaur Gum
I am trying to bind some TextBox.Text values to an object, so I'm doing the binding like this:

code:
MyFirstTextBox.DataBindings.Add("Text", MyObject, "Name");
MySecondTextBox.DataBindings.Add("Text", MyObject, "Total");
Let's say MyObject is like this:

code:
class MyObject
{
     string Name;
     int Total;
}
This works fine for the Name member, but doesn't do jack for the Total member. I'm guessing this is because Name is a string and I need to do this differently for Total which is an int, I just can't figure out what I need to do differently.

Am I doing something really dumb here or is this just not possible with a TextBox? Note that I have the same problem with other non-string types (float, decimal, etc). Maybe I just change all of those controls to up down boxes and the backing fields to decimals? Help?

Lhet
Apr 2, 2008

bloop


I'm having a bit of trouble getting data binding working in WPF, using the MVVM (model view viewmodel) pattern.
I'm basically building a zoom bar, so the combobox needs to change the zoom when a new value is selected. However, zoom can happen in different ways (resize, scrollwheel, etc) that will change the value to something not in the combobox (either in between values or bigger/smaller). So when that happens I need to add the appropriate value and refresh with it selected, (and remove it when it's gone).
I implemented it with Winforms just fine, and doing the same thing without data binding would be simple, but I need to learn the whole data binding thing.
I've pasted the important pieces: http://pastebin.com/9i1CZjFw

I'm not sure if I'm missing something important in the viewmodel/constructor, or if I just haven't found the right syntax for the xaml.

ljw1004
Jan 18, 2005

rum
Today the VB/C# team released a public CTP of our project codenamed "Roslyn" -- which is about opening up the guts of the compiler to third-party tools.

[VB] http://blogs.msdn.com/b/vbteam/archive/2011/10/19/introducing-the-microsoft-roslyn-ctp.aspx
[C#] http://blogs.msdn.com/b/csharpfaq/archive/2011/10/19/introducing-the-microsoft-roslyn-ctp.aspx

edit: and rewriting the compilers from scratch. They used to be written in C++. We're now writing them in VB and C# respectively.

ljw1004 fucked around with this message at 06:21 on Oct 20, 2011

ninjeff
Jan 19, 2004

ljw1004 posted:

Today the VB/C# team released a public CTP of our project codenamed "Roslyn" -- which is about opening up the guts of the compiler to third-party tools.

[VB] http://blogs.msdn.com/b/vbteam/archive/2011/10/19/introducing-the-microsoft-roslyn-ctp.aspx
[C#] http://blogs.msdn.com/b/csharpfaq/archive/2011/10/19/introducing-the-microsoft-roslyn-ctp.aspx

edit: and rewriting the compilers from scratch. They used to be written in C++. We're now writing them in VB and C# respectively.

That's awesome and I can't wait to get home and try it out. I love you guys.

Horse Cock Johnson
Feb 11, 2005

Speed has everything to do with it. You see, the speed of the bottom informs the top how much pressure he's supposed to apply. Speed's the name of the game.
What is the recommended way to kick off a background task in an ASP.NET app?

What I'm going for is this: user performs a search and makes some selections from their search results. User clicks a button which then fires off a long-running process on the server. When the process has completed the user gets an email with an attachment containing the results of the long-running process.

What I've got is an empty ASPX page that opens in a separate window, kicks off the long-running process on a thread pool thread and some JavaScript that just immediately closes the window. It works, but feels kludgy. Is there some other, best practice way of accomplishing this?

boo_radley
Dec 30, 2005

Politeness costs nothing
Hey ljw1004, do you know if VS11 let us Edit and Continue with 64 bit projects? (asks the SharePoint dev :smithicide:)

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

Horse Cock Johnson posted:

What is the recommended way to kick off a background task in an ASP.NET app?


I would have you ASP.NET app write to a database the details of what needs to be run. I would create a Windows service that polls the database every second or so and spin up a thread from the thread pool to perform the long running process.

ninjeff
Jan 19, 2004

Horse Cock Johnson posted:

What is the recommended way to kick off a background task in an ASP.NET app?

What I'm going for is this: user performs a search and makes some selections from their search results. User clicks a button which then fires off a long-running process on the server. When the process has completed the user gets an email with an attachment containing the results of the long-running process.

What I've got is an empty ASPX page that opens in a separate window, kicks off the long-running process on a thread pool thread and some JavaScript that just immediately closes the window. It works, but feels kludgy. Is there some other, best practice way of accomplishing this?

You can make the client side of that less kludgy by using AJAX (probably via jQuery or equivalent). In MVC you'd have an action that returned an XmlResult or JsonResult to confirm that the process has started; not sure what the equivalent is in WebForms.

wwb
Aug 17, 2004

gariig posted:

I would have you ASP.NET app write to a database the details of what needs to be run. I would create a Windows service that polls the database every second or so and spin up a thread from the thread pool to perform the long running process.

If you are going to do that, a console app running as a scheduled task is a much better option for a number of reasons. First, philosophically, services should, well, serve and not poll. Second, a simple command line app is vastly easier to debug and test. Third, when something goes wrong it is easier to re-run the command line task.

Now, if you want to go the service route, you should probably look at a message queue. NServiceBus is a pretty decent option here.

Horse Cock Johnson
Feb 11, 2005

Speed has everything to do with it. You see, the speed of the bottom informs the top how much pressure he's supposed to apply. Speed's the name of the game.

gariig posted:

I would have you ASP.NET app write to a database the details of what needs to be run. I would create a Windows service that polls the database every second or so and spin up a thread from the thread pool to perform the long running process.

I absolutely agree that having something external to the web app is the correct answer to this problem. Thing is, the server on which this app runs resides within the Pentagon so we have very strict parameters as far as what we can do on it and what we can't.

Whatever the solution is it's going to have to be implemented within the web app itself.

ninjeff
Jan 19, 2004

Might want to check this out, Horse Cock Johnson: http://haacked.com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

ljw1004 posted:

Today the VB/C# team released a public CTP of our project codenamed "Roslyn" -- which is about opening up the guts of the compiler to third-party tools.

[VB] http://blogs.msdn.com/b/vbteam/archive/2011/10/19/introducing-the-microsoft-roslyn-ctp.aspx
[C#] http://blogs.msdn.com/b/csharpfaq/archive/2011/10/19/introducing-the-microsoft-roslyn-ctp.aspx

edit: and rewriting the compilers from scratch. They used to be written in C++. We're now writing them in VB and C# respectively.
This is really awesome, been looking forward to this one for a while now.

wwb
Aug 17, 2004

EDIT: beaten.

ljw1004
Jan 18, 2005

rum

boo_radley posted:

Hey ljw1004, do you know if VS11 let us Edit and Continue with 64 bit projects? (asks the SharePoint dev :smithicide:)

Sorry, that's not my area.

boo_radley
Dec 30, 2005

Politeness costs nothing

ljw1004 posted:

Sorry, that's not my area.

OK, thanks. I appreciate the reply.

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog

ljw1004 posted:

Today the VB/C# team released a public CTP of our project codenamed "Roslyn" -- which is about opening up the guts of the compiler to third-party tools.

edit: and rewriting the compilers from scratch. They used to be written in C++. We're now writing them in VB and C# respectively.

The newest compilers with the async changes aren't built on this platform, right? Is the plan for the compiler release after that to be on the Roslyn platform?

ljw1004
Jan 18, 2005

rum

Smugdog Millionaire posted:

The newest compilers with the async changes aren't built on this platform, right? Is the plan for the compiler release after that to be on the Roslyn platform?

Async CTP - installs on top of VS2010
Roslyn CTP - installs on top of VS2010
(and the two CTPs co-exist okay!)

Dev11 - the next version of VS will have Async built-in, but won't have Roslyn built-in.

We haven't yet announced a plan for when Roslyn will become part of VS.

Sprawl
Nov 21, 2005


I'm a huge retarded sperglord who can't spell, but Starfleet Dental would still take me and I love them for it!

Sub Par posted:

I am trying to bind some TextBox.Text values to an object, so I'm doing the binding like this:

code:
MyFirstTextBox.DataBindings.Add("Text", MyObject, "Name");
MySecondTextBox.DataBindings.Add("Text", MyObject, "Total");
Let's say MyObject is like this:

code:
class MyObject
{
     string Name;
     int Total;
}
This works fine for the Name member, but doesn't do jack for the Total member. I'm guessing this is because Name is a string and I need to do this differently for Total which is an int, I just can't figure out what I need to do differently.

Am I doing something really dumb here or is this just not possible with a TextBox? Note that I have the same problem with other non-string types (float, decimal, etc). Maybe I just change all of those controls to up down boxes and the backing fields to decimals? Help?

try this

code:
MyFirstTextBox.DataBindings.Add("Text", MyObject, "Name");
MySecondTextBox.DataBindings.Add("Text", MyObject, "Total", true);

Sprawl
Nov 21, 2005


I'm a huge retarded sperglord who can't spell, but Starfleet Dental would still take me and I love them for it!

Horse Cock Johnson posted:

What is the recommended way to kick off a background task in an ASP.NET app?

What I'm going for is this: user performs a search and makes some selections from their search results. User clicks a button which then fires off a long-running process on the server. When the process has completed the user gets an email with an attachment containing the results of the long-running process.

What I've got is an empty ASPX page that opens in a separate window, kicks off the long-running process on a thread pool thread and some JavaScript that just immediately closes the window. It works, but feels kludgy. Is there some other, best practice way of accomplishing this?

You could easily invoke the page hit with just javascript something like jquery and make it not open a window.

Dietrich
Sep 11, 2001

I'm just hoping Roslyn finally lets us do ILmerge type stuff with WPF applications. I hate releasing programs which are 1 mb of .exe and 30 mb of .dll's.

Sub Par
Jul 18, 2001


Dinosaur Gum

Sprawl posted:

try this

Works. Thanks! New question. I have a DataGridView whose datasource is bound to a BindingList<MyObject>, where MyObject implements INotifyPropertyChanged. Everything works great. I'd like users to be able to select a row in the DataGridView though and click a button to edit that row which necessitates accessing the correct MyObject from my BindingList. Is it safe to assume that my BindingList will always have its set of MyObjects in the same order as my DataGridView? So I could do:

code:
int MyIndex = MyDGV.SelectedRows[0].Index;
MyObject ObjToEdit = new MyObject();
ObjToEdit = MyBindingList[MyIndex]
This seems to work, but I am wondering if it's a bad idea? Thanks.

Sub Par fucked around with this message at 03:58 on Oct 21, 2011

Zhentar
Sep 28, 2003

Brilliant Master Genius

Dietrich posted:

I'm just hoping Roslyn finally lets us do ILmerge type stuff with WPF applications. I hate releasing programs which are 1 mb of .exe and 30 mb of .dll's.

Roslyn is for the opposite end of what you think it is. They aren't giving access to let you mess with the compiler output, they're helping you mess with the input (i.e. your code). The biggest feature of Roslyn is that it gives you access to the Abstract Syntax Tree the compiler generates, which you can easily use for things like static analysis or refactoring.

The Roslyn CTP looks really cool, I'm going to have to try playing with it soon. Unfortunately, it's got the usual CTP constraints, and there's a pretty big list of unimplemented features (if it doesn't gracefully ignore them that will be problematic for most of the code I'd be interested in trying it on). Are there likely to be any updates to the CTP with further language feature support? And is there some legalese somewhere that defines what exactly re-distribution & production use mean?

As a side note, ASTs combined with Linq queries makes for an amazing combination.

ninjeff
Jan 19, 2004

Zhentar posted:

As a side note, ASTs combined with Linq queries makes for an amazing combination.

On that note, is there an official story for conversion to System.Linq.Expressions expressions from Roslyn's parser output? That would be really neat.

Mr. Crow
May 22, 2008

Snap City mayor for life
I've probably been looking at this to long, but how would I go about, essentially, reading from a tree structure and creating a new class hierarchy from it, breadth first?

It gets hairy because the tree I need to create needs to all be a rigid and known hierarchy, but the tree I'm reading from only defines portions of said hierarchy, and can have nodes of undefined data thrown in at random intervals.

I had a recursive DFS approach working fine before, but finding/reading two lines of this technical document means I have to change it to a BFS.

One approach I've though of is to have a two queues, one for the tree I'm reading and another for the tree I'm building, of parent nodes. So as I'm reading the child nodes on the one tree, I'm attaching them to the parent nodes of the tree I'm building. The only issue with this is I'm not sure how to determine when to dequeue items from the parent queue.

Any ideas or better suggestions?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
What do you mean exactly by 'create a new class hierarchy?' Are you writing a utility to generate code based on what you're reading from this tree? Also can you go into more detail on why it must be BFS rather than DFS?

Mr. Crow
May 22, 2008

Snap City mayor for life

Orzo posted:

What do you mean exactly by 'create a new class hierarchy?'

Like it needs to be in a pre-defined, asymmetric structure, so I can't have more lists of lists basically.

quote:

Are you writing a utility to generate code based on what you're reading from this tree? Also can you go into more detail on why it must be BFS rather than DFS?

Depends on what you mean by generate code. The whole class hierarchy is known ahead of time, it's a standard out of my control. I've already got all the various classes (via a code generator) written out. I do however need to generate a concrete structure, validate it and pass it off to another application based on god knows what other people feel like sending us/the other tree.

It needs to be BFS because various 'children' need to access data in higher level nodes, and it would just be a huge headache trying to account for each individual case of null exceptions and/or to do lazy initialization because there are something like ~400 classes in the structure and no way to generate it via T4 Templates or something. Also for other cases I'm sure I'm as yet unaware of.

Though I think I've got a solution by having a queue of Tuples instead of just the node, so I can associate the number of children with the parent (via a counter running on the other tree). If someone knows of/can think of a better approach I'd be happy to know.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Just because something needs to access data in the parent doesn't mean you can't use a depth first search. You just need to do it preorder rather than inorder (visit the root nodes before recursing). See http://en.wikipedia.org/wiki/Tree_traversal

Mr. Crow
May 22, 2008

Snap City mayor for life

Orzo posted:

Just because something needs to access data in the parent doesn't mean you can't use a depth first search. You just need to do it preorder rather than inorder (visit the root nodes before recursing). See http://en.wikipedia.org/wiki/Tree_traversal

The data they need access to isn't in the parent it's variable branches over and above.

So on the example tree on that page, C might need data from I.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Oh okay, I misinterpreted 'higher level node' as 'ancestor'

ljw1004
Jan 18, 2005

rum

ninjeff posted:

On that note, is there an official story for conversion to System.Linq.Expressions expressions from Roslyn's parser output? That would be really neat.

Not possible yet I'm afraid.

Roundabout idea: if you had an AST of an expression, then you could construct a new AST which was "return (Expression<Func<int>>)(_ => AST)". Then run it through the Roslyn compiler component to get an in-memory assembly. Then execute this assembly to get the expression-tree out of it.

Unfortunately this falls down because the current Roslyn CTP doesn't yet implement the "expression-trees" bit of either VB or C#. That is in the pipeline, though.

Unfortunately it also falls down in more interesting cases because the compilers don't support the conversion of statements into expression-trees: they can only turn expressions into expression-trees.

If you'd like to see statement-lambdas be turnable into expression trees -- then let us know! We're looking at future (post-Dev11) ideas in our language design meetings. A good way to communicate your wishes is through UserVoice:
http://visualstudio.uservoice.com/forums/121579-visual-studio/category/30931-languages-c-

ljw1004
Jan 18, 2005

rum

Zhentar posted:

And is there some legalese somewhere that defines what exactly re-distribution & production use mean?
Are there likely to be any updates to the CTP with further language feature support?

I'm afraid us engineers aren't allowed to help anyone with legalese -- if we say the wrong thing it counts as legally binding on MS.

And I'm afraid we also haven't announced any plans for further Roslyn CTP updates.


(I can tell you that an updated AsyncCTP is in the works though! for better Phone and Silverlight5 support.)

Adbot
ADBOT LOVES YOU

ninjeff
Jan 19, 2004

ljw1004 posted:

Not possible yet I'm afraid.

Roundabout idea: if you had an AST of an expression, then you could construct a new AST which was "return (Expression<Func<int>>)(_ => AST)". Then run it through the Roslyn compiler component to get an in-memory assembly. Then execute this assembly to get the expression-tree out of it.

Unfortunately this falls down because the current Roslyn CTP doesn't yet implement the "expression-trees" bit of either VB or C#. That is in the pipeline, though.

Unfortunately it also falls down in more interesting cases because the compilers don't support the conversion of statements into expression-trees: they can only turn expressions into expression-trees.

If you'd like to see statement-lambdas be turnable into expression trees -- then let us know! We're looking at future (post-Dev11) ideas in our language design meetings. A good way to communicate your wishes is through UserVoice:
http://visualstudio.uservoice.com/forums/121579-visual-studio/category/30931-languages-c-

Thanks for the reply!

It certainly would be cool if the compilers could generate statement expression trees. I'm imagining stuff like generating SQL procedures from code, or sending code to be executed on another machine (security concerns notwithstanding, of course). Not sure if I have a personal need to do that on the projects I'm working on right now, so I won't make a UserVoice post, but it's great to know that this kind of stuff is being considered.

  • Locked thread