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.
 
  • Post
  • Reply
Mr. Crow
May 22, 2008

Snap City mayor for life

chmods please posted:

How much control do you have over the external process? If the answer is "none", I'd recommend building your program as a shell which draws itself around the other windows, it sounds like asking for trouble otherwise.

For all intents and purposes, 'none' is the answer.

We already do have our program as a shell... sort of. We're basically just calling SetParent on the external app and installing some hooks, but there is some (predictably) hackish stuff put in to account for weird bugs, as well as just some general quirkiness to the look and feel.

I'd be curious if you had something else in mind when you said shell, maybe it's something we can do better?

Currently exploring / prototyping using HwndHost instead, I realize in a lot of ways it's just substituting old problems for new problems, but if we can solve the new ones, the other advantages it gives would be very beneficial.

Adbot
ADBOT LOVES YOU

shrughes
Oct 11, 2008

(call/cc call/cc)
Why the gently caress doesn't the OP have a link to the old thread?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

shrughes posted:

Why the gently caress doesn't the OP have a link to the old thread?

I updated the OP with the link, thanks for the perplexingly hostile reminder.

raminasi
Jan 25, 2005

a last drink with no ice
Can I thank you for making the great OP and suggest adding Sandcastle/SHFB to it :shobon:

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

GrumpyDoctor posted:

Can I thank you for making the great OP and suggest adding Sandcastle/SHFB to it :shobon:

Sure, write up a description and give me links because I'm lazy.

wwb
Aug 17, 2004

Thanks for updating the OP -- any way we could get the links to TortoiseHG / TortoiseSVN as well as bitbucket back in there?

uXs
May 3, 2005

Mark it zero!
Found this about WPF and MVVM: http://blog.lab49.com/archives/2650 and the video linked in there still works. I wish the video quality on the code samples was better, but the content (to me at least) seems very, very good.

It's taken me from having basically no clue about WPF to having a handle on how to make an MVVM application with WPF in about 1.5 hours. I realize there's a shitload more to learn but at least I feel like I have a very good base now to start from. Highly recommended viewing!

PapFinn
Jul 15, 2003

I am Ron Pearlman's illigitimate love child.
I'm not sure if this is the place to ask, but I'm working on picking up some job specific skills to make myself more useful with my company. We are using Classic ASP with Visual Basic. My understanding is that this is a significantly different environment that a ASP.Net/VB.Net environment.

Is that an accurate statement? If so, are there any suggested online resources for learning Classic ASP/VB? So far I'm looking at w3schools and http://www.tizag.com but I'm not sure if either of those are my best place to start or if I should just find some old books.

Any current sources for online learning are obviously focusing on modern frameworks, not stuck firmly in the past like my company.

wwb
Aug 17, 2004

Yes, they are vastly different beyond some surface similarities as to similar languages. Especially with Option Strict on. The best place to start is http://www.asp.net/get-started , that is probably one of the few sites still doing examples in VB.Net though -- most of the world has gone C#. You might wish to do the same.

uXs
May 3, 2005

Mark it zero!

wwb posted:

Yes, they are vastly different beyond some surface similarities as to similar languages. Especially with Option Strict on. The best place to start is http://www.asp.net/get-started , that is probably one of the few sites still doing examples in VB.Net though -- most of the world has gone C#. You might wish to do the same.

I think you misunderstand, he wants to learn classic ASP, not .NET.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

PapFinn posted:

I'm not sure if this is the place to ask, but I'm working on picking up some job specific skills to make myself more useful with my company. We are using Classic ASP with Visual Basic. My understanding is that this is a significantly different environment that a ASP.Net/VB.Net environment.

Is that an accurate statement? If so, are there any suggested online resources for learning Classic ASP/VB? So far I'm looking at w3schools and http://www.tizag.com but I'm not sure if either of those are my best place to start or if I should just find some old books.

Any current sources for online learning are obviously focusing on modern frameworks, not stuck firmly in the past like my company.

If you're familiar with modern languages and frameworks already, there's nothing much to pick up. It's your standard unmaintainable "presentation and business logic mushed together in one place" mess. Avoid working on it if you can, it sucks and no one hires classic ASP developers anymore.

wwb
Aug 17, 2004

You know I did manage to read that backwards.

