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
zerofunk
Apr 24, 2004

epalm posted:

How can I tell which resource is causing the permission problem?


I always default to running Process Monitor to look at what the process is trying to access when diagnosing things like this. Might be a better way that I'm not aware of, but that should tell you.

https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx

Adbot
ADBOT LOVES YOU

crashdome
Jun 28, 2011
Quick refactoring question:
Small isolated project, WPF, and only desktop use. I have one view which has a Print button to printout a simple list report so an operator can take it to a machine instead of running back-forth to the desktop. It's a "Print Preview" view that pops up and I create the FlowDocument from the Print Preview viewmodel. Very lazily done, I admit. It was supposed to be the only thing sent to a printer when I created this 8 months ago.

They have now asked me to create another print out of another list on another page and also a smaller printout for a label machine from yet another page. SO I am stuck with the application having two "Print Preview" views which are practically identical code-wise and a third "Print Preview" view which will most likely be different and more complex. My mind is telling me to refactor everything to a single "Print Preview" view and ViewModel and inject my FlowDocuments from a service so I can reuse as much code as possible. More time-consuming but, might save me in the long run. My fingers are saying "screw it, copy and paste and make three views, three viewmodels and call it the day". Doubt they'll ask me to expand any more print outs but hey, we've all heard that before .Either way I choose, I'm paid the same.

I'm pretty sure I know what I'll do but, I want to pick some brains and ask: What would you REALLY do?

crashdome fucked around with this message at 21:54 on Feb 4, 2016

Inverness
Feb 4, 2009

Fully configurable personal assistant.

epalm posted:

Ah gotcha. So it's in my interest to find out why NetworkService is complaining, rather than cop out by running under a more (too) powerful account.

The stack trace just looks like this:


How can I tell which resource is causing the permission problem?
Try sticking Debugger.Launch() into your service OnStart() so you can debug it then.

I assume what is happening is you're getting this exception during the startup phase which kills it immediately.

The other possibility, which I don't know for sure, is your network service account might not have the permission required to execute the service file. Perhaps someone changed permissions there?

EssOEss
Oct 23, 2006
128-bit approved

Squall posted:

Has anyone tried to make a class library for ASP.NET Core/ASP.NET 5 and a Universal Windows application? I tried using a portable class library but usually its mere presence is enough to stop anything from building in Visual Studio.

I tried and failed and added this issue to the ever growing pile titled "Reasons to stay away from ASP.NET Core".

Gul Banana
Nov 28, 2003

I've done it before but it involved manually running "dnu wrap" and hand-editing the output. the trick was to make a normal csproj library rather than a portable one, which UWP can just reference, and then use the wrapping project.json thing to also reference it from the asp.net core project

raminasi
Jan 25, 2005

a last drink with no ice

crashdome posted:

Quick refactoring question:
Small isolated project, WPF, and only desktop use. I have one view which has a Print button to printout a simple list report so an operator can take it to a machine instead of running back-forth to the desktop. It's a "Print Preview" view that pops up and I create the FlowDocument from the Print Preview viewmodel. Very lazily done, I admit. It was supposed to be the only thing sent to a printer when I created this 8 months ago.

They have now asked me to create another print out of another list on another page and also a smaller printout for a label machine from yet another page. SO I am stuck with the application having two "Print Preview" views which are practically identical code-wise and a third "Print Preview" view which will most likely be different and more complex. My mind is telling me to refactor everything to a single "Print Preview" view and ViewModel and inject my FlowDocuments from a service so I can reuse as much code as possible. More time-consuming but, might save me in the long run. My fingers are saying "screw it, copy and paste and make three views, three viewmodels and call it the day". Doubt they'll ask me to expand any more print outs but hey, we've all heard that before .Either way I choose, I'm paid the same.

I'm pretty sure I know what I'll do but, I want to pick some brains and ask: What would you REALLY do?

I think this decision depends on the actual implementation time differences now and in the nebulous future.

In other words: what does your heart tell you

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Squall posted:

Has anyone tried to make a class library for ASP.NET Core/ASP.NET 5 and a Universal Windows application? I tried using a portable class library but usually its mere presence is enough to stop anything from building in Visual Studio.
What do you mean? I was able to make a portable class library that did just that. Had no problems building.

epswing
Nov 4, 2003

Soiled Meat

zerofunk posted:

I always default to running Process Monitor to look at what the process is trying to access when diagnosing things like this. Might be a better way that I'm not aware of, but that should tell you.

https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx

Right, Process Monitor. I need to spend some time understanding how to use it. If I capture data for a couple seconds, I have half a million records to comb though.. even if the needle I'm looking for is there, that's one hell of a haystack.

raminasi
Jan 25, 2005

a last drink with no ice

epalm posted:

Right, Process Monitor. I need to spend some time understanding how to use it. If I capture data for a couple seconds, I have half a million records to comb though.. even if the needle I'm looking for is there, that's one hell of a haystack.

The filters are pretty powerful and straightforward.

zerofunk
Apr 24, 2004
Yeah, sorry should have mentioned that you will absolutely want to use the filters. I tend to mostly just use the Process Name one myself. And make sure you click the Include button to actually add it before you click Ok.

Inverness
Feb 4, 2009

Fully configurable personal assistant.
It really annoys me that Json.NET does not preserve type information for object arrays or dictionaries with object values. Even if I specify TypeNameHandling.All it just pisses on any TimeSpan objects by making them strings.

xgalaxy
Jan 27, 2004
i write code

Inverness posted:

It really annoys me that Json.NET does not preserve type information for object arrays or dictionaries with object values. Even if I specify TypeNameHandling.All it just pisses on any TimeSpan objects by making them strings.

Can't you create a custom Converter for types you want handled in a special way? You would create a class that implements Converter (or whatever its called) and then annotate your field or property with the converter you want it to use when serializing.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

xgalaxy posted:

Can't you create a custom Converter for types you want handled in a special way? You would create a class that implements Converter (or whatever its called) and then annotate your field or property with the converter you want it to use when serializing.
I already made a converter to handle the problem, but it just annoys me that custom functionality is needed for that. It should be a pretty basic concept.

brap
Aug 23, 2004

Grimey Drawer
What is it supposed to do? Is it supposed to record the types of the value for each key when it serializes then remember that when it comes back? Is it supposed to serialize the value into some kind of wrapper object that contains the type information? How do you propose achieving this functionality?

Inverness
Feb 4, 2009

Fully configurable personal assistant.

fleshweasel posted:

What is it supposed to do? Is it supposed to record the types of the value for each key when it serializes then remember that when it comes back? Is it supposed to serialize the value into some kind of wrapper object that contains the type information? How do you propose achieving this functionality?
The same way it preserves the type when class members are of a base type but the actual object is of a derived type: include a "$type" property with the type name.

This is what I did with a custom converter for IDictionary<string, object>:
code:
{
	"duration": {
	  "$type": "System.TimeSpan, mscorlib",
	  "$value": "00:00:01"
	},
	"endTime": {
	  "$type": "System.TimeSpan, mscorlib",
	  "$value": "00:00:01.5500000"
	},
	"adouble": {
	  "$type": "System.Double, mscorlib",
	  "$value": 1.0
	}
}

Mr Shiny Pants
Nov 12, 2012

Inverness posted:

The same way it preserves the type when class members are of a base type but the actual object is of a derived type: include a "$type" property with the type name.

This is what I did with a custom converter for IDictionary<string, object>:
code:
{
	"duration": {
	  "$type": "System.TimeSpan, mscorlib",
	  "$value": "00:00:01"
	},
	"endTime": {
	  "$type": "System.TimeSpan, mscorlib",
	  "$value": "00:00:01.5500000"
	},
	"adouble": {
	  "$type": "System.Double, mscorlib",
	  "$value": 1.0
	}
}

Now it only works in .Net, JavaScript won't know how to deserialize this.

RICHUNCLEPENNYBAGS
Dec 21, 2010

Mr Shiny Pants posted:

Now it only works in .Net, JavaScript won't know how to deserialize this.

If you're using angular or something you can define a custom deserializer on the client side too. There's no native date format in JSON (which I find insanely stupid but whatever).

e: OK, I didn't look very closely at that so it would be more involved. But still, you could do it, if you wanted.

RICHUNCLEPENNYBAGS fucked around with this message at 16:59 on Feb 6, 2016

raminasi
Jan 25, 2005

a last drink with no ice

Mr Shiny Pants posted:

Now it only works in .Net, JavaScript won't know how to deserialize this.

Sure, but if you're willing to use TypeNameHandling.All, presumably you don't care about that fact.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Mr Shiny Pants posted:

Now it only works in .Net, JavaScript won't know how to deserialize this.
Considering I'm serializing data structures unique to .NET, in this case compiler-generated iterator classes, I don't mind.

For context, I'm experimenting with serializing iterators after reading an article about logic over time in games. Using async and stuff like that is great, but there is a problem where many games need to be able to serialize the state of the game after any frame. This doesn't work with async due to how continuations work with that, but iterators are much simpler in concept and execution. You can make a framework that allows you to use those iterators as coroutines with their own stacks and logical threads of execution.

I made a class that takes an IEnumerator and changes it into an IteratorState object which has DataContract annotations but is neutral to any one serializer. Now I'm testing that by using Json.NET to serialize it and that means I need to be able to preserve the exact types for variables and arguments stored in Dictionary<string, object>. The result:

JavaScript code:
{
  "$id": "1",
  "Threads": [
    {
      "$id": "2",
      "Stack": [
        {
          "DeclaringTypeName": "Coroutines.Framework.CoroutineExecutor, Coroutines",
          "MethodName": "Delay",
          "State": 1,
          "Current": null,
          "This": {
            "$ref": "1"
          },
          "Arguments": {
            "duration": {
              "$type": "System.TimeSpan, mscorlib",
              "$value": "00:00:01"
            }
          },
          "Variables": {
            "duration": {
              "$type": "System.TimeSpan, mscorlib",
              "$value": "00:00:01"
            },
            "endTime": {
              "$type": "System.TimeSpan, mscorlib",
              "$value": "00:00:01.5500000"
            }
          }
        },
        {
          "DeclaringTypeName": "Coroutines.Tests.CoroutineTestClass, Coroutines.Tests",
          "MethodName": "DelaySeconds",
          "State": 1,
          "Current": null,
          "This": {
            "$type": "Coroutines.Tests.CoroutineTestClass, Coroutines.Tests"
          },
          "Arguments": {
            "seconds": {
              "$type": "System.Double, mscorlib",
              "$value": 1.0
            }
          },
          "Variables": {
            "seconds": {
              "$type": "System.Double, mscorlib",
              "$value": 1.0
            }
          }
        }
      ],
      "Status": 0,
      "Exception": null
    }
  ],
  "Time": "00:00:01.1000000"
}

Mr Shiny Pants
Nov 12, 2012

Can you post the article? I am curious. :)

epswing
Nov 4, 2003

Soiled Meat
Is there a technical reason why there is no button in Visual Studio that builds my project and all dependencies into a single executable?

I know I can use a tool like ILMerge for this, but it seems like an obvious omission.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Mr Shiny Pants posted:

Can you post the article? I am curious. :)
Sure: http://www.gamasutra.com/blogs/JeanSimonet/20160128/264083/Logic_Over_Time.php

epalm posted:

Is there a technical reason why there is no button in Visual Studio that builds my project and all dependencies into a single executable?

I know I can use a tool like ILMerge for this, but it seems like an obvious omission.
Because it's not officially supported and altering other dependencies would invalidate any kind of file signing you want to do.

epswing
Nov 4, 2003

Soiled Meat

Inverness posted:

Because it's not officially supported and altering other dependencies would invalidate any kind of file signing you want to do.

I don't know too much about build processes under the hood. How would your dependencies be "altered"?

EssOEss
Oct 23, 2006
128-bit approved
Type names consist of assembly+typename. If you merge it all into one assembly, guess what happens - yes, all code that ever loaded any types must also change because the assembly part of the name is now different. This is why ILMerge does not work with WPF, for example - WPF hardcodes type names into XAML and that's too much for ILmerge. It's not a big deal with plain old code but Visual Studio needs to cover a lot more than just the needs of 90% of developers.

There are workarounds and they work reasonably OK but it's still a hack. Maybe in the future with the .NET Native approach (compile everything, right now) taking more mindshare, this might some day become a reality. But it's really not worth the cost these days to implement it in the official toolchain, given that most people literally do not care and that any solution would not even work for a nontrivial scope of projects.

Plus breaking code signing is just evil.

Incidentally, LibZ is the modern alternative to ILMerge. I believe ILMerge is not really maintained and was having trouble with recent (.NET 4.6) assemblies. It also works a completely different way - instead of loving around with the actual IL code, it just embeds the other assemblies and loads them on-demand. This means it also works for WPF, among other things.

EssOEss fucked around with this message at 20:28 on Feb 8, 2016

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Since we're on a semi-related subject, has anybody managed to make a nice, portable* packaging of F#/C# Interactive (fsi.exe / csi.exe)? I find it a priceless utility for diagnostics, quick maintenance, and banging out all sorts of random scripts, but getting it to run on a third party computer has been pretty frustrating.

* in the "can be run straight from the folder [as long as you have the .NET framework installed]" sense, not in the "can be compiled for greybeard Unix" sense

RICHUNCLEPENNYBAGS
Dec 21, 2010

NihilCredo posted:

Since we're on a semi-related subject, has anybody managed to make a nice, portable* packaging of F#/C# Interactive (fsi.exe / csi.exe)? I find it a priceless utility for diagnostics, quick maintenance, and banging out all sorts of random scripts, but getting it to run on a third party computer has been pretty frustrating.

* in the "can be run straight from the folder [as long as you have the .NET framework installed]" sense, not in the "can be compiled for greybeard Unix" sense

I guess there's an REPL and the ability to run scripts in VS2015 Update 1: https://msdn.microsoft.com/en-us/magazine/mt614271.aspx

e: Er, I guess you already knew that and this isn't what you're asking. Sorry.

Munkeymon
Aug 14, 2003

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



NihilCredo posted:

Since we're on a semi-related subject, has anybody managed to make a nice, portable* packaging of F#/C# Interactive (fsi.exe / csi.exe)? I find it a priceless utility for diagnostics, quick maintenance, and banging out all sorts of random scripts, but getting it to run on a third party computer has been pretty frustrating.

* in the "can be run straight from the folder [as long as you have the .NET framework installed]" sense, not in the "can be compiled for greybeard Unix" sense

I just use LinqPad for that sort of thing :shrug:

crashdome
Jun 28, 2011

GrumpyDoctor posted:

I think this decision depends on the actual implementation time differences now and in the nebulous future.

In other words: what does your heart tell you

I guess I failed at a light-hearted post. :confuoot:
I was just trying to gauge other's opinions about taking short-cuts and when. You can bet money I am copy/pasting the one class into three classes and tweaking them. Refactoring would add boat-loads more work and I don't see much being added in the future to this current project to justify it. I was just curious what others might do when faced with a similar, general circumstance.

xgalaxy
Jan 27, 2004
i write code
I thought the new .NET Core documents stated something about being able to bundle all your dependency assemblies together into a single executable.
Also, I wish LinqPad worked in OS X.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

xgalaxy posted:

I thought the new .NET Core documents stated something about being able to bundle all your dependency assemblies together into a single executable.
Also, I wish LinqPad worked in OS X.
I think you're talking about native compilation, which is a different beast.

xgalaxy
Jan 27, 2004
i write code

Inverness posted:

I think you're talking about native compilation, which is a different beast.

No I'm pretty sure I'm not. Part of the deal with .NET going multiplatform is they have to find an executable bootstrapping model that will work multiplatform. As opposed to the current situation with Mono where you have to type mono in front of everything in order for it to run the executable as a managed assembly. I could be wrong, but I thought I had read that part of the bootstrapping model they are thinking of using is one where all of the assemblies are somehow bundled together.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

xgalaxy posted:

No I'm pretty sure I'm not. Part of the deal with .NET going multiplatform is they have to find an executable bootstrapping model that will work multiplatform. As opposed to the current situation with Mono where you have to type mono in front of everything in order for it to run the executable as a managed assembly. I could be wrong, but I thought I had read that part of the bootstrapping model they are thinking of using is one where all of the assemblies are somehow bundled together.
You just do the same thing except with an ELF binary instead of a PE binary. Have main() call into the CLR with with whatever information is needed to launch the managed program.

I'm not sure where this idea of bundled assemblies is coming from.

sarehu
Apr 20, 2007

(call/cc call/cc)
I have a question. Is writing C# that doesn't obey Microsoft's C# Coding Conventions actually a thing that real people do?

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

sarehu posted:

I have a question. Is writing C# that doesn't obey Microsoft's C# Coding Conventions actually a thing that real people do?

I'm in the middle of refactoring a massive brownfield application that...just yes. Yes. yes.

Gul Banana
Nov 28, 2003

sarehu posted:

I have a question. Is writing C# that doesn't obey Microsoft's C# Coding Conventions actually a thing that real people do?

https://github.com/bchavez/RethinkDb.Driver#quick-examples :-(

sarehu
Apr 20, 2007

(call/cc call/cc)

Exactly the code that prompted the question. Also there's some if ( this.Socket != null ) and if( foo == bar ) in the implementation :eyepop:

mortarr
Apr 28, 2005

frozen meat at high speed
I feel a bit dumb asking this... when I'm working is a cshtml file in vs2015, when I hit enter after a closing tag, like </div>, </td> etc, all of the html enclosed by that pair of tags is being re-indented to the wrong level. I'm not sure if its a VS thing, resharper, or the two working against each other.

So I start with something like this (all css, asp.net mvc stuff etc omitted):
code:
<tr>
  <td><label>stuff</label><span>goes</span><div>here</div></td>
  <td>
    <ul>
      <li><div><span>thing one</span></li>
      <li><div><span>thing two</span></li>
      <li><div><span>thing three</span></li>
    </ul>
  </td>
</tr>
Then say I hit enter after the </tr> to start typing another <tr> block, and then it gets re-formatted to:
code:
<tr>
<td>
  <label>
    stuff
  </label>
  <span>
    goes
  </span>
  <div>
    here
  </div>
</td>
<td>
  <ul>
    <li>
      <div>
        <span>
          thing one
        </span>
      </div>
    </li>
      <div>
        <span>
          thing two
        </span>
      </div>
    </li>
      <div>
        <span>
          thing three
        </span>
      </div>
    </li>
  </ul>
</td>
</tr>
It's a goddamn pain, and I can't think of what to google for!

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick
Your <li> elements have a <div> but no </div> - that's probably what's causing it

Gul Banana
Nov 28, 2003

sarehu posted:

Exactly the code that prompted the question. Also there's some if ( this.Socket != null ) and if( foo == bar ) in the implementation :eyepop:

i think it's mechanically translated from java :/

Adbot
ADBOT LOVES YOU

Calidus
Oct 31, 2011

Stand back I'm going to try science!
Is it bad practice to store user information in session variables? I just realized how many times I look up basic user information in the database and I was thinking about keeping basic things like company id, company route and company discount in session variables so I don't need to query the database all the time.

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