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
Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING
What do I need to know to compile my first little program in visual studio community using c#? There are no errors and it runs fine in debug mode, but when I export it (to either build or release, on any CPU or x6) and try to run the .exe it just hangs forever, windows explorer on that screen lagging massively forever until it waits long enough for me to be able to close it, and otherwise nothing happens. So the program is crashing horribly somehow and I can't figure out how/why because it runs fine in debug mode through the IDE.. anything I'm missing? I've googled, checked the event viewer, re-exported multiple times, but can't figure it out.

The program doesn't even do anything on start, it just (presumably) loads references and then draws some buttons. No actual behaviour starts until I click a button, but I never get to that point.

Sulla Faex fucked around with this message at 15:21 on Dec 5, 2015

Adbot
ADBOT LOVES YOU

Kekekela
Oct 28, 2004

redleader posted:

Greybeard Erland Sommarskog goes into a hell of a lot of detail on this subject.

quote:

For other types of objects than the four listed above, SQL Server does not build query plans. Specifically, SQL Server does not create query plans for views and inline-table functions. Queries like:

SELECT abc, def FROM myview

I was under the impression the distinctions he is making regarding query plans haven't been true since early versions of Sql Server, and everything gets query plans generated now. (I know that's beside the point of why you linked it, its just something that I found curious)

redleader
Aug 18, 2005

Engage according to operational parameters

Kekekela posted:

I was under the impression the distinctions he is making regarding query plans haven't been true since early versions of Sql Server, and everything gets query plans generated now. (I know that's beside the point of why you linked it, its just something that I found curious)

Yeah, I thought the same thing. A close reading of that link reveals "If your application does not use stored procedures, but submits SQL statements directly, most of what I say this chapter is still applicable", which I interpret as meaning 'this applies equally to autogenerated SQL and suchlike'. It's been a while since I've run into a slow-in-app-fast-in-SSMS query though.

EssOEss
Oct 23, 2006
128-bit approved

Sulla-Marius 88 posted:

What do I need to know to compile my first little program in visual studio community using c#?

Sounds funky. Should be nothing special required. Post your code maybe?

Does it also hang if you do "Run without Debugging"?

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING

EssOEss posted:

Sounds funky. Should be nothing special required. Post your code maybe?

Does it also hang if you do "Run without Debugging"?

Ah poo poo, good call. Yeah it hangs if i Run without debugging. I wonder what the difference is that the IDE can't catch it in Debug mode. I'll do some Googling now and if that fails just rip out my code until I get it to a working stage again. Thanks!

Polio Vax Scene
Apr 5, 2009



What would be the best way to create a web URL that has a base64 encoded string in it? I had a problem with forward slashes earlier, are there other characters I might need to worry about?

epswing
Nov 4, 2003

Soiled Meat
Why can't I put Automapper mapping configurations (via Mapper.CreateMap statements) in the static constructor of the related object?

To me, this seems like the most logical place to put the mapping statements:

C# code:
public class Person
{
	public int Id { get; set; }
	public string Name { get; set; }
	public int Age { get; set; }
}

public class PersonDto1
{
	static PersonDto1()
	{
		Mapper.CreateMap<Person, PersonDto1>();
	}

	public int Id { get; set; }
	public string Name { get; set; }
}

public class PersonDto2
{
	static PersonDto2()
	{
		Mapper.CreateMap<Person, PersonDto2>();
	}

	public int Id { get; set; }
	public int Age { get; set; }
}
But it appears that running Mapper.Map<Person, PersonDto1>(entity) throws an Exception before the PersonDto1 static constructor runs. I was under the (false) impression that, as soon as you try to do anything with PersonDto1, the static constructor will run. Automapper must be instantiating a PersonDto1 at some point, why isn't the static constructor running?

Edit: Oh. Automapper must simply be checking to see if a mapping exists before trying to map it. Duh.

epswing fucked around with this message at 15:59 on Dec 7, 2015

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING

Sulla-Marius 88 posted:

Ah poo poo, good call. Yeah it hangs if i Run without debugging. I wonder what the difference is that the IDE can't catch it in Debug mode. I'll do some Googling now and if that fails just rip out my code until I get it to a working stage again. Thanks!

I started a new Windows Form project and hit 'run without debugging' and it crashed as well. So the problem is my dev environment, not the solution. Ugh

chippy
Aug 16, 2006

OK I DON'T GET IT

epalm posted:

Why can't I put Automapper mapping configurations (via Mapper.CreateMap statements) in the static constructor of the related object?

To me, this seems like the most logical place to put the mapping statements:

C# code:
public class Person
{
	public int Id { get; set; }
	public string Name { get; set; }
	public int Age { get; set; }
}

public class PersonDto1
{
	static PersonDto1()
	{
		Mapper.CreateMap<Person, PersonDto1>();
	}

	public int Id { get; set; }
	public string Name { get; set; }
}

public class PersonDto2
{
	static PersonDto2()
	{
		Mapper.CreateMap<Person, PersonDto2>();
	}

	public int Id { get; set; }
	public int Age { get; set; }
}
But it appears that running Mapper.Map<Person, PersonDto1>(entity) throws an Exception before the PersonDto1 static constructor runs. I was under the (false) impression that, as soon as you try to do anything with PersonDto1, the static constructor will run. Automapper must be instantiating a PersonDto1 at some point, why isn't the static constructor running?

Edit: Oh. Automapper must simply be checking to see if a mapping exists before trying to map it. Duh.

e: Nevermind, I read it wrong.

Munkeymon
Aug 14, 2003

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



Manslaughter posted:

What would be the best way to create a web URL that has a base64 encoded string in it? I had a problem with forward slashes earlier, are there other characters I might need to worry about?

Just use Uri.EscapeDataString()

epswing
Nov 4, 2003

Soiled Meat
I'm having an InstallShield problem that I just can't crack. It's a long shot but maybe someone here has seen this before.

I have InstallShield 2013 LE set to install
  • "WinBatchAsp.Content Files" to C:\inetpub\wwwroot\WinBatchAsp
  • "WinBatchAsp.Primary Output" to C:\inetpub\wwwroot\WinBatchAsp\bin

as well as to create a site in IIS, with a Content Source Path of "[IISROOTFOLDER]WinBatchAsp"

When I run the installer, C:\inetpub\wwwroot\WinBatchAsp\bin looks like this:


but when I load the site in Chrome I get

quote:

Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

HOWEVER, from Visual Studio (as Administrator) if I right-click -> Publish using the File System publish method, C:\inetpub\wwwroot\WinBatchAsp\bin looks like this:


(note the extra folders) and after manually creating a site in IIS Manager, when I load the site in Chrome everything works as expected.

:confused:

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

epalm posted:

(note the extra folders) and after manually creating a site in IIS Manager, when I load the site in Chrome everything works as expected.

Ignoring the extra folders, are there any additional DLLs in the bin folder after publishing? If you delete the folders does it still work?

epswing
Nov 4, 2003

Soiled Meat

Bognar posted:

Ignoring the extra folders, are there any additional DLLs in the bin folder after publishing? If you delete the folders does it still work?

Each of those language-looking folders contain:
  • Microsoft.Data.Edm.resources.dll
  • Microsoft.Data.OData.resources.dll
  • System.Spatial.resources.dll

When I delete all the folders and restart IIS, the site still works, yes.

I haven't gone one by one to match them all up, but, after deleting the folders, in both cases there are 46 dlls in the bin folder.

epswing fucked around with this message at 19:46 on Dec 7, 2015

EssOEss
Oct 23, 2006
128-bit approved

Manslaughter posted:

What would be the best way to create a web URL that has a base64 encoded string in it? I had a problem with forward slashes earlier, are there other characters I might need to worry about?

RFC 4648 and RFC 6920 (I think) define/mention the commonly used base64url encoding, which is URL-safe. It's used everywhere in JavaScript land. Replace + with - and / with _.

kingcrimbud
Mar 1, 2007
Oh, Great. Now what?

epalm posted:

Automapper mapping configurations

Separate your models from how your models are mapped. https://en.wikipedia.org/wiki/Single_responsibility_principle

I also recommend looking into using Automapper non-statically. Testing is a bit easier. Configure mappings via Profiles then inject in IMappingEngine instances as needed to map.

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick

epalm posted:

I'm having an InstallShield problem that I just can't crack. It's a long shot but maybe someone here has seen this before.

I have InstallShield 2013 LE set to install
  • "WinBatchAsp.Content Files" to C:\inetpub\wwwroot\WinBatchAsp
  • "WinBatchAsp.Primary Output" to C:\inetpub\wwwroot\WinBatchAsp\bin

as well as to create a site in IIS, with a Content Source Path of "[IISROOTFOLDER]WinBatchAsp"

When I run the installer, C:\inetpub\wwwroot\WinBatchAsp\bin looks like this:


but when I load the site in Chrome I get


HOWEVER, from Visual Studio (as Administrator) if I right-click -> Publish using the File System publish method, C:\inetpub\wwwroot\WinBatchAsp\bin looks like this:


(note the extra folders) and after manually creating a site in IIS Manager, when I load the site in Chrome everything works as expected.

:confused:

That manifest not matching error usually means that your project references version x of a library but when the library was actually loaded at runtime, it finds version y instead, and there's no explicit remapping of version x to y in the app/web.config to allow version y to be loaded.
I'm guessing that install shield is including version 2 of the dll while your project references version 4, or maybe that it's not including the dll at all and using what's in the gac, and the gac doesn't have the version you're expecting.
I suppose in either case, you could go to the install shield settings and explicitly select that dll with the correct version, and force it to use that one instead of either trying to guess the right one on its own or leaving it out and expecting the right one to already be in the gac.

mortarr
Apr 28, 2005

frozen meat at high speed

epalm posted:

Why can't I put Automapper mapping configurations (via Mapper.CreateMap statements) in the static constructor of the related object?

To me, this seems like the most logical place to put the mapping statements:

C# code:
public class Person
{
	public int Id { get; set; }
	public string Name { get; set; }
	public int Age { get; set; }
}

public class PersonDto1
{
	static PersonDto1()
	{
		Mapper.CreateMap<Person, PersonDto1>();
	}

	public int Id { get; set; }
	public string Name { get; set; }
}

public class PersonDto2
{
	static PersonDto2()
	{
		Mapper.CreateMap<Person, PersonDto2>();
	}

	public int Id { get; set; }
	public int Age { get; set; }
}
But it appears that running Mapper.Map<Person, PersonDto1>(entity) throws an Exception before the PersonDto1 static constructor runs. I was under the (false) impression that, as soon as you try to do anything with PersonDto1, the static constructor will run. Automapper must be instantiating a PersonDto1 at some point, why isn't the static constructor running?

Edit: Oh. Automapper must simply be checking to see if a mapping exists before trying to map it. Duh.

Hey, not sure if you give a poo poo, but I found this automapper style which keeps the `Mapper.CreateMap<Person, PersonDto2>();` part out of your DTO's for classes with one-to-one mappings... `AutomapperConfigTask.Execute()` gets called on startup, and handles the basic one-one CreateMap statements, so you only need to write the custom ones by implementing IHaveCustomMappings.

I used to have heaps of classes implementing automappers `Profile` that got discovered on startup, but I think having the mapping inside the DTO's is a better way to go than lumping them all together, and this style seems to complement what you're already thinking of with the static methods.

code:
  public interface IMapFrom<T>
  {
  }

  public interface IHaveCustomMappings
  {
    void CreateMappings(IConfiguration configuration);
  }

  public class AutomapperConfigTask 
  {
    public void Execute()
    {
      var types = Assembly.GetExecutingAssembly().GetExportedTypes();

      LoadStandardMappings(types);
      LoadCustomMappings(types);

      Mapper.AssertConfigurationIsValid();
    }

    private static void LoadCustomMappings(IEnumerable<Type> types)
    {
      var maps = (from t in types
                  from i in t.GetInterfaces()
                  where typeof(IHaveCustomMappings).IsAssignableFrom(t) &&
                      !t.IsAbstract &&
                      !t.IsInterface
                  select (IHaveCustomMappings)Activator.CreateInstance(t)).ToArray();

      foreach (var map in maps)
      {
        map.CreateMappings(Mapper.Configuration);
      }
    }

    private static void LoadStandardMappings(IEnumerable<Type> types)
    {
      var maps = (from t in types
                  from i in t.GetInterfaces()
                  where i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IMapFrom<>) &&
                      !t.IsAbstract &&
                      !t.IsInterface
                  select new
                  {
                    Source = i.GetGenericArguments()[0],
                    Destination = t
                  }).ToArray();

      foreach (var map in maps)
      {
        Mapper.CreateMap(map.Source, map.Destination);
      }
    }
  }

  public class Person
  {
    public string Id { get; set; }
    public string Name { get; set; }
  }

  public class PersonDto : IMapFrom<Person>
  {
    public string Id { get; set; }
    public string Name { get; set; }
  }

  public class PersonDto2 : IHaveCustomMappings
  {
    public string Id { get; set; }
    public string Name { get; set; }
    public List<string> PhoneNumbers { get; set; }

    public void CreateMappings(IConfiguration configuration) 
    {
	configuration.CreateMap<Person, PersonDto2>()
          .ForMember(m => m.Id, opt => opt.MapFrom(src => src.Id))
          .ForMember(m => m.Name, opt => opt.MapFrom(src => src.Name))      
          .ForMember(m => m.PhoneNumbers, opt => opt.UseValue(src => new[] { "111", "222" }));      
    }
  }  

epswing
Nov 4, 2003

Soiled Meat
I'm stuck in deployment hell right now. I simply cannot get this ASP project installed and working in IIS.

After installing, in the browser I get

quote:

Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.

I've set the System.Net.Http.Formatting reference Copy Local to true/false, no difference.

Following some SO advice, if I remove
pre:
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting"
                          publicKeyToken="31bf3856ad364e35"
                          culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
from web.config, I get

quote:

Could not load file or assembly 'System.Spatial' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.

I don't know how to diagnose/debug these errors, so I'm just endlessly googling, flipping a setting here and there, uninstalling, reinstalling, and that's been my existence for days.

Any advice? I'm using a pretty standard ASP.NET WebAPI setup, as far as I can tell, on Visual Studio 2013, .NET 4.5, MVC 5, WebAPI 2, IIS 7.5, Windows 7.

epswing fucked around with this message at 16:54 on Dec 8, 2015

amotea
Mar 23, 2008
Grimey Drawer
Whenever I get this error it's often caused by the referenced assembly having the wrong version vs. what's defined in the binding redirects. Sometimes different projects in the solution are using a different version.

What version is the System.Net.Http.Formatting assembly you are referencing in your projects? (can also check this by looking at the file version of the assembly file that's actually copied to the bin directory)

epswing
Nov 4, 2003

Soiled Meat

amotea posted:

What version is the System.Net.Http.Formatting assembly you are referencing in your projects? (can also check this by looking at the file version of the assembly file that's actually copied to the bin directory)

I'm assuming you mean this?



It's version 5.2.3.0

This is the properties window of the file that gets copied to the bin direction. The version doesn't seem to match, but I'm not sure what "version" it's referring to.

epswing fucked around with this message at 18:19 on Dec 8, 2015

brap
Aug 23, 2004

Grimey Drawer

kingcrimbud posted:

Separate your models from how your models are mapped. https://en.wikipedia.org/wiki/Single_responsibility_principle

I also recommend looking into using Automapper non-statically. Testing is a bit easier. Configure mappings via Profiles then inject in IMappingEngine instances as needed to map.

What does it enable you to test? That your program still works even if you substitute in some other Automapper implementation?

I think people should buckle down and write the translators. Pretty soon you will find yourself writing enough logic in a translator that if you start doing all that stuff through the Automapper API you'll be miserable in trying to debug and maintain it.

Polio Vax Scene
Apr 5, 2009



epalm posted:

I'm assuming you mean this?



It's version 5.2.3.0

This is the properties window of the file that gets copied to the bin direction. The version doesn't seem to match, but I'm not sure what "version" it's referring to.



Are there any other projects in your solution that use it? What happens if you remove and readd the reference then rebuild?

epswing
Nov 4, 2003

Soiled Meat

Manslaughter posted:

Are there any other projects in your solution that use it? What happens if you remove and readd the reference then rebuild?

Yes, it's referenced in the Asp project, and the Asp.Tests project.

I removed both references, re-added them, rebuild, and now I get



:holy:

epswing fucked around with this message at 19:12 on Dec 8, 2015

Essential
Aug 14, 2003
Has anyone created Task Scheduler jobs from code? It looks like it's possible from a command line. Another option seems to be to export as a file and then copy it into the correct folder.

I need something that works from XP on up. Is there any libraries recommended?

edit: found this, https://taskscheduler.codeplex.com/ That looks pretty good and is available via Nuget.

Essential fucked around with this message at 19:23 on Dec 8, 2015

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick

epalm posted:

I'm stuck in deployment hell right now. I simply cannot get this ASP project installed and working in IIS.

After installing, in the browser I get


I've set the System.Net.Http.Formatting reference Copy Local to true/false, no difference.

Following some SO advice, if I remove
pre:
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting"
                          publicKeyToken="31bf3856ad364e35"
                          culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
from web.config, I get


I don't know how to diagnose/debug these errors, so I'm just endlessly googling, flipping a setting here and there, uninstalling, reinstalling, and that's been my existence for days.

Any advice? I'm using a pretty standard ASP.NET WebAPI setup, as far as I can tell, on Visual Studio 2013, .NET 4.5, MVC 5, WebAPI 2, IIS 7.5, Windows 7.

Have you looked at the fusion log?
http://www.hanselman.com/blog/BackToBasicsUsingFusionLogViewerToDebugObscureLoaderErrors.aspx
https://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.110).aspx

epswing
Nov 4, 2003

Soiled Meat

No I haven't, thanks for the link. The research continues.

What's killing me is the app builds and runs fine when debugging from VS via IISExpress, and runs fine when I right-click Publish to File System and create an IIS site manually. But when I install via InstallShield I get "Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference".

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Try removing the reference to Web API and adding the Web API package from NuGet.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Essential posted:

Has anyone created Task Scheduler jobs from code? It looks like it's possible from a command line. Another option seems to be to export as a file and then copy it into the correct folder.

I need something that works from XP on up. Is there any libraries recommended?

edit: found this, https://taskscheduler.codeplex.com/ That looks pretty good and is available via Nuget.

It sucks. There's a com api but it's incomprehensible. Windows server 2012 has powershell cmdlets.

Personally, I just export /import them when I need to have scheduled tasks exist as part of environment configuration.

epswing
Nov 4, 2003

Soiled Meat

Bognar posted:

Try removing the reference to Web API and adding the Web API package from NuGet.

I understand what you mean, but I don't know exactly how to do that. Can you be more explicit?

Wen you say "remove the reference to Web API", what exactly is "the reference to Web API"? There are a bunch of items in the project References list that start with "System.Net.Http". What about the ones starting with "System.Web.Http"? I have some vague impression that "http" means WebAPI and "web" means MVC. Which do I remove?

What exactly do I add from nuget? A search on nuget.org for "webapi" returns 954 packages. Which do I need?

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

epalm posted:

I understand what you mean, but I don't know exactly how to do that. Can you be more explicit?

Wen you say "remove the reference to Web API", what exactly is "the reference to Web API"? There are a bunch of items in the project References list that start with "System.Net.Http". What about the ones starting with "System.Web.Http"? I have some vague impression that "http" means WebAPI and "web" means MVC. Which do I remove?

What exactly do I add from nuget? A search on nuget.org for "webapi" returns 954 packages. Which do I need?

Open the references folder on your web project, delete anything that starts with System.Web.Http or System.Net.Http. Then run Install-Package Microsoft.AspNet.WebApi to install this NuGet package.

It's a shot in the dark, but that will at least specify all your references explicitly and maybe convince InstallShield that those are the assemblies that should be copied.

epswing
Nov 4, 2003

Soiled Meat

Bognar posted:

Open the references folder on your web project, delete anything that starts with System.Web.Http or System.Net.Http. Then run Install-Package Microsoft.AspNet.WebApi to install this NuGet package.

It's a shot in the dark, but that will at least specify all your references explicitly and maybe convince InstallShield that those are the assemblies that should be copied.

I did exactly as you said, and got

quote:

PM> Install-Package Microsoft.AspNet.WebApi
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.WebHost (≥ 5.2.3 && < 5.3.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Core (≥ 5.2.3 && < 5.3.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Client (≥ 5.2.3)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 6.0.4)'.
'Microsoft.AspNet.WebApi 5.2.3' already installed.

epswing fucked around with this message at 20:05 on Dec 8, 2015

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Huh, looks like it was already installed through NuGet. You would have to uninstall then reinstall to get that portion to work, but now I doubt that will help if the NuGet package was already referenced.

epswing
Nov 4, 2003

Soiled Meat

Bognar posted:

Huh, looks like it was already installed through NuGet. You would have to uninstall then reinstall to get that portion to work, but now I doubt that will help if the NuGet package was already referenced.

I ran around the "Manage Nuget Packages for Solution" dialog killing anything with "API" in the name. Then ran Install-Package Microsoft.AspNet.WebApi and Install-Package Microsoft.AspNet.WebApi.Owin. Then compiled the installer, and installed it.

As you suspected, same error ("[FileLoadException: Could not load file or assembly 'System.Net.Http.Formatting' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]")

Though the ASP project still works in IISExpress, and still works if I Publish to File System and manually create the site in IIS Manager.

Edit: What a loving nightmare. I would happily throw cold hard cash at someone to fix this so I can move on with my life, but I'm stuck. If I hire a consultant (one of you) or even a developer support person from Microsoft, the answer will almost certainly be "shrug..InstallShield must be doing something weird", and if I hire a developer support person from InstallShield, the answer will almost certainly be "shrug..Visual Studio must be doing something weird".

If someone here has been following my last few posts, knows what I'm after, and wants to make $150 USD /hr, PM me.

epswing fucked around with this message at 21:14 on Dec 8, 2015

wwb
Aug 17, 2004

Essential posted:

Has anyone created Task Scheduler jobs from code? It looks like it's possible from a command line. Another option seems to be to export as a file and then copy it into the correct folder.

I need something that works from XP on up. Is there any libraries recommended?

edit: found this, https://taskscheduler.codeplex.com/ That looks pretty good and is available via Nuget.

FWIW we have moved most things that we triggered via scheduled tasks into the app as Quartz.NET jobs. Self contained is cool.

Essential
Aug 14, 2003

Ithaqua posted:

It sucks. There's a com api but it's incomprehensible. Windows server 2012 has powershell cmdlets.

Personally, I just export /import them when I need to have scheduled tasks exist as part of environment configuration.

Bummer to hear that library sucks. I'll look into the export/import stuff.

In case I'm heading in the wrong direction and there's a better solution, all I'm attempting to do is make sure my app is up and running. It uploads data every 15 minutes and sometimes it gets turned off for various reasons. A lot of the computers that run it never get rebooted, so run at startup never fires. I'd like a task that run's once an hour or so and if the app's not running to start it up. It really only needs to run M-F from 8am-6pm, but I don't know that I need to get that complex with the task scheduler.

It can't be a Windows Service for various reasons. It's a system tray app and has to stay that way. And ideally I can set it all up automatically without anyone having to manually do anything.

Also Ithaqua, I sent you a PM. If it's not something you can help with then please feel free to ignore.

wwb posted:

FWIW we have moved most things that we triggered via scheduled tasks into the app as Quartz.NET jobs. Self contained is cool.

Cool thanks, I'll check that out as well! Now that I've explained my use case, would Quartz.net work?

wwb
Aug 17, 2004

Thanks for clarifying the use case. Quartz.net probably isn't suitable here -- it is an internal scheduler which presumes your app is running not something that can get your app running like you need.

kingcrimbud
Mar 1, 2007
Oh, Great. Now what?

fleshweasel posted:

What does it enable you to test? That your program still works even if you substitute in some other Automapper implementation?

I think people should buckle down and write the translators. Pretty soon you will find yourself writing enough logic in a translator that if you start doing all that stuff through the Automapper API you'll be miserable in trying to debug and maintain it.

Injecting interfaces allows for easier testing, especially when using Moq. Mock<>.Verify is a great way to ensure things are called or not called. Using static classes just makes things more difficult to test.

And I agree with your second point in theory, I just haven't seen a case where the situation called for mapping between tiers/systems and Automapper was unable to do it cleanly and consistently.

Mr. Crow
May 22, 2008

Snap City mayor for life
I'm getting a really bizarre log4net issue, I'm wondering if anyone has any ideas. Basically, when the (WPF) application loads up, it log4net loads its configuration context from the application config file correctly as expected; then at some point its configuration is switched to an entirely different applications configuration (Box Sync, in this case). Somehow Box Sync starts hijacking the log4net logs and my applications logging is getting dumped into a Box Sync log.

The hell?

Mr Shiny Pants
Nov 12, 2012

Mr. Crow posted:

I'm getting a really bizarre log4net issue, I'm wondering if anyone has any ideas. Basically, when the (WPF) application loads up, it log4net loads its configuration context from the application config file correctly as expected; then at some point its configuration is switched to an entirely different applications configuration (Box Sync, in this case). Somehow Box Sync starts hijacking the log4net logs and my applications logging is getting dumped into a Box Sync log.

The hell?

Some default configuration place log4net is looking and finding the Box Sync one and loading that?

Dunno, sounds plausible.

Adbot
ADBOT LOVES YOU

xgalaxy
Jan 27, 2004
i write code
I'm confused about how NuGet works and maybe someone can help me.
There appears to be a discrepancy in how NuGet functions between Xamarin Studio and Visual Studio.

I'm trying to add the Microsoft.CodeAnalysis nuget packages. In Xamarin Studio the only packages it adds besides the CodeAnalysis packages are System.Collections.Immutable and System.Reflection.Metadata. But in Visual Studio it is adding a ton of System.* packages that should already be installed by default (or at least I would expect them to be) such as System.Collections, System.IO, System.Linq, etc, etc. All of them tagged with 4.0.0 at the end.

Can someone explain why it is doing this?

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