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
Inverness
Feb 4, 2009

Fully configurable personal assistant.

beuges posted:

I'll take a look at Assembly.LoadFile but I'm not certain that will help in this case because it looks like it only loads that particular assembly, and not all the references as well, and some of the references will likely have the same names as others already loaded, but differ internally.
What I'm writing is a transaction processing engine, where each transaction's logic sits in a separate plugin assembly, or more likely, set of assemblies. The complication is that the engine must support multiple versions of the same transaction being made available to different clients. So, I have an assembly called QueryFoo which in turn references a bunch of other assemblies. I'm storing each version of each plugin package (i.e. the QueryFoo.dll + all referenced assemblies) in its own version-numbered folder, then loading the appropriate assembly into its own app domain, so that I can have different versions loaded at the same time.
What I may end up doing is moving all the app domains into a separate service, and figuring out a way to pass requests directly into a specific appdomain in that service to avoid the cost of creating the app domain and marshalling data into/out of it in the transaction processor itself.
There is an event on the AppDomain, I forget what it's called, but it is called when a reference to an assembly needs to be resolved and makes you handle that either with an already loaded assembly or by loading a new assembly.

Adbot
ADBOT LOVES YOU

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost
After installing Visual Studio 2015 Update 2 and updating the UWP tools to 1.3.1, I can't load any project using the 10586 SDK. On builds with insider I can use the newest preview SDK, or the original RTM version, but not 10586. I get this error every time:

code:
The project requires a platform SDK (UAP, Version=10.0.10586.0) that is not installed. Please visit the following link for more information: 
[url]http://go.microsoft.com/fwlink/?prd=12514&pver=15.0&sbp=PlatformSDKMissing&plcid=0x409&o1=UAP,%20Version=10.0.10586.0[/url]
Which, of course, does not go anywhere. This has happened on two computers so far with the 1.3.1 tooling updating, and I have no way to roll back. If I make a new UWP project it does show the 10586 SDK, but if you try to create it throws the same error as above. Any ideas?

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Drastic Actions posted:

After installing Visual Studio 2015 Update 2 and updating the UWP tools to 1.3.1, I can't load any project using the 10586 SDK. On builds with insider I can use the newest preview SDK, or the original RTM version, but not 10586. I get this error every time:

code:
The project requires a platform SDK (UAP, Version=10.0.10586.0) that is not installed. Please visit the following link for more information: 
[url]http://go.microsoft.com/fwlink/?prd=12514&pver=15.0&sbp=PlatformSDKMissing&plcid=0x409&o1=UAP,%20Version=10.0.10586.0[/url]
Which, of course, does not go anywhere. This has happened on two computers so far with the 1.3.1 tooling updating, and I have no way to roll back. If I make a new UWP project it does show the 10586 SDK, but if you try to create it throws the same error as above. Any ideas?
Go to the 10586 SDK entry in the programs & features list and click change/modify. Try a repair or click change to see what features are selected and if you need to add something.

Mister Duck
Oct 10, 2006
Fuck the goose

beuges posted:

I'll take a look at Assembly.LoadFile but I'm not certain that will help in this case because it looks like it only loads that particular assembly, and not all the references as well, and some of the references will likely have the same names as others already loaded, but differ internally.
What I'm writing is a transaction processing engine, where each transaction's logic sits in a separate plugin assembly, or more likely, set of assemblies. The complication is that the engine must support multiple versions of the same transaction being made available to different clients. So, I have an assembly called QueryFoo which in turn references a bunch of other assemblies. I'm storing each version of each plugin package (i.e. the QueryFoo.dll + all referenced assemblies) in its own version-numbered folder, then loading the appropriate assembly into its own app domain, so that I can have different versions loaded at the same time.
What I may end up doing is moving all the app domains into a separate service, and figuring out a way to pass requests directly into a specific appdomain in that service to avoid the cost of creating the app domain and marshalling data into/out of it in the transaction processor itself.

Yeah loading with colliding dependencies into a single domain is one of the rabbit holes of using LoadFile. It's easy enough to figure out the referenced assemblies, but loading them all in without making something break somewhere is probably going to be a bigger issue.

You seem to really need the isolation of AppDomains, unfortunately. This is actually how it's done with the VSTO add-ins for Office to SxS load two versions of .NET in a single process (3.5, 4.X), although they don't really have any sort of intensive cross-domain communication going on.

epswing
Nov 4, 2003

Soiled Meat

Mister Duck posted:

Are any of these DatePickers inside a virtualizing control?

I'm looking into what exactly a virtualizing control is, but the DatePicker I think is causing the exception is located as such in XAML:

Page -> DockPanel -> ToolBar -> DatePicker

oliveoil
Apr 22, 2016
New to C# and .Net in general. What unit-testing framework and runner do people like best nowadays? And if they aren't included in the framework, what mocking and assertion frameworks are going to save me the most work?

Chamook
Nov 17, 2006

wheeeeeeeeeeeeee
We use AutoFixture with xUnit and AutoMoq to do spooky magic and generate data for our tests automatically, it seems pretty good to me but I haven't really used anything else to compare.

EssOEss
Oct 23, 2006
128-bit approved
xUnit is great because it is multi-framework and has the same API everywhere. It is also the only automated test framework that is actively maintained, as far as I know.

Speaking of testing. Last I checked, there was no mocking library that was UWP-capable - has this changed in recent times? I can see something called SimpleStubs - anyone have experience with this?

iron buns
Jan 12, 2016

We transitioned from NUnit to xUnit a while back. It's good. The test isolation alone was worth it.

We're using ReSharper Ultimate to run the tests locally. It comes with built-in code coverage support (used to be sold separately as dotCover) that integrates very nicely with Visual Studio.

On the build servers we're using SonarQube to run the tests along with other code quality enforcement things. Nobody really looks at the reports, but it integrates nicely with our other systems, so you'll see if the tests are failing while reviewing a pull request.

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer
xUnit and Shouldly, sometimes Moq or Autofixture. The NCrunch test runner is pretty amazing but it's quite pricey, I usually use it in conjunction with the ReSharper one. Most build servers will make it easy to use the xUnit standalone runner.

epswing
Nov 4, 2003

Soiled Meat

Pixelboy posted:

You could use Windbg to figure this out, if you spend the time to learn WIndbg.

Do you at least have the Microsoft symbols getting loaded?

I'll look into Windbg. I feel like I should know this but...how do I know if the Microsoft symbols are loaded, and how exactly does that affect debugging?

epswing fucked around with this message at 15:54 on Apr 22, 2016

epswing
Nov 4, 2003

Soiled Meat

Bognar posted:

Elsewhere on the internet, someone said they updated to .NET 4.5 and got a better stack-trace when they encountered this bug. If you can trigger the bug, I'd suggest going that route (if you're not already on 4.5).

I suspect the real error is being hidden by the dispatcher executing a delegate. That delegate is probably some code attached in an event handler attached to a DatePicker somewhere. I'd look for any events on DatePickers that happen to modify anything in the view hierarchy.

We're using .NET 4.5 now.

The DatePickers in question are not hooked up the any events, and are not in a DataTemplate (ie not repeated on the screen). It's just a pair of DatePickers at the top of a Page to specify a From and To date range to run a report.

This is only occurring on a single production machine (dozens of other installations are working fine). The OS is Windows Server 2012 R2. I cannot reproduce this on my dev machine. I've googled around and the results I've found are also never able to repro the issue.

I'm kinda stuck because it's some Exception I can't catch happening deep in WPF code. The only reason I know what's happening is I have this sitting in App.xaml.cs as a last-ditch "something blew up, here's the exception you didn't catch":

C# code:
AppDomain.CurrentDomain.UnhandledException += (s, args) =>
{
    var ex = (Exception)args.ExceptionObject;
    log.Error("UnhandledException: {0}\n{1}", ex.Message, ex.StackTrace);
};

raminasi
Jan 25, 2005

a last drink with no ice
Apparently XAML doesn't consider constructors with only default parameters "parameterless". That's annoying.

bobua
Mar 23, 2003
I'd trade it all for just a little more.

I want to add an Outlook contact notes style field in an app with an SQL backend. I'd be fine with simple text or rich text based data, but the awesome outlook style 'paste anything(pictures, files, etc) in here would be awesome if it isn't a massive undertaking.

Anyone know of a good resource on something like that? I'd like to get the addition to the database write the first time and not just cobble some crap together.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

GrumpyDoctor posted:

Apparently XAML doesn't consider constructors with only default parameters "parameterless". That's annoying.

And the error message you get from doing his is so loving useless. It does not tell you what field or what file the error is in, just that it won't work.

At least with UWP, don't know about WPF

TheReverend
Jun 21, 2005

I can't believe I'm stuck with an inheritance problem but here we are...


I want to keep track of the number of instances in a class with a static int. It would increment on the constructor and decrement on the destructor.

I also want all derived classes to have this ability as well but their own tabulations.

So class Square, Pentagon,Triangle, etc would have their own counts when inherited from base class "Polygon".

Right now it's a Polygon count for all instances.

Anyway to change that? Do I just have to setup a private static int for each class manually and then add in the increment and decrement code?

Mister Duck
Oct 10, 2006
Fuck the goose

TheReverend posted:

I can't believe I'm stuck with an inheritance problem but here we are...


I want to keep track of the number of instances in a class with a static int. It would increment on the constructor and decrement on the destructor.

I also want all derived classes to have this ability as well but their own tabulations.

So class Square, Pentagon,Triangle, etc would have their own counts when inherited from base class "Polygon".

Right now it's a Polygon count for all instances.

Anyway to change that? Do I just have to setup a private static int for each class manually and then add in the increment and decrement code?

What are you using this for? If you are depending on the count for a count of accessible objects, then decrementing in a finalizer could leave you seriously messed up. There is no guarantee when that is going to occur so you could still be counting objects that are unreachable by any code.

EssOEss
Oct 23, 2006
128-bit approved

TheReverend posted:

I want to keep track of the number of instances in a class with a static int. It would increment on the constructor and decrement on the destructor.

There are no destructors in C#/VB.Net, so your entire premise is flawed. What the hell are you up to?

Mister Duck
Oct 10, 2006
Fuck the goose

epalm posted:

We're using .NET 4.5 now.

The DatePickers in question are not hooked up the any events, and are not in a DataTemplate (ie not repeated on the screen). It's just a pair of DatePickers at the top of a Page to specify a From and To date range to run a report.

This is only occurring on a single production machine (dozens of other installations are working fine). The OS is Windows Server 2012 R2. I cannot reproduce this on my dev machine. I've googled around and the results I've found are also never able to repro the issue.

I'm kinda stuck because it's some Exception I can't catch happening deep in WPF code. The only reason I know what's happening is I have this sitting in App.xaml.cs as a last-ditch "something blew up, here's the exception you didn't catch":

C# code:
AppDomain.CurrentDomain.UnhandledException += (s, args) =>
{
    var ex = (Exception)args.ExceptionObject;
    log.Error("UnhandledException: {0}\n{1}", ex.Message, ex.StackTrace);
};

Not sure what your DatePickers' XAML looks like, but try something like this on both of them just to check if this fixes the issue:

// Create some custom style, something like below
<Style x:Key="CustomDatePickerStyle" TargetType="{x:Type DatePicker}">

// Apply it to the DatePicker
<DatePicker Style="{StaticResource CustomDatePickerStyle}"/>

See if that makes the issue go away, it might not work, but I have seen it fix it in some scenarios. The fact it only happens on one machine is odd though. I assume you have multiple machines with the same basic OS/.NET setup and only that one repros it? Are you running any UIAutomation on it (Narrator, touch devices, things like that?) that you aren't on the other machines?.

raminasi
Jan 25, 2005

a last drink with no ice

TheReverend posted:

I can't believe I'm stuck with an inheritance problem but here we are...


I want to keep track of the number of instances in a class with a static int. It would increment on the constructor and decrement on the destructor.

I also want all derived classes to have this ability as well but their own tabulations.

So class Square, Pentagon,Triangle, etc would have their own counts when inherited from base class "Polygon".

Right now it's a Polygon count for all instances.

Anyway to change that? Do I just have to setup a private static int for each class manually and then add in the increment and decrement code?

I'm going to agree with the others that this smells absolutely terrible. Are you saying that it's already implemented, but you want the ability to extend it to subclasses? How are you doing it now?

TheReverend
Jun 21, 2005

It's not already implemented.

It's for nothing other than my own curiosity (just loving around).

I guess the point of my question is , is there a way you can have a static variable be kept track of separately for all derived classes?

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

TheReverend posted:

I guess the point of my question is , is there a way you can have a static variable be kept track of separately for all derived classes?

If you go abstract or generic in the base class yes.
http://stackoverflow.com/questions/5060124/can-i-have-a-base-class-where-each-derived-class-has-its-own-copy-of-a-static-pr

EssOEss
Oct 23, 2006
128-bit approved
I mean if I had to, I would do it like this:

code:
private static readonly Dictionary<Type, int> _allMyInts = new Dictionary<Type, int>();

protected static int MyInt
{
	get
	{
		if (_allMyInts.ContainsKey(GetType())
			return _allMyInts[GetType()];
		else
			return default(int);
 	}
	set { _allMyInts[GetType()] = value; }
}
But this is all dirty logic, no built in mechanism for that. Please never do this.

iron buns
Jan 12, 2016

TheReverend posted:

It's not already implemented.

It's for nothing other than my own curiosity (just loving around).

I guess the point of my question is , is there a way you can have a static variable be kept track of separately for all derived classes?

code:
using System;
using System.Threading;

class Polygon { }

abstract class Polygon<T> : Polygon
{
    public static volatile int Count;

    public Polygon() { Interlocked.Increment(ref Count); }

    ~Polygon() { Interlocked.Decrement(ref Count); }
}

class Triangle : Polygon<Triangle> { }
class Pentagon : Polygon<Pentagon> { }
class Rectangle : Polygon<Rectangle> { }

class Program
{
    static void Main(string[] args)
    {
        var triangles = new[] { new Triangle(), new Triangle(), new Triangle() };
        var pentagons = new[] { new Pentagon(), new Pentagon() };
        var rectangles = new[] { new Rectangle() };

        Console.WriteLine($"Triangles: {Triangle.Count}");
        Console.WriteLine($"Pentagons: {Pentagon.Count}");
        Console.WriteLine($"Rectangles: {Rectangle.Count}");

        GC.KeepAlive(triangles);
        GC.KeepAlive(pentagons);
        GC.KeepAlive(rectangles);

        GC.Collect();
        GC.WaitForPendingFinalizers();

        Console.WriteLine($"Triangles: {Triangle.Count}");
        Console.WriteLine($"Pentagons: {Pentagon.Count}");
        Console.WriteLine($"Rectangles: {Rectangle.Count}");
    }
}

// Output (Release):
//   Triangles: 3
//   Pentagons: 2
//   Rectangles: 1
//   Triangles: 0
//   Pentagons: 0
//   Rectangles: 0
Please, don't do this. The results will vary depending whether you're using Debug or Release build.

Gul Banana
Nov 28, 2003

those implementations are bad

do this instead:
code:
class BaseClass
{
    protected static class Count<T>
    {
	public static int Instances;
    }
}

class Subclass1
{
    public Subclass1()
    {
        Count<Subclass1>.Instances++;
    }
}

class Subclass2
{
    public Subclass2()
    {
        Count<Subclass2>.Instances++;
    }
}

Gul Banana fucked around with this message at 13:40 on Apr 23, 2016

EssOEss
Oct 23, 2006
128-bit approved

Gul Banana posted:

don't do this:

Fixed the most important bit

brap
Aug 23, 2004

Grimey Drawer
Seriously. Fix your data design instead of using statics in this way.

Gul Banana
Nov 28, 2003

it's not THAT weird to want an instance count for various objects. inheritance is not a great way to do it but that doesn't change the nature of the tools involved. like, this simpler version
code:
static class Count<T>
{
  public static int Instances;
}

class A
{
  public A()
  {
    Count<A>.Instances++;
  }
}
is perfectly valid and gives you a central place to add features like thread-safety
code:
static class Count<T>
{
  private static int _instances;
  public static int Instances => _instances;
  public static void AddInstance()
  {
    Interlocked.Increment(ref _instances);
  }
}
or GC-tracking:
code:
static class Count<T> where T: class
{
  private static List<WeakReference> _instances = new List<WeakReference>();
  public static int Instances => _instances.ToList().Count(ref => ref.IsAlive); 
  public static void AddInstance(T obj)
  {
    lock(_instances) 
    { 
      _instances.Add(new WeakReference(obj)); 
    }
  }
}
or logging, etc, etc. it's not some crazy voodoo area

Gul Banana fucked around with this message at 14:17 on Apr 24, 2016

Red Mike
Jul 11, 2011
Instance count won't be correct unless you: never remove instances, maybe have it be an IDisposable and use Dispose to remove the instance, need the instance count relating to the garbage collector (this is not what the majority of people will be expecting).

If you actually need a GC-wise count, then you should know enough about how GC works to be comfortable setting it up with a finaliser without help.

raminasi
Jan 25, 2005

a last drink with no ice
How can I check my NUnit test coverage results with VS2015 Community? I've tried OpenCover with OpenCover.UI, but all my tests are listed as "Not Run" no matter what I do. Is there another solution?

e: I guess OpenCover.UI doesn't support NUnit 3 yet

raminasi fucked around with this message at 19:30 on Apr 24, 2016

Pixelboy
Sep 13, 2005

Now, I know what you're thinking...

epalm posted:

I'll look into Windbg. I feel like I should know this but...how do I know if the Microsoft symbols are loaded, and how exactly does that affect debugging?

Well, when you're debugging stuff - when you call into a Microsoft or CLR function... you will see proper names and line numbers, instead of addresses and offsets.

Helpful if something deep inside throws an exception.

Of course, you can also grab the CLR code off GitHub now....

Fergus Mac Roich
Nov 5, 2008

Soiled Meat
I'm interested in adding report generation to an application. I need something free, preferably with good documentation, but I don't need to do anything too fancy with content. What would you guys recommend I do? Part of me thinks I should just use a templating engine and a WebBrowser with html/js, but I wasn't sure if there was something more standard.

Fergus Mac Roich fucked around with this message at 03:29 on Apr 27, 2016

EssOEss
Oct 23, 2006
128-bit approved
My approach has always been to spit out piles of data and to let an external reporting solution take care of any reports. This nicely splits the maintenance of the main functionality from the maintenance of the part that is reporting on it and helps, I find, drive a solution's evolution in a sensible way.

Just having admins/ops write some PowerShell script that processes a terabyte of log files and outputs a text file is very good from a cost/benefit and maintainability perspective. Consider what you need versus what you "need".

However, this is very general and likely not very useful to you. Can you share more about what sort of reports, who makes them, what data is being reported over and so forth?

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.
For the love of pete, where the hell do I configure what value TFS 2013 uses for OutDir when it runs builds?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Finster Dexter posted:

For the love of pete, where the hell do I configure what value TFS 2013 uses for OutDir when it runs builds?

Assuming a default process template, there's an "MSBuild Arguments" section under "Build -> Advanced". Overriding the outdir is going to probably screw some stuff up though, what do you actually want to do?

If you can upgrade to TFS 2015 and use the new build system, it's way, way better. XAML build is dead.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost
For those not following Xamarin Evolve right now, the Xamarin SDKs are now open and on GitHub

Drastic Actions fucked around with this message at 16:50 on Apr 27, 2016

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

Ithaqua posted:

Assuming a default process template, there's an "MSBuild Arguments" section under "Build -> Advanced". Overriding the outdir is going to probably screw some stuff up though, what do you actually want to do?

If you can upgrade to TFS 2015 and use the new build system, it's way, way better. XAML build is dead.

If I had my way we wouldn't even be using TFS Build. We already have a lot of Atlassian stuff, so I'd rather use Bamboo or even TeamCity would be better than this garbage fire.

But yeah, we just moved our TFS server to a new server and on the old server OutDir was set to go to d:\Builds and on the new server it's going to c:\Builds. On the new server it needs to go to d:\Builds again because IT said so.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Finster Dexter posted:

If I had my way we wouldn't even be using TFS Build. We already have a lot of Atlassian stuff, so I'd rather use Bamboo or even TeamCity would be better than this garbage fire.

But yeah, we just moved our TFS server to a new server and on the old server OutDir was set to go to d:\Builds and on the new server it's going to c:\Builds. On the new server it needs to go to d:\Builds again because IT said so.

Just change the agent setting, no need to mess with outdir.

Seriously though, not being a Microsoft shill: The new build system in 2015 is awesome. The old one was pretty well-known to be more or less okay if you had bog-standard .NET applications, and pretty awful otherwise. If you haven't looked at it, https://msdn.microsoft.com/en-us/library/vs/alm/build/feature-overview

New Yorp New Yorp fucked around with this message at 17:05 on Apr 27, 2016

Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

Ithaqua posted:

Just change the agent setting, no need to mess with outdir.

Where does one do that?

Note that no one will give me actual permissions to manage this poo poo, but it's apparently my responsibility to figure it out because no one else is willing to do it I guess.

Adbot
ADBOT LOVES YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Finster Dexter posted:

Where does one do that?

Note that no one will give me actual permissions to manage this poo poo, but it's apparently my responsibility to figure it out because no one else is willing to do it I guess.

In VS, team explorer, builds tab: Actions -> Manage Build Controllers -> click agent, select properties. Working directory is configurable.

That's off the top of my head, might not be exactly that path.

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