I will note you can make very maintainable code in lovely old languages too, it just requires more discipline. And I've seen a boat load of ASP.NET apps with "presentation and business logic mushed together in one place"; arguably more so than in other frameworks that don't give you as many wizards to generate code.

mortarr
Apr 28, 2005

frozen meat at high speed
I have an internal site that serves branding content to other internal sites. It's made up of some dynamic css and images that are held in a database (accessed via EF) plus some static css, image and font files.

The dynamic stuff is accessed via a get to an MVC controller action method, with a query string like so: `http://url/template/css?unit=city-future&division=communications`. I wanted to use named params rather than primary keys, so it was clear in the secondary sites what was being pulled.

My main concern is that it's taking almost 1s to do the roundtrip to serve the css, and it's quite noticable with styles updating part way though page-load.

I thought I could add some kind of cache because the data is effectively static, but I've not worked with caching before, so can anyone give me some pointers or recommend some resources on caching in ASP.Net MVC / IIS?

Mr Shiny Pants
Nov 12, 2012
I've used the MemoryCache before. It works as advertised.

See: http://msdn.microsoft.com/library/system.runtime.caching.memorycache.aspx

You create a cache, put items in it and in your application that loads the resources you create the logic to check the cache first.

Please be aware that you can't depend on your files always being in the cache, if your machine gets low on memory it will purge some of the items in the cache.

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer
You might want to look into cache control headers so repeated page views from the same client won't need to hit your server. Check out the OutputCacheAttribute.

Also look at what EF is running to grab the content. SQL Express Profiler is free and can tell you what SQL is being executed. If the database is what's slowing everything down you might need to address what EF is generating or whether you need indexes in the database.

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
More trouble in ASP land. I think that my goal should be obvious from the code, but I'm having a lot of trouble googling the right answers. I'm working with a ListView, and States is an (incomplete) array of two letter State abbreviations.

code:
<ItemTemplate>

Length is <%# Eval("States.Length") %>

<%

 int length = int.Parse(Eval("States.Length").ToString()); // error
 
 for (int i=0; i<length; i++)
 {
  Response.Write("<li>");
  Response.Write(Eval("States[" + i + "]")); // again?
  Response.Write("</li>");
 }

%>

</ItemTemplate>
The error that gets thrown here is Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. Presumably the same thing would happen if it reached that line in the loop.

Suggestions?

Newf fucked around with this message at 19:13 on Jul 9, 2014

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Newf posted:

More trouble in ASP land. I think that my goal should be obvious from the code, but I'm having a lot of trouble googling the right answers. I'm working with a ListView.

code:
<ItemTemplate>

Length is <%# Eval("States.Length") %>

<%

 int length = int.Parse(Eval("States.Length").ToString()); // error
 
 for (int i=0; i<length; i++)
 {
  Response.Write("<li>");
  Response.Write(Eval("States[" + i + "]")); // again?
  Response.Write("</li>");
 }

%>

</ItemTemplate>
The error that gets thrown here is Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. Presumably the same thing would happen if it reached that line in the loop.

Suggestions?

Use a databound control, as suggested? This should be in a repeater, it looks like.

Or, better yet, don't use webforms if you don't have to.

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
It's perhaps not clear, but I am in a databound control (note that the first <%# Eval("States.Length") %> works). The problem is that the control is bound to an object which has a number of arrays as members, including the present States array.

The solution then, I guess, is to bind more specifically to the States array rather than its parent object.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Don't use a for-loop and don't use Response.Write in your ASPX page. Use another repeater bound to States, instead.

Chasiubao
Apr 2, 2010


What's everyone's opinion on the var keyword? I'm in the middle of a religious discussion on code reviews.

Team 1 has no hard and fast rules: use var where it makes sense, for super long nested generics, etc.

Team 2 insists that it should only be used when the type is immediately discernible from the rhs.

No Safe Word
Feb 26, 2005

Chasiubao posted:

What's everyone's opinion on the var keyword? I'm in the middle of a religious discussion on code reviews.

Team 1 has no hard and fast rules: use var where it makes sense, for super long nested generics, etc.

Team 2 insists that it should only be used when the type is immediately discernible from the rhs.

Use var like all the time basically. (Both teams are correct, and it should almost always be immediately discernible from the RHS or you should consider refactoring)

Chasiubao
Apr 2, 2010


No Safe Word posted:

Use var like all the time basically. (Both teams are correct, and it should almost always be immediately discernible from the RHS or you should consider refactoring)

code:
var x = await GetAMyObjectAsync(); // okay

var y = await DoAThingAsync(); // not okay
Team 2 is not happy with the second line because the return type of the RHS is not immediately discernible, but Team 1 does not want to rename DoAThingAsync to DoAThingThatReturnsMyResponseAsync.

omeg
Sep 3, 2012

Chasiubao posted:

code:
var x = await GetAMyObjectAsync(); // okay

var y = await DoAThingAsync(); // not okay
Team 2 is not happy with the second line because the return type of the RHS is not immediately discernible, but Team 1 does not want to rename DoAThingAsync to DoAThingThatReturnsMyResponseAsync.

Do they also want to return to Hungarian notation?

Chill Callahan
Nov 14, 2012
Can't you just mouse over 'var' to find out the type in VS? C# is still statically typed so I'm not sure why it's a big deal.

raminasi
Jan 25, 2005

a last drink with no ice

Chill Callahan posted:

Can't you just mouse over 'var' to find out the type in VS? C# is still statically typed so I'm not sure why it's a big deal.

It works less often than it should, and now you need to bring your IDE along when you go codebase history spelunking.

Chasiubao
Apr 2, 2010


omeg posted:

Do they also want to return to Hungarian notation?

:shrug:

I don't know.

wwb
Aug 17, 2004

I will publicly admit I came out in the "I hate var" school when it came out but have since learned to appreciate it. As a great man pointed out, perhaps in this thread, it is really the IDE's problem to figure out what type you are dealing with and it works brilliantly. Our rule here has become "just use var unless you can't use var" over the last few years.

Newf posted:

It's perhaps not clear, but I am in a databound control (note that the first <%# Eval("States.Length") %> works). The problem is that the control is bound to an object which has a number of arrays as members, including the present States array.

The solution then, I guess, is to bind more specifically to the States array rather than its parent object.

You have a few issues in this code. First thing, don't try and convert int to strings and then do int things to them (error #1). Response.Write() is also an abomination that should generally be avoided in ASP.NET webforms as it really screws with the page lifecycle.

In general, with complex data binding, you are better off convervting the Container.DataItem to your custom object and never loving using eval no Response.Write. Something like:

code:
<ItemTemplate>

<%
    var di = Container.DataItem as MyClass
%>

Length is di.States.Length %>

<%

 int length = di.States.Length
 
 for (int i=0; i<length; i++)
 {
    %>
	<li><%# di.States[i] #%>
%>
 }

%>

</ItemTemplate>
Been a really long time since I did webforms so that might not be perfectly kosher but you get the idea.

ShaunO
Jan 29, 2006

Chasiubao posted:

code:
var x = await GetAMyObjectAsync(); // okay

var y = await DoAThingAsync(); // not okay
Team 2 is not happy with the second line because the return type of the RHS is not immediately discernible, but Team 1 does not want to rename DoAThingAsync to DoAThingThatReturnsMyResponseAsync.

Use var everywhere, IMO.

Team 1 not wanting to have sensible names for their methods is a bit ridiculous and I think eclipses the var discussion. You shouldn't need to include the name of the return type in the method name but DoAThingAsync() should be fairly obvious what the return type is based on the context surrounding the code. I would expect something like a ThingResult object. I think with intuitive naming surrounded by code that clearly defines the context of what is going on, it shouldn't matter what the actual return types are.

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

wwb posted:

You have a few issues in this code. First thing, don't try and convert int to strings and then do int things to them (error #1). Response.Write() is also an abomination that should generally be avoided in ASP.NET webforms as it really screws with the page lifecycle.

In general, with complex data binding, you are better off convervting the Container.DataItem to your custom object and never loving using eval no Response.Write. Something like:

code:
...
Been a really long time since I did webforms so that might not be perfectly kosher but you get the idea.

Holy poo poo, this is great. The whole webforms thing is really still a mindfuck to me. The way that you can mix markup and code is kinda magical. Also, being able change this code on the fly and having it reflected on the next page load. I guess the c# is compiled on the fly when there's a page request?

Thanks all. I did end up binding directly to the States list (and then did the same for the other lists I wanted on the page).

wwb
Aug 17, 2004

More like ASP.NET takes the template file and generates a C# class that inherits from your page class and basically spits out a string at the end of the day. If you want to look under the hood, look at the next exception you get -- somewhere near the bottom of the page it will tell you the source file name, open it in your favorite text editor.

chippy
Aug 16, 2006

OK I DON'T GET IT
Someone please help me with this problem, it's driving me mental.

I maintain and extend an old .net 3.5 Winforms app. It was created in VS 2008 but I recently updated the project to VS 2013. As part of the migration, it automatically switched the targeted framework to 4.5. I didn't want to force all my users to upgrade (they have some XP machines), so I switched the target back to 3.5. There was a warning that I might have to manually edit some project files to get it to build, but it built and run fine so I didn't worry about it after that, everything was running fine on the customer's machines.

Recently I was asked to make some changes in part of the system that uses a bunch of stuff from Windows.Forms.DataVisualization.Charting. I can't open these forms up in the designer, I get a big page of errors and a warning that the designer might become unstable and I might lose some controls. The main errors are a bunch of failures to resolve the charting classes, stuff like this:

"Could not find type 'System.Windows.Forms.DataVisualization.Charting.ChartArea'. Please make sure that the assembly that contains this type is referenced. If this type is part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU'.

If I ignore them and open them in the designer, all those charts disappear.

The thing is, all the references in the project are pointing to the 3.5 version of the assembles, the projects build and run fine, and if I add new charts, they work fine too. The only thing that doesn't work, is opening up the existing forms in the designer. I don't understand why the compiler can resolve the references, and build the project, but the designer can't.

I've tried deleting and re-adding the references and it doesn't help. Although one thing I've noticed is that if I hover over the Chart control in the toolbox, it says version 4.0, even if I manually add those controls by adding the 3.5 version of the DLL onto the toolbox.

I tried switching the project to 4.0 and was then able to open the forms in the designer (wtf), but then when I tried to add new charts, I got an error message about not being able to create a reference to the assembly, which also seems odd, since I already had one. I managed to fix this by deleting and re-adding the references, and then everything worked, but the project was targeting 4.0, which I'm really trying to avoid.

Does anyone have any idea how I can get this working while still targeting 3.5?

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

Ithaqua posted:

Or, better yet, don't use webforms if you don't have to.

To follow up on this... The context here is that I'm making a web front-end that interfaces with a windows service which exposes a bunch of controls exposed via [ServiceContract] class and [OperationContract] methods. I'm using svcutil.exe to generate the client class for the webapp.

I understand that webforms are maybe on the way out, but they do seem like the simplest tool that's adequate for the job. Nothing super fancy will be going on - mostly CRUD interaction and configuring the windows service. Am I wrong about this? Are there reasons that I'd be better off going for an MVC2 app? (VS2010)

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Newf posted:

To follow up on this... The context here is that I'm making a web front-end that interfaces with a windows service which exposes a bunch of controls exposed via [ServiceContract] class and [OperationContract] methods. I'm using svcutil.exe to generate the client class for the webapp.

I understand that webforms are maybe on the way out, but they do seem like the simplest tool that's adequate for the job. Nothing super fancy will be going on - mostly CRUD interaction and configuring the windows service. Am I wrong about this? Are there reasons that I'd be better off going for an MVC2 app? (VS2010)

Web Forms is terrible and will almost never end up being the simplest tool for the job. As you already saw, something as simple as adding an <li> element for every item in a list isn't intuitive. The "event" structure of Web Forms is a misguided attempt to make the web like the desktop which ends up making everything inefficient. If there's nothing forcing you to use Web Forms, use MVC.

And if you can help it, don't use MVC2. Get the latest VS you can get your hands on and use the latest version of MVC.

wwb
Aug 17, 2004

Even if you are stuck on 2010 then you can defintiely use MVC4, which isn't the absolute latest and greatest but it is a decent snapshot of the point where most of the warts are worked out.

You can build stuff distrubingly quick -- with a little tweaking of datavalidation attributes and EditorFor you can beet webforms speed to market in terms of building CRUD apps. UI look and feel is pretty easy now that they have gone all twitter bootstrap on you. Moreover, it is something you probably want on the resume rather than web forms. Unless you enjoy maintaining dead-end legacy applications.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

ShaunO posted:

Use var everywhere, IMO.

var life 4 eva

raminasi
Jan 25, 2005

a last drink with no ice
I've got a solution that's started opening with some projects unloaded. I can manually load them fine, but I have to do it every time the solution is opened fresh. I deleted the .suo file for the solution and the problem didn't go away. This is on VS 2013. Anyone have any ideas?

Huragok
Sep 14, 2011
I'm not 100% sure but aren't solution project files selected for loading/unloading using the .vsproj? If that is the case and you use source control you should break out the rubber hose (:getin:) because someone must be committing the .vsproj with projects unloaded.

chippy
Aug 16, 2006

OK I DON'T GET IT

chippy posted:

Someone please help me with this problem, it's driving me mental.

I maintain and extend an old .net 3.5 Winforms app. It was created in VS 2008 but I recently updated the project to VS 2013. As part of the migration, it automatically switched the targeted framework to 4.5. I didn't want to force all my users to upgrade (they have some XP machines), so I switched the target back to 3.5. There was a warning that I might have to manually edit some project files to get it to build, but it built and run fine so I didn't worry about it after that, everything was running fine on the customer's machines.

Recently I was asked to make some changes in part of the system that uses a bunch of stuff from Windows.Forms.DataVisualization.Charting. I can't open these forms up in the designer, I get a big page of errors and a warning that the designer might become unstable and I might lose some controls. The main errors are a bunch of failures to resolve the charting classes, stuff like this:

"Could not find type 'System.Windows.Forms.DataVisualization.Charting.ChartArea'. Please make sure that the assembly that contains this type is referenced. If this type is part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU'.

If I ignore them and open them in the designer, all those charts disappear.

The thing is, all the references in the project are pointing to the 3.5 version of the assembles, the projects build and run fine, and if I add new charts, they work fine too. The only thing that doesn't work, is opening up the existing forms in the designer. I don't understand why the compiler can resolve the references, and build the project, but the designer can't.

I've tried deleting and re-adding the references and it doesn't help. Although one thing I've noticed is that if I hover over the Chart control in the toolbox, it says version 4.0, even if I manually add those controls by adding the 3.5 version of the DLL onto the toolbox.

I tried switching the project to 4.0 and was then able to open the forms in the designer (wtf), but then when I tried to add new charts, I got an error message about not being able to create a reference to the assembly, which also seems odd, since I already had one. I managed to fix this by deleting and re-adding the references, and then everything worked, but the project was targeting 4.0, which I'm really trying to avoid.

Does anyone have any idea how I can get this working while still targeting 3.5?

Further to this...

On my work machine (probably because I hosed around with it so much yesterday, trying to clear out all .NET 4.0 versions of the charting DLLs), I'm no longer able to add the .NET 3.5 chart controls to my toolbox in VS 2013. If I drag the DLL on, nothing happens. If I choose "Add Items", browse to the DLL and select it, I'm told the file doesn't exist, which is clearly not true as I just browsed to it.

And before that, if I add the chart DLLS from C:\Program Files (x86)\Microsoft Chart Controls\Assemblies, I'd get the massive page full of errors saying the types could not be found, but if I added the exact same files from a different location (C:\Charts), I'd get a single message saying the assembly couldn't be loaded.

So last night I tried the project on VS 2013 on my machine at home. I was able to install the .3.5 Chart Controls, add them to my toolbox, and add a chart to the project, all with no issues. But then when I saved, closed and re-opened the project, I got the page full of errors saying the types couldn't be initialised, on the form that was previously working fine in the designer.

Help :(

crashdome
Jun 28, 2011
I'll just throw some things out there. Somebody correct me if I'm way off base.

Permission/Security context of VS as compared to where the files are located? Is something conflicting with a DLL in the GAC vs the files you want?

If you reference assemblies directly, put copies in a source folder and reference from there. It helps avoid "unable to find" errors when you are working across multiple machines with potentially different file structure. Try not to reference assemblies in the 'Program Files' folders as you could potentially run into the virtual file system mucking everything up.

Adbot
ADBOT LOVES YOU

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

I cannot help, but you have my sympathy. These are the parts of development that make me want to jump out of a plane.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply