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
The Gripper
Sep 14, 2004
i am winner

Howmuch posted:

Thanks for the explanation and the link.

So either way, you'll always need admin access to reserve the namespace. I'll probably keep it the way it is for now.
If you reserve the namespace and set permissions on it so your application can register for it, you'll only require admin access once.

So you could reserve the namespace during install, when admin permissions might already be required, or bundle a separate script or application that can do it. That way your actual program won't need admin access.

Adbot
ADBOT LOVES YOU

Dietrich
Sep 11, 2001

I'm considering writing a windows service to use a web client to warm a IIS site up after the app pool recycles on a timed basis.

I'm pretty sure something like that exists somewhere already. Anyone have a lead for me?

uXs
May 3, 2005

Mark it zero!

Ithaqua posted:

I disagree about the dynamic SQL thing. I think it makes code a lot uglier and less maintainable.

By the way, you can replace all of your nested ifs with
code:
foreach (var c in controls.OfType<ComboBox>().Where(x => x.SelectedIndex != 0))

Well, sure. I pretty much write everything in Linq these days, for EF. But sometimes (increasingly rare) I still need to build some SQL.

I'm sure it could even make code easier to read in places, instead of abusing the poo poo out of reflection and what have you.

User0015
Nov 24, 2007

Please don't talk about your sexuality unless it serves the ~narrative~!
I'm not sure how tolerant you guys are with Stupid Newbie Questions, but I am troubled and I wish to share.

While I've been working on other parts of my little project, earlier I managed to get my listview working with a databind in XAML. It was a good day, but there is a dark secret to the code.

code:
private void listVideosView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (((System.Windows.Controls.ListBox)(sender)).SelectedItems.Count != 0)
            {
                if (((object[])(e.AddedItems))[0] != null)
                    textBox1.Text = (((ObservableCollection<listVideo.VideoData>)(((object[])(e.AddedItems))[0])))[0].Filename;
                else
                    textBox1.Text = (((ObservableCollection<listVideo.VideoData>)(((object[])(e.AddedItems))[1])))[0].Filename;
            }
            else ((System.Windows.Controls.ListBox)(sender)).SelectedIndex = 0;
        }
This works, mind you. But oh, oh god what have I done? Here is the class:

code:
public partial class listVideo : Window
    {

        ObservableCollection<VideoData> _VideoCollection =
        new ObservableCollection<VideoData>();

        public listVideo(string filename, string id)
        {
            _VideoCollection.Add(new VideoData {
                Filename = filename, ID = id, Status = String.Empty });
        }

        public ObservableCollection<VideoData> VideoCollection
        { get { return _VideoCollection; } }

        public class VideoData
        {
            public string Filename { get; set; }
            public string Status { get; set; }
            public string ID { get; set; }
        }
       

    }
This is actually pulled straight off a Codeproject tutorial. What I (think) I want is this.

code:
private void listVideosView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
	    //Do some check here to make sure the selection is still valid
	    //because this can occur when a file is added/deleted/renamed.
            textBox1.Text = (sender as listVideo).Filename; // or whatever is equivalent
        }
Bonus points if you guys can explain to me how I could just databind my stupid textbox and never bother with this gain. Even extra bonus points if there's a really simple approach to doing this that is completely different than mine and would have taken 5 minutes.

extra horror: var id = ((ObservableCollection<listVideo.VideoData>)(listVideosView.SelectedItems)[0])[0].ID; :suicide:

User0015 fucked around with this message at 00:48 on Nov 21, 2012

raminasi
Jan 25, 2005

a last drink with no ice
It looks like you're not using a separate view model, in which case you're doing things the Wrong Way. I'm interpreting your intention as this: whenever the user changes their selection in a ListBox, a TextBox updates with the content of what they've selected in some way. The way to do this properly is by binding your ListBox to a property in your view model, binding your TextBox to a property in your view model, and then rigging up the setter for the ListBox-bound property to update the TextBox-bound property so that whenever the former changes the latter does as well.

I think, anyway. I'm pretty new to WPF myself.

User0015
Nov 24, 2007

Please don't talk about your sexuality unless it serves the ~narrative~!
I'd prefer to stay out of view model stuff, for now. That will come later.

Keep in mind there's two possibly important things here: There's multiple columns of data (and I want just one column of info), and there is a DirectoryInfo object watching the folder itself, so the listview can change either by the user, or if a file changes in the directory. Part of the code there is handling the case where the user has a file selected that is then deleted, for example.

Forgot to add: I attempted to do something stupid simple earlier. A generic object with just those 3 Parameters (or whatever). This worked, except it was showing up as blank on the list view itself. I posted that problem here, and Ithaqua said "override your ToString" which I did. Except I needed it to spit out Filename in column 1, Status in column 2, etc....and I couldn't figure out how to separate the columns and the parameters.

User0015 fucked around with this message at 01:24 on Nov 21, 2012

raminasi
Jan 25, 2005

a last drink with no ice

User0015 posted:

I'd prefer to stay out of view model stuff, for now. That will come later.

User0015 posted:

Even extra bonus points if there's a really simple approach to doing this that is completely different than mine and would have taken 5 minutes.

:confused:

User0015
Nov 24, 2007

Please don't talk about your sexuality unless it serves the ~narrative~!
I'm worried digging into view model stuff won't be a 5 minute thing, but another hurdle that will take a long time to learn. I have so much I need to get up to speed with already, I really hate to add another thing on top of it. That's all. Especially if it isn't strictly necessary and there's other ways to do it in 5 minutes.

wwb
Aug 17, 2004

Dietrich posted:

I'm considering writing a windows service to use a web client to warm a IIS site up after the app pool recycles on a timed basis.

I'm pretty sure something like that exists somewhere already. Anyone have a lead for me?

Modern versions of IIS have some app warmup plumbing, see http://blogs.iis.net/thomad/archive/2009/10/14/now-available-the-iis-7-5-application-warm-up-module.aspx for an intro.

I have not used it myself so I can't add anything meaningful.

@User0015: use the model view stuff. It seems like double work on the surface, but the truth of it is you are being much more ornithological. Model binding is one problem. Updating the database is another problem. They have strange conflicts the way ASP.NET MVC and .NET ORMS are implemented.

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

User0015 posted:

I'm worried digging into view model stuff won't be a 5 minute thing, but another hurdle that will take a long time to learn. I have so much I need to get up to speed with already, I really hate to add another thing on top of it. That's all. Especially if it isn't strictly necessary and there's other ways to do it in 5 minutes.

The big problem with WPF is that it doesn't let you fall into pit of success and gives you enough rope to hang yourself with. Where ASP.NET MVC forces you to do the "right thing" (MVC pattern) and makes it really hard to do the "wrong thing" like put data access code in your web page. The correct path for WPF is doing MVVM even if the tooling and language doesn't point you in that direction. It is the correct path and will remove all of that nasty code through data binding.

gariig fucked around with this message at 02:07 on Nov 21, 2012

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog

Dietrich posted:

I'm considering writing a windows service to use a web client to warm a IIS site up after the app pool recycles on a timed basis.

I'm pretty sure something like that exists somewhere already. Anyone have a lead for me?

This do the trick? http://www.iis.net/downloads/microsoft/application-initialization

Sedro
Dec 31, 2008

User0015 posted:

I'd prefer to stay out of view model stuff, for now. That will come later.
You are almost doing MVVM already. Just tweak some naming and viola:
C# code:
public class VideoViewModel
{
    public string Filename { get; set; }
    public string Status { get; set; }
    public string ID { get; set; }
}

public class VideoLibraryViewModel
{
    readonly ObservableCollection<VideoViewModel> _videos;

    public VideoLibraryViewModel(string filename, string id)
    {
        _videos = new ObservableCollection<VideoViewModel>();
        _videos.Add(new VideoViewModel {
            Filename = filename, ID = id, Status = String.Empty });
    }

    public ObservableCollection<VideoViewModel> Videos
    {
        get { return _videos; }
    }
}
Then to solve your problem using MVVM, you could add the following:
C# code:
public class VideoLibraryViewModel : INotifyPropertyChanged
{
    ...

    VideoViewModel _selectedVideo;
    public VideoViewModel SelectedVideo
    {
        get { return _selectedVideo; }
        set
        {
            if (_selectedVideo != value)
            {
                _selectedVideo = value;
                FirePropertyChanged("SelectedVideo");
            }
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    void FirePropertyChanged(string propertyName)
    {
        var handler = PropertyChanged;
        if (handler != null)
            handler(this, new PropertyChangedEventArgs(propertyName));
    }
}
XML code:
<ListBox
    ItemsSource="{Binding Videos, Mode=OneWay}"
    SelectedItem="{Binding SelectedVideo, Mode=TwoWay}"
    />
<TextBox
    Text="{Binding SelectedVideo.Filename, Mode=OneWay}"
    />

User0015
Nov 24, 2007

Please don't talk about your sexuality unless it serves the ~narrative~!
Hmm. What would the structure of the project look like? Are each of these classes just a separate file? Are they included somewhere specifically?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

User0015 posted:

Hmm. What would the structure of the project look like? Are each of these classes just a separate file? Are they included somewhere specifically?

Read this:
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

uXs posted:

Well, sure. I pretty much write everything in Linq these days, for EF. But sometimes (increasingly rare) I still need to build some SQL.

I'm sure it could even make code easier to read in places, instead of abusing the poo poo out of reflection and what have you.

My dynamic SQL aversion is probably because in the Dark Ages of 2008, I worked for a place that had a rule: No in-line SQL, anywhere, ever. Stored procedures only. So I ended up with some truly butt-ugly stored procedures, but at least my code was nice and clean.

Have you ever felt like you needed to unit test your SQL?

wwb
Aug 17, 2004

Yup. Done it with home rolled ORMs, no ORMs and with "real ORMs"

These days my data access strategy is:
* RavenDb (seriously gently caress sql and schemas)
* [smaller scale, fixed inputs / outcomes] : Dapper
* [larger scale, not so fixed inputs] : EF code first

uXs
May 3, 2005

Mark it zero!

Ithaqua posted:

My dynamic SQL aversion is probably because in the Dark Ages of 2008, I worked for a place that had a rule: No in-line SQL, anywhere, ever. Stored procedures only. So I ended up with some truly butt-ugly stored procedures, but at least my code was nice and clean.

Have you ever felt like you needed to unit test your SQL?

Well, your C# code may have been nice and clean, but SQL code is still code. It's like saying your room is clean while your closet is full of rats and dead pigeons. And poo poo.

As for unit testing: I only really started to unit test very recently, after I switched to EF. So there's basically no SQL code anyway. And if there was, I'd probably just use integration tests. (Which is what I do for the really low level EF code too.)

wwb
Aug 17, 2004

^^^ I generally argue that anything using these magic linq containers really needs unit tests to at least force the linq to generate the SQL successfully. You can do lots of things that will compile, do just fine in linq to objects and then crash magic sql generators hard.

The nightmarish part of unit testing database stuff is when you have data you care about in some way shape in form. If you are just testing the schema build + your magic sql generator then you are in better shape than most.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

wwb posted:

^^^ I generally argue that anything using these magic linq containers really needs unit tests to at least force the linq to generate the SQL successfully. You can do lots of things that will compile, do just fine in linq to objects and then crash magic sql generators hard.

The nightmarish part of unit testing database stuff is when you have data you care about in some way shape in form. If you are just testing the schema build + your magic sql generator then you are in better shape than most.

I just did a project using nHibernate, which can be a huge pain in the rear end to get mappings set up correctly. I used Sqlite as my integration test database, and still bumped into some weird issues.

For example, I needed to do a query that grouped up the year/month. It's hair-pullingly frustrating to do that with nHibernate, so I ended up giving it a sql fragment to group on. It turns out Sqlite doesn't support YEAR() and MONTH() functions. :argh:

aBagorn
Aug 26, 2004
This is probably more of just me being dumb, but here goes anyway.

In doing some post-deployment tweaking between one project and the next, I want to find out all ways I can improve performance (or, in this case, user's perceived performance). I've done some really good refactoring in the data access layer, and cleaned up my models, controller, and view models. Now I want to see if I can shave off any more precious milliseconds.

We have several Partial Views that are nested within divs on one View (and then made pretty with jQuery tabs), as such:

code:
<div id="General">
    @{Html.RenderAction("General");}
</div>
<div id="Benefits">
    @{Html.RenderAction("Benefits");}
</div>
<div id="Billing">
    @{Html.RenderAction("Billing");}
</div>
<div id="Claims">
    @{Html.RenderAction("Claims");}
</div>
<div id="Agent">
    @{Html.RenderAction("Agent");}
</div>
<div id="Product">
    @{Html.RenderAction("ProductForm");}
</div>
I'm using Html.RenderAction to load them all, and (as expected?) It's loading them synchronously, one after the other. I was wondering how (if at all) I could load them parallel, as the three in the middle (Benefits/Billing/Claims) are bottlnecks due to the business logic involved in constructing their view models. There's probably a way to do it with AJAX or using RenderPartial and stuffing them all in one Async Controller method, but I don't know.

Just looking for some ideas at this point, and it's not like it's business critical, but I figured if anyone would know, it's you guys (and asking this question validates my justification to have the forums unblocked by our new web filter since I use them for 'business purposes')

wwb
Aug 17, 2004

This definitely applies to nhibernate too.

If I am going through the pain of testing against a real live database, I would definitely test against at least a family member of what is in production. I never understood the fascination of using sqllite as a test bed, might as well use sql express.

Note this also applies to ravendb -- the embedded version can see things the server can't, seen lots of code that seems briliant in local tests that dies when talking cross-process.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

aBagorn posted:

I want to find out all ways I can improve performance

First: Profile the application. Use ANTS or the built-in VS profiler.

aBagorn
Aug 26, 2004

Ithaqua posted:

First: Profile the application. Use ANTS or the built-in VS profiler.

We're getting a version of ANTS before the calendar year is over :swoon:

But no VS Profiler though, we're only on Professional

aBagorn fucked around with this message at 17:38 on Nov 21, 2012

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

aBagorn posted:

We're getting a version of ANTS before the calendar year is over :swoon:

But no VS Profiler though, we're only on Professional

You should be able to use AJAX.RenderPartial. Hack around at it a little bit.

What's with the ugly @{HTML.RenderAction("foo");} stuff, anyway? Those curly braces are redundant, and removing them will make the semicolon redundant too.

aBagorn
Aug 26, 2004

Ithaqua posted:

You should be able to use AJAX.RenderPartial. Hack around at it a little bit.

What's with the ugly @{HTML.RenderAction("foo");} stuff, anyway? Those curly braces are redundant, and removing them will make the semicolon redundant too.

@Html.Action("foo") returns MvcHtmlString and can be called without braces/semicolon

@Html.RenderAction("foo") returns void and needs the braces/semicolon

(I think they are functionally equivalent in this case.

Sedro
Dec 31, 2008

User0015 posted:

Hmm. What would the structure of the project look like? Are each of these classes just a separate file? Are they included somewhere specifically?
I made you a quick example here.

30 TO 50 FERAL HOG
Mar 2, 2005



So I've created a web app in Visual Web Developer 2010 that uses a database and want to pull data out of that database with a C# app I'm making. The problem is that Web Developer only supports SQL Compact 4.0 and Visual C# only supports SQL Compact 3.5. They are not forward or backward compatible.

How the gently caress do I do this because I'm about to burn Redmond to the ground.

glompix
Jan 19, 2004

propane grill-pilled

Ithaqua posted:

You should be able to use AJAX.RenderPartial. Hack around at it a little bit.

What's with the ugly @{HTML.RenderAction("foo");} stuff, anyway? Those curly braces are redundant, and removing them will make the semicolon redundant too.

It's because the method writes directly to the response stream. I haven't messed around with MVC much lately but I think there are cleaner equivalents now that actually return IHtmlStrings and don't introduce confusing use cases, as noted.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

BiohazrD posted:

Visual C# only supports SQL Compact 3.5.

That's not true. What version are you talking about?

http://blogs.msdn.com/b/sqlserverco...s-2010-sp1.aspx

30 TO 50 FERAL HOG
Mar 2, 2005



Ithaqua posted:

That's not true. What version are you talking about?

http://blogs.msdn.com/b/sqlserverco...s-2010-sp1.aspx

I'm using Express unfortunately, which doesn't have SP1. I can grab a license for the real deal if I have to, or try Express 2012.

Zhentar
Sep 28, 2003

Brilliant Master Genius

BiohazrD posted:

I'm using Express unfortunately, which doesn't have SP1.

That is also not true. VS 2010 Express has the exact same SP1 as every other version of VS 2010.


aBagorn posted:

But no VS Profiler though, we're only on Professional

If you can upgrade to 2012, 2012 Pro does include the profiler.

Zhentar fucked around with this message at 22:49 on Nov 21, 2012

adaz
Mar 7, 2009

WCF question hoping you all can help me with. I think I know the answer I just want some internet confirmation here.

Say I have a data contract like this

code:
<DataContract>
Public Class BaseErrorInfo

<DataMember>
Public Property innerException as Exception

End Class
Now, from what I recall and understand of the WCF serializer if I try to throw a derived type of exception - like ArgumentNullException - into innerException property it's going to blow up right? I have to cast ArgumentNullException to i base exception correct or implement the KnownType attributes on whatever derived exceptions I'm expecting to put in there?

Kind of confirming how I'm going to handle fault contracts, but also derived types.

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy
Is there a significant performance difference loading a workflow activity from XAML versus defining it entirely in code?

osigas
Mar 4, 2006

Then maybe you shouldn't be living here

aBagorn posted:

This is probably more of just me being dumb, but here goes anyway.

In doing some post-deployment tweaking between one project and the next, I want to find out all ways I can improve performance (or, in this case, user's perceived performance). I've done some really good refactoring in the data access layer, and cleaned up my models, controller, and view models. Now I want to see if I can shave off any more precious milliseconds.

We have several Partial Views that are nested within divs on one View (and then made pretty with jQuery tabs), as such:

code:
<div id="General">
    @{Html.RenderAction("General");}
</div>
<div id="Benefits">
    @{Html.RenderAction("Benefits");}
</div>
<div id="Billing">
    @{Html.RenderAction("Billing");}
</div>
<div id="Claims">
    @{Html.RenderAction("Claims");}
</div>
<div id="Agent">
    @{Html.RenderAction("Agent");}
</div>
<div id="Product">
    @{Html.RenderAction("ProductForm");}
</div>
I'm using Html.RenderAction to load them all, and (as expected?) It's loading them synchronously, one after the other. I was wondering how (if at all) I could load them parallel, as the three in the middle (Benefits/Billing/Claims) are bottlnecks due to the business logic involved in constructing their view models. There's probably a way to do it with AJAX or using RenderPartial and stuffing them all in one Async Controller method, but I don't know.

Just looking for some ideas at this point, and it's not like it's business critical, but I figured if anyone would know, it's you guys (and asking this question validates my justification to have the forums unblocked by our new web filter since I use them for 'business purposes')

Don't use Actions.
In your situation, where you aren't passing anything in to each action and require a specific order to things, you'd probably be better off processing it all together and then calling it as Partials.

e.g. Controller
code:
public ActionResult Page()
{
  var model = new PageModel();
  
  model.General = PrepareGeneralModel();
  model.Benefits = PrepareBenefitsModel();
  /* .... */
  return View(model);
}

private GeneralModel PrepareGeneralModel()
{
  return new GeneralModel { /* logic */ };
}
/* ... */
Then with your view...
code:
@Model PageModel

@{Html.RenderPartial("General", model.General);}
@{Html.RenderPartial("Benefits", model.Benefits);}
<!-- ... -->
Plus, you get the added benefit of not calling all those Actions, which causes a round trip through the MVC structure for each one.

epswing
Nov 4, 2003

Soiled Meat
Just a heads up, Mindscape is having a Black Friday sale, where the price increases by $1 every time they make a sale.

I just bought WPF Elements for $151, so now it costs $152 (retails for $799).

http://www.mindscapehq.com/black-friday-2012

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

adaz posted:

WCF question hoping you all can help me with. I think I know the answer I just want some internet confirmation here.

Say I have a data contract like this

code:
<DataContract>
Public Class BaseErrorInfo

<DataMember>
Public Property innerException as Exception

End Class
Now, from what I recall and understand of the WCF serializer if I try to throw a derived type of exception - like ArgumentNullException - into innerException property it's going to blow up right? I have to cast ArgumentNullException to i base exception correct or implement the KnownType attributes on whatever derived exceptions I'm expecting to put in there?

Kind of confirming how I'm going to handle fault contracts, but also derived types.

My WCF is a little rusty, but that should work just fine. You can assign an ArgumentNullException to a property of type Exception.

Of course, in my view, an exception that occurs within your WCF service should be handled within your WCF service. You can certainly notify the caller that something went wrong, but the caller shouldn't necessarily be concerned with the exact nature of the problem, especially if it's something that the caller has no control over and can't possibly recover from.

I'd probably just end up having the result be something along these lines:
code:
public enum ResultType
{
	Success,
	Error
}

public struct ServiceResult
{
	public ResultType ResultType {get; private set;}
	public string ResultMessage {get; private set;}
	
	public ServiceResult(ResultType resultType, string ResultMessage)
	{
		this.ResultType = resultType;
		this.ResultMessage = resultMessage;
	}
}
Then, you can pass a ServiceResult back along to the caller. The caller can check if the call succeeded or not, and if not, it can log the result message and do whatever sort of cleanup or recovery is necessary.

Meanwhile, on the service side, you can catch and handle your actual exceptions however you want, including logging full stack traces and other relevant information that's totally useless from the perspective of the caller.

Essential
Aug 14, 2003
In case anyone is curious, I finally had a chance last night to test my Silverlight 5 Out Of Browser app on a MAC and it works! Had no issues accessing the file system, copying files, creating directories, renaming files etc.

For the record that's 1 application, 1 code base, works on both PC and MAC with full local file system access.

adaz
Mar 7, 2009

Ithaqua posted:

My WCF is a little rusty, but that should work just fine. You can assign an ArgumentNullException to a property of type Exception.

Of course, in my view, an exception that occurs within your WCF service should be handled within your WCF service. You can certainly notify the caller that something went wrong, but the caller shouldn't necessarily be concerned with the exact nature of the problem, especially if it's something that the caller has no control over and can't possibly recover from.


Oh sure, but there are occasions when I'd like to let a client know more about the exception (for centralized logging purposes as an example) than just a general fault type message which I why I was asking. Also, having a derived class and knowing if it can be serialized is a fairly common scenario.

Not that I don't believe you Ithaqua - your advice tends to be stellar and on point - but I went and looked this up on msdn and found the section. Assuming I'm reading it right you in fact cannot send a derived type without using the Known Type attribute: http://msdn.microsoft.com/en-us/library/ms734767(v=vs.100).aspx unless I am reading this completely wrong!

msdn posted:

A data contract from a derived class can be sent when a data contract from a base class is expected, but only if the receiving endpoint "knows" of the derived type using the KnownTypeAttribute. For more information, see Data Contract Known Types. In the previous example, an object of type Employee can be sent when a Person is expected, but only if the receiver code employs the KnownTypeAttribute to include it in the list of known types.


Ithaqua posted:

I'd probably just end up having the result be something along these lines:
code:
public enum ResultType
{
	Success,
	Error
}

public struct ServiceResult
{
	public ResultType ResultType {get; private set;}
	public string ResultMessage {get; private set;}
	
	public ServiceResult(ResultType resultType, string ResultMessage)
	{
		this.ResultType = resultType;
		this.ResultMessage = resultMessage;
	}
}
Then, you can pass a ServiceResult back along to the caller. The caller can check if the call succeeded or not, and if not, it can log the result message and do whatever sort of cleanup or recovery is necessary.

Meanwhile, on the service side, you can catch and handle your actual exceptions however you want, including logging full stack traces and other relevant information that's totally useless from the perspective of the caller.

This is actually an interesting idea. Essentially going back to the age old do you want exceptions (fault contracts in WCF terminology) or like result codes as you propose. I'm not a huge fan of using exceptions to handle every known error, and I think I like your approach much better than a fault contract. Or, more precisely, use this when at all possible but still define a fault contract for true exceptions like can't communicate with endpoint type of things.

e: Also somewhat random but I cam across this nice link on SQL Query optimization. I'm not a DBA and try to avoid directly touching SQL when at all possible (thanks to you folks and your push of entity framework :)) but like a lot of folks I end up doing more of it than I'd like. Good blog post on just the basics of query optimization and stuff if you're using MS SQL Server: http://blogs.msdn.com/b/karthick_pk/archive/2012/11/22/tuning_2d00_sql_2d00_server_2d00_query.aspx

adaz fucked around with this message at 23:13 on Nov 22, 2012

UberJumper
May 20, 2007
woop
Is there anyway to use expression blend to simply add new and edit existing brushes defined in a resource dictionary?

I have never used expression blend, and i really don't want to manually create all of the brushes by hand.

If i open the project in expression blend (which takes forever), i can see the existing brushes under the resource tab, however it doesn't seem to let me add new ones.

Adbot
ADBOT LOVES YOU

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm finally getting around to working on my project that uses MVC and MVVM for WPF with some shared code. I had previously asked about how to separate the project logically and am going for something like:
Project.Web.View
Project.Web.Controllers
Project.Client.View
Project.Client.ViewModels
Project.Model
Project.Data
Project.Tests.Unit

I have this mostly set up. I made the Controllers project a class library, but when I moved my controllers to this project, I lose the ability to scaffold views from a controller via right click. Did I setup the project wrong or is there another way to maintain this functionality?

Additionally, since I'm also new to Entity Framework, I wasn't sure which code went into Data vs Model in the above project structure. Would models only hold the basic model classes that inherit DbContexts and then the Data project house interfaces and classes with virtual properties that represent the data from the model? Getting slightly confused on this part. Is this unnecessary separation or call all of that go in Models and I don't need a separate Data project?

Screenshot of how I have it so far:

Uziel fucked around with this message at 21:01 on Nov 24, 2012

  • Locked thread