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
New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Bognar posted:

This is kind of lovely since it's dodging your question entirely, but my recommendation is to avoid web services if you're just starting out with C#. They are basically legacy now and there's no real reason to start a new project with one these days. If you're trying to make something web accessible, then I'd recommend looking into ASP.NET MVC and Web API. The tutorials over at http://www.asp.net/web-api are decent enough to get started.

Yeah, web services are double legacy. They were eclipsed by WCF services which were eclipsed by WebAPI.

Adbot
ADBOT LOVES YOU

Begall
Jul 28, 2008

Bognar posted:

This is kind of lovely since it's dodging your question entirely, but my recommendation is to avoid web services if you're just starting out with C#. They are basically legacy now and there's no real reason to start a new project with one these days. If you're trying to make something web accessible, then I'd recommend looking into ASP.NET MVC and Web API. The tutorials over at http://www.asp.net/web-api are decent enough to get started.

Fair enough, this also has the key advantage that it worked the first time I tried it, thanks!

raminasi
Jan 25, 2005

a last drink with no ice
code:
double[] x = { building.geoProperties.CoreArea + building.geoProperties.PerimeterArea };
Expression has been evaluated and has no value
res.Data["Total Area"] = new UmiDataSeries { Data = x };
{Mit.Umi.Core.UmiDataSeries}
    Data: {double[1]}
    Name: null
    Resolution: null
    Units: null
res.Data["Total Area"] = new UmiDataSeries { Data = { building.geoProperties.CoreArea + building.geoProperties.PerimeterArea } };
[don't wanna break the tables] threw an exception of type 'System.NullReferenceException'
what

This is not just happening in the Immediate window - the exception is thrown by my code. Seriously, what the hell is this?

edit: I made a simpler case

raminasi fucked around with this message at 05:54 on Dec 30, 2015

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
A bug in the indexer for the Data property?

ninjeff
Jan 19, 2004

GrumpyDoctor posted:

code:
double[] x = { building.geoProperties.CoreArea + building.geoProperties.PerimeterArea };
Expression has been evaluated and has no value
res.Data["Total Area"] = new UmiDataSeries { Data = x };
{Mit.Umi.Core.UmiDataSeries}
    Data: {double[1]}
    Name: null
    Resolution: null
    Units: null
res.Data["Total Area"] = new UmiDataSeries { Data = { building.geoProperties.CoreArea + building.geoProperties.PerimeterArea } };
[don't wanna break the tables] threw an exception of type 'System.NullReferenceException'
what

This is not just happening in the Immediate window - the exception is thrown by my code. Seriously, what the hell is this?

edit: I made a simpler case

If you want to initialise IListProperty to an array then line 27 should be IListProperty = new [] { 1.0 }. If you want it to be some other collection type then you need to specify that. As-is, what you have there compiles to something like:
code:
var caseB = new IListMember();
caseB.IListProperty.Add(1.0);
You should be able to see why this throws a NullReferenceException :)

EssOEss
Oct 23, 2006
128-bit approved
I find it a good practice in general to ensure that my objects never have null-valued container fields.

code:
class IListMember
{
    public IList<double> IListProperty { get; set; } = new List<double>();	
}

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy


I swear I've checked this checkbox at least 100 times and it doesn't do a god drat thing.

Munkeymon
Aug 14, 2003

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



So it works about as well as the 'keep me logged in' check box or basically Microsoft's web login system in general?

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Munkeymon posted:

So it works about as well as the 'keep me logged in' check box or basically Microsoft's web login system in general?

Type in your email address and password to log in. Wait gently caress, you typed in your email address, did you mean an organizational account or a personal account? You don't know? Well gently caress you. Okay you clicked one, hold on while I bounce you through 10 redirects to login on a different page.

Munkeymon
Aug 14, 2003

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



Or when you get bounced out to a login page but don't notice during the minutes it's valid. Now there's an error message about something being invalid? Well I'm sure that doesn't confuse anyone ever.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Works On My Machine

Che Delilas
Nov 23, 2009
FREE TIBET WEED

Ithaqua posted:

Works On My Machine

The mark of quality code.

crashdome
Jun 28, 2011
Ok I see you are logging in from a new device. We're going to text you a code or maybe an email. We can wait while you run to another device to check that code.... I hope you don't have alzheimers!

OK you got the code and you managed to enter it correctly. Great! Please wait while we forget what page you were on and redirect you back to the beginning. We'll probably ask you to login again.

Squall
Mar 10, 2010

"...whatever."

crashdome posted:

Ok I see you are logging in from a new device. We're going to text you a code or maybe an email. We can wait while you run to another device to check that code.... I hope you don't have alzheimers!

OK you got the code and you managed to enter it correctly. Great! Please wait while we forget what page you were on and redirect you back to the beginning. We'll probably ask you to login again.

If you have two factor auth setup without a really quick and easy way to access the codes you need, you kind of deserve to be jerked around imo

ninjeff
Jan 19, 2004

crashdome posted:

Ok I see you are logging in from a new device. We're going to text you a code or maybe an email. We can wait while you run to another device to check that code.... I hope you don't have alzheimers!

OK you got the code and you managed to enter it correctly. Great! Please wait while we forget what page you were on and redirect you back to the beginning. We'll probably ask you to login again.

Ok I see you are logging in from a new device in bed in the middle of the night and your two-week old baby has just fallen asleep. We've sent you an SMS! Now you must race against time to put your phone on silent before it makes a big-rear end sound and wakes up the whole family.

crashdome
Jun 28, 2011

Squall posted:

If you have two factor auth setup without a really quick and easy way to access the codes you need, you kind of deserve to be jerked around imo

I want to live in your world where you can supposedly turn off that feature.

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer

GrumpyDoctor posted:

I'm having a weird AutoMapper problem. Mapper.AssertConfigurationIsValid() succeeds, but all my actual mappings are failing with "Missing type map configuration or unsupported mapping." As an example: I'm mapping a Source.GlazingMaterial to a Destination.GlazingMaterial, but the mapper, in a child mapping, then tries to map the source object itself to an Int32 field, which obviously fails. I don't know which one, because neither type even has any Int32 fields. Something like this is happening with every type - the mapper tries to map the source object itself to a field on the destination object (which may not even exist). Calling Mapper.Reset() before establishing my mappings doesn't fix the problem. Is there any way to ask AutoMapper wtf it thinks it's doing?

e: When the exception is thrown, AutoMapperMappingException.Context.MemberName is empty. That seems...wrong.
Wild guess, is the Mapper.AssertConfigurationIsValid in the same build mode (debug/release)? Anything funky with the models being in assemblies targeting different runtime versions from the call site/tests?

raminasi
Jan 25, 2005

a last drink with no ice

Destroyenator posted:

Wild guess, is the Mapper.AssertConfigurationIsValid in the same build mode (debug/release)? Anything funky with the models being in assemblies targeting different runtime versions from the call site/tests?

The call to Mapper.AssertConfigurationIsValid is in the same assembly as the map definitions and the actual calls to Map, so I don't think that's the problem. I could double-check the runtime versions of all relevant assemblies, but I discovered that it's not actually all types, just the first few that I tested. I switched those to manual mapping and everything seems to be "working" now.

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer
Weird. Any chance it's generating a parent class mapping that's getting selected so the child specific fields aren't recognised?

raminasi
Jan 25, 2005

a last drink with no ice

Destroyenator posted:

Weird. Any chance it's generating a parent class mapping that's getting selected so the child specific fields aren't recognised?

The types of the fields it's trying to map to don't match any types of any properties anywhere within the destination class hierarchy. I have no idea where they're coming from.

Inverness
Feb 4, 2009

Fully configurable personal assistant.
I'd like to see the ICompileModule feature from DNX be supported on other platforms.

raminasi
Jan 25, 2005

a last drink with no ice
I'd like to use the same text in generated documentation files and actual help text used when my application runs. Is there an elegant way to do this?

EssOEss
Oct 23, 2006
128-bit approved
Okay, I have managed to write down all my relevant learnings about NuGet packaging in the modern way. Phew, that was more effort than I expected!


Comments very welcome! Code is on GitHub.

Trying out this SO self-answered questions format. Yay, already one vote to close from some jerk who didn't even read my text!

EssOEss fucked around with this message at 12:33 on Jan 6, 2016

unpacked robinhood
Feb 18, 2013

by Fluffdaddy
I'd like to highlight words in a word document that match a given regexp, and eventually turn them into merge fields.

Currently the script I came up with correctly identifies the words I'm looking for but the highlight is all over the place, and I commented out the merge fields part because it's not ready yet.

code:
Sub lookForFields()
'
' lookForFields Macro
'
    Dim para As Paragraph
    Dim lineText As String
    Dim regEx As New RegExp
    Dim strPattern As String: strPattern = "\<(.*?)\>"
    'Dim strPattern As String: strPattern = "<([\w]+)>"
    Dim strInput As String
    Dim region As Word.Range
    Dim allmatches As MatchCollection
    Dim currentWord As String
    
    Debug.Print (vbCrLf + "------------------")
    Dim res As String
        With regEx
            .Global = True
            .MultiLine = False
            .IgnoreCase = True
            .Pattern = strPattern
        End With


   For Each para In ActiveDocument.Paragraphs
        txt = para.Range.Text
        Set allmatches = regEx.Execute(txt)
       For Each m In allmatches
       Set rng = ActiveDocument.Range(Start:=m.FirstIndex + para.Range.Start, End:=m.FirstIndex + Len(m.Value) + para.Range.Start)
            Debug.Print m.Value, para.Range.Start, m.FirstIndex, Len(m.Value)
            'Set myField = ActiveDocument.Fields.Add(Range:=rng, Type:=wdFieldMergeField, Text:="scuba")
            rng.HighlightColorIndex = wdYellow
        Next m
    Next para

End Sub
How would I go about making this work correctly ?

e: updated script, it highlights like I want it to but replacing the hilighted words with mergefields doesn't work reliably.

unpacked robinhood fucked around with this message at 17:07 on Jan 6, 2016

Mr Shiny Pants
Nov 12, 2012
This is probably a long shot, but here goes: I want to save emails relevant to projects in our ERP system. We don't actually want to save the actual emails but a link to them. Does anyone know if I can use the EWS api in Exchange to get a link to an email that when the user clicks the link it will open the email? Sort of like how saving the URL of a PDF saved on SharePoint will open Acrobat and the corresponding PDF file.

Inverness
Feb 4, 2009

Fully configurable personal assistant.
I suggest you copy that documentation over to your github repo wiki or to md files in the repo.

Are SO self-answered questions even allowed?

Kekekela
Oct 28, 2004

Inverness posted:


Are SO self-answered questions even allowed?

They are in the context of finding an answer out later to a question you were legitimately asking.

e: I'm not sure about what essoess is going for though, seems kind of grey area (as evidenced by the 3 votes to close being for 3 different reasons) but I upvoted anyway because goons. there you have it VV

Kekekela fucked around with this message at 18:44 on Jan 6, 2016

epswing
Nov 4, 2003

Soiled Meat
http://stackoverflow.com/help/self-answer

quote:

Stack Exchange has always explicitly encouraged users to answer their own questions. If you have a question that you already know the answer to, and you would like to document that knowledge in public so that others (including yourself) can find it later, it's perfectly okay to ask and answer your own question on a Stack Exchange site.

Munkeymon
Aug 14, 2003

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



Anyone else think it's be nice to have a "Only break on uncaught exceptions in files currently open in the editor" option? Getting sick of closing tabs I don't want open just because something I didn't break and can't fix is failing off in the corner over there.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Munkeymon posted:

Anyone else think it's be nice to have a "Only break on uncaught exceptions in files currently open in the editor" option? Getting sick of closing tabs I don't want open just because something I didn't break and can't fix is failing off in the corner over there.

I would love either something like that, or "Break on uncaught exceptions if THIS METHOD RIGHT HERE is in the call stack".

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

Ithaqua posted:

Yeah, web services are double legacy. They were eclipsed by WCF services which were eclipsed by WebAPI.

That depends on who you ask. The ongoing debate at my job here has been WCF vs. WebAPI, with pretty good arguments on either side. Basically, WCF still has a place where you can use NetTcpBinding or whatever. Honestly, it's moot as far as I'm concerned because I want exposure completely divorced from the service business logic, anyway, so that my WebAPI/WCF is just wrapped around a DLL.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Finster Dexter posted:

That depends on who you ask. The ongoing debate at my job here has been WCF vs. WebAPI, with pretty good arguments on either side. Basically, WCF still has a place where you can use NetTcpBinding or whatever. Honestly, it's moot as far as I'm concerned because I want exposure completely divorced from the service business logic, anyway, so that my WebAPI/WCF is just wrapped around a DLL.

WCF as a web service is what I mean. If you want to use it for TCP or MSMQ binding, that's a different purpose.

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug
Ran into something weird at work and wanted to see if the forums collective wisdom can help:

Note: This is on Windows 7 x64 and VS2012 Update 5

I'm writing some unit tests for a WebApi controller (which is in an Mvc Project), and I discovered that the base class is making a call directly to HttpContext.Current. Ok, not problem, we are using Autofac and I have some experience with Ninject binding HttpContextBase to return HttpContext.Current so I take a peek to see if there is a "preferred" way to do this. Turns out there is! Autofac.Mvc5. I open up my package manager and paste the install command and get this output:

code:
PM> Install-Package Autofac.Mvc5
Install-Package : Unable to find package 'Autofac.Mvc5'.
At line:1 char:16
+ Install-Package <<<<  Autofac.Mvc5
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    +
Hmm, weird. At this point I notice I don't get tab-based auto-completion on package names either. So I go and right-click my solution and hit "Manage NuGet Packages for Solution..." and here is where poo poo gets REAL weird:

  • I go to "Online" and search for "Autofac.Mvc5". It appears in the results but says it's installed...
  • I got to "Installed packages" and it does NOT appear in the list of packages.
  • I did a search of the entire solution and there seems to be nothing with "Autofac.Mvc5" in it

I tried going to NuGet settings and clearing the cache but that didn't seem to buy me anything. This is pretty strange. Anyone see anything like this before? We are making the switch to VS2015 next week but I'm not fond of just waiting for that if I can fix this in the mean time. Anyone see something like this before? As I mentioned before the tests are for a WebApi controller that is using a base class that seems to be used for all controllers. Autofac.WebApi2 is installed to the project and I can use it but it doesn't seem to have the Autofac module (AutofacWebTypesModule) that I need to register.

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
I've never seen that before.

What does your packages.config look like? Is Autofac.Mvc5 in there? (guess not if a solution wide search doesn't find it)

Is it in the packages directory for the solution?

Is your Nuget exe and tooling up to date for VS2012?

It sounds like something is cached or corrupted somewhere, though.

mortarr
Apr 28, 2005

frozen meat at high speed
What do you guys do when you're building software to sell and you use 3rd party libraries via nuget eg. Autofac, elmah, EF etc. Is there a recommended practice for including licenses for these?

With the javascript libraries, the license is usually included as part of the .js file, so I think I'm OK there, but for all these other packages I've just created a "licenses" folder, which contains files named like the package name - "autofac.lic", "autofac.mvc.lic" and copied the license from their github or wherever I can find it into the corresponding .lic file. This folder will be included as part of the distributed software.

I normally develop inhouse apps that are not for distribution, so this has never come up before and I'm not sure what approach to take.

EssOEss
Oct 23, 2006
128-bit approved
Edit: nevermind

EssOEss fucked around with this message at 15:36 on Jan 9, 2016

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug

Finster Dexter posted:

I've never seen that before.

What does your packages.config look like? Is Autofac.Mvc5 in there? (guess not if a solution wide search doesn't find it)

Is it in the packages directory for the solution?

Is your Nuget exe and tooling up to date for VS2012?

It sounds like something is cached or corrupted somewhere, though.

The packages.config for the project I want to add it to does not contain a reference to it.

When I checked the Packages folder for the solution, however it DID contain Autofac.Mvc5.3.3.4 and when I saw this I checked the repositories.config and went through each of the referenced packages.config but none of them contained a reference to Autofac.Mvc so I deleted the folder there and was able to install the package to the project.

Not sure how it ended up there because I double checked and it's not coming from source control. Thanks for pointing out to check the packages folder!

epswing
Nov 4, 2003

Soiled Meat
I keep running into the same ASP problem.

Generally my ASP solutions are structured like this:
  • FooAsp
  • FooCore
  • FooCore.Tests

FooCore is "The Application".

FooAsp is pretty thin, and depends on FooCore to get the real work done. If I wanted to, I could write other interfaces like FooConsole or FooWpf.

FooCore.Tests, as expected, depends on FooCore and runs my tests.

I want to take advantage of user management via the Identity framework, which does registration, login, password hashing, password resets, authorization via roles, authentication via cookies (mvc) and tokens (webapi), and more. I really, really don't want to write and maintain these things myself. However, the ApplicationUser class is sitting in a UserContext in FooAsp, and all my other entities are sitting in DataContext in FooCore.

Here's an example of the problem. Say I wanted to add a feature that sends users text messages based on events that occur in FooCore. I want to build a testable class in FooCore that interfaces with (for example) Twilio, with restrictions on how many messages per second it sends, logs who it has sent messages to, records failures, etc. FooCore doesn't know about FooAsp (ie doesn't know about ApplicationUser).

What I've done in the past is write my own User entity in FooCore that maps 1:1 with an ApplicationUser in FooAsp, but this is a pain to keep synchronized (and redundant to keep two user tables in literally the same database).

How can I deal with this properly?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

epalm posted:

I keep running into the same ASP problem.

Generally my ASP solutions are structured like this:
  • FooAsp
  • FooCore
  • FooCore.Tests

FooCore is "The Application".

FooAsp is pretty thin, and depends on FooCore to get the real work done. If I wanted to, I could write other interfaces like FooConsole or FooWpf.

FooCore.Tests, as expected, depends on FooCore and runs my tests.

I want to take advantage of user management via the Identity framework, which does registration, login, password hashing, password resets, authorization via roles, authentication via cookies (mvc) and tokens (webapi), and more. I really, really don't want to write and maintain these things myself. However, the ApplicationUser class is sitting in a UserContext in FooAsp, and all my other entities are sitting in DataContext in FooCore.

Here's an example of the problem. Say I wanted to add a feature that sends users text messages based on events that occur in FooCore. I want to build a testable class in FooCore that interfaces with (for example) Twilio, with restrictions on how many messages per second it sends, logs who it has sent messages to, records failures, etc. FooCore doesn't know about FooAsp (ie doesn't know about ApplicationUser).

What I've done in the past is write my own User entity in FooCore that maps 1:1 with an ApplicationUser in FooAsp, but this is a pain to keep synchronized (and redundant to keep two user tables in literally the same database).

How can I deal with this properly?

Create another project and reference it from both Asp and Core?

Adbot
ADBOT LOVES YOU

wwb
Aug 17, 2004

epalm posted:

I keep running into the same ASP problem.

Generally my ASP solutions are structured like this:
  • FooAsp
  • FooCore
  • FooCore.Tests

FooCore is "The Application".

FooAsp is pretty thin, and depends on FooCore to get the real work done. If I wanted to, I could write other interfaces like FooConsole or FooWpf.

FooCore.Tests, as expected, depends on FooCore and runs my tests.

I want to take advantage of user management via the Identity framework, which does registration, login, password hashing, password resets, authorization via roles, authentication via cookies (mvc) and tokens (webapi), and more. I really, really don't want to write and maintain these things myself. However, the ApplicationUser class is sitting in a UserContext in FooAsp, and all my other entities are sitting in DataContext in FooCore.

Here's an example of the problem. Say I wanted to add a feature that sends users text messages based on events that occur in FooCore. I want to build a testable class in FooCore that interfaces with (for example) Twilio, with restrictions on how many messages per second it sends, logs who it has sent messages to, records failures, etc. FooCore doesn't know about FooAsp (ie doesn't know about ApplicationUser).

What I've done in the past is write my own User entity in FooCore that maps 1:1 with an ApplicationUser in FooAsp, but this is a pain to keep synchronized (and redundant to keep two user tables in literally the same database).

How can I deal with this properly?

Personally I would typically render unto the framework what is the framework and keep my own copy of the user data I cared about. There might end up being minimal duplication of data as the framework might need email for mechanical purposes and I'd need email for marketing purposes but I'd rather control my data and be able to use it without needing to keep the same tables working with the framework's mechanics. The bridge I used to use was a ProviderUserKey setting under the old membership stuff, I'd suspect there is an equivalent in the new Identity stuff but I haven't been down that path recently.

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