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
Mr Shiny Pants
Nov 12, 2012

Sedro posted:

Do you have Client Access installed? Does the driver show up in the ODBC Administration outside of VS?

Yes you need Client Access for the connection to an AS/400, I did this a couple weeks ago and it should work straight away.

The only thing you need to be aware of when working with the AS/400 is that you check the IBM redbooks on some weird things in the driver. I've never come across these things when using something like Postgress or SQLite, it does some magic in returning the proper DB2 fieldtypes to .Net mappings IIRC. I thought it was odd, that is why I remember.

Adbot
ADBOT LOVES YOU

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Sedro posted:

Do you have Client Access installed? Does the driver show up in the ODBC Administration outside of VS?

Yes - at least I think so



I wasn't sure if I had to add the ODBC package as an add-on or something for VS.

Sedro
Dec 31, 2008
Yeah, my VS2012 doesn't have the driver either. The Client Access installer adds its provider to machine.config, but VS seems to load them from the registry. You could probably add the registry entries with some effort.

Mr Shiny Pants
Nov 12, 2012

Bob Morales posted:

Yes - at least I think so



You can install the extra libraries by running the Client Access setup again and choosing .Net libraries under "ODBC" IIRC. It doesn't get installed by default.

This has an explanation and samples: https://www.redbooks.ibm.com/redbooks/pdfs/sg246440.pdf

This also the Redbook I used to query and insert into our AS/400 system.

The command I remembered is DeriveParameters() otherwise nothing works. :)

There is also a Nuget package that just installs the .Net driver but I haven't used that.

Night Shade
Jan 13, 2013

Old School

Bob Morales posted:

Yes - at least I think so



I wasn't sure if I had to add the ODBC package as an add-on or something for VS.



Check your 32 bit ODBC sources. Visual Studio isn't 64 bit (yet).

crashdome
Jun 28, 2011
So I am about to embark on my first UWP app -and- also my first use of JSON in an app -and- also my first VS2015 app (from ground up). It will connect to a REST api and use authentication via cookies. Any libraries or packages out there I should look into? Any good write-ups I could read? Any new features in VS2015 to make life easier?

I've googled a bit and read some interesting things but, I don't know "what's new" as some stuff already written looks a few years old.

Usually doing WPF/ORM apps in a DB environment so this is a ton of firsts for me.

edit: Here's something I've read but it is for VS2012.

crashdome fucked around with this message at 01:22 on Dec 3, 2015

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

crashdome posted:

So I am about to embark on my first UWP app -and- also my first use of JSON in an app -and- also my first VS2015 app (from ground up). It will connect to a REST api and use authentication via cookies. Any libraries or packages out there I should look into? Any good write-ups I could read? Any new features in VS2015 to make life easier?

I've googled a bit and read some interesting things but, I don't know "what's new" as some stuff already written looks a few years old.

Usually doing WPF/ORM apps in a DB environment so this is a ton of firsts for me.

edit: Here's something I've read but it is for VS2012.

Things to Google, in loose order of decreasing importance:

HttpClient (the C# one, not Apache)
async/await
CookieContainer
Newtonsoft.Json (aka JsonConvert)

Strangely, the article you linked doesn't mention HttpClient at all even though that was the hotness around the article's publishing date.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I updated my Visual Studio 2015 from Update 1 RC to Update 1 release. Now when I start the application I get an error sound and it locks up on the start page. Is this happening to anyone else?

crashdome
Jun 28, 2011

Bognar posted:

Things to Google, in loose order of decreasing importance:

HttpClient (the C# one, not Apache)
async/await
CookieContainer
Newtonsoft.Json (aka JsonConvert)

Strangely, the article you linked doesn't mention HttpClient at all even though that was the hotness around the article's publishing date.

Thanks. I'm checking those out right now. I assume HttpClient has something over the WebClient or HttpWebRequest as they mentioned?

chippy
Aug 16, 2006

OK I DON'T GET IT

crashdome posted:

Thanks. I'm checking those out right now. I assume HttpClient has something over the WebClient or HttpWebRequest as they mentioned?

This is a fairly good comparison. Looks like HttpClient (or RestSharp) might be the way to go:

http://www.diogonunes.com/blog/webclient-vs-httpclient-vs-httpwebrequest/

Inverness
Feb 4, 2009

Fully configurable personal assistant.
The time required to install Update 1 is atrocious. :wtc:

fankey
Aug 31, 2001

I have something like the following targeting .Net 4.0 ( yea XP support! )
code:
    class Manager
    {
      public delegate void GotDataHandler(string data);
      public event GotDataHandler GotData;
      public delegate void DoneHandler();
      public event DoneHandler Done;
      public void Go()
      {
        //....
      }
    }

    async void Go( Manager manager)
    {
      TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
      List<string> data = new List<string>();
      Manager.GotDataHandler gdh = (d) =>
        {
          data.Add(d);
        };
      manager.GotData += gdh;
      Manager.DoneHandler dh = () =>
        {
          tcs.SetResult(true);
        };
      manager.Done += dh;
      manager.Go();

      bool result = await tcs.Task;

      if (result)
      {
        // do something with data here...
      }
      manager.GotData -= gdh;
      manager.Done -= dh;
    }
I'd like to add the ability to cancel (or return false ) the task if the Done handler doesn't get called within a certain amount of time. What would be the easiest way to accomplish this? I assume I need a CancellationSource but can't find a simple example that ties it all together.

Munkeymon
Aug 14, 2003

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



Just a quick rant but the fact that I can't simply do
C# code:
IList<IThing> things = new List<Thing>();
Combined with the "interfaces for everything everywhere" policy i'm currently working under drives me up the loving wall sometimes.

Sedro
Dec 31, 2008
Well sure, mutable lists are invariant. What would happen if you add SomeOthingThing : IThing to the list?

Immutable lists to the rescue, right?

C# code:
IImmutableList<IThing> things = ImmutableList.Create<Thing>();
^^^ 
Error: Cannot implicitly convert type 'System.Collections.Immutable.ImmutableList<Thing>' to 'System.Collections.Immutable.IImmutableList<IThing>'
:negative:

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Munkeymon posted:

Just a quick rant but the fact that I can't simply do
C# code:
IList<IThing> things = new List<Thing>();
Combined with the "interfaces for everything everywhere" policy i'm currently working under drives me up the loving wall sometimes.

So, you actually can do this with IEnumerable<T>, because the generic parameter is defined as out T. You can't do it with IList<T>, since it has methods like int IndexOf(T item). This is probably confusing if you're not familiar with covariance and contravariance so I can give a better explanation if necessary.

Kuvo
Oct 27, 2008

Blame it on the misfortune of your bark!
Fun Shoe
Have any of you ran into an issue with NuGet packages after installing VS15 update 1? Installed the update, went to rebuild my solution and got one of these errors for each project

code:
Your project is not referencing the ".NETFramework,Version=v4.5.2" framework. Add a reference to ".NETFramework,Version=v4.5.2" in the "frameworks" section of your project.json, and then re-run NuGet restore.
Each of my projects roots has a project.lock.json file but I don't see any "framework" section in it. All the projects were targeting 4.5.2 before the update and nothing has changed since then. I tried clearing out my packages folder and rebuilding but got the same error. Any ideas?

Kuvo fucked around with this message at 19:17 on Dec 3, 2015

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

fankey posted:

I have something like the following targeting .Net 4.0 ( yea XP support! )

...code...

I'd like to add the ability to cancel (or return false ) the task if the Done handler doesn't get called within a certain amount of time. What would be the easiest way to accomplish this? I assume I need a CancellationSource but can't find a simple example that ties it all together.

Do you have control over the Manager class? If so, make it support polling a cancellation token.

If not, you can do ghetto Task cancellation (not recommended):

C# code:
var myTask = SomeLongRunningAsyncMethod();
var myDelay = Task.Delay(delayMilliseconds);
await Task.WhenAny(new[] { myTask, myDelay});

if (myDelay.Status == TaskStatus.RanToCompletion)
{
    // handle timeout
}
else
{
    var result = await myTask; // await to throw exception
    // do stuff
}

fankey
Aug 31, 2001

Bognar posted:

Do you have control over the Manager class? If so, make it support polling a cancellation token.

If not, you can do ghetto Task cancellation (not recommended):

C# code:
var myTask = SomeLongRunningAsyncMethod();
var myDelay = Task.Delay(delayMilliseconds);
await Task.WhenAny(new[] { myTask, myDelay});

if (myDelay.Status == TaskStatus.RanToCompletion)
{
    // handle timeout
}
else
{
    var result = await myTask; // await to throw exception
    // do stuff
}

Thinking about this more - I don't need to cancel the Manager operation. In my case the Manager stuff is always running and actually shouldn't be canceled. I just need to stop my task from waiting if I don't hear from the Manager in a given amount of time.

Munkeymon
Aug 14, 2003

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



Bognar posted:

So, you actually can do this with IEnumerable<T>, because the generic parameter is defined as out T. You can't do it with IList<T>, since it has methods like int IndexOf(T item). This is probably confusing if you're not familiar with covariance and contravariance so I can give a better explanation if necessary.

I have a fuzzy familiarity with covariance and contravariance but I don't immediately see why IndexOf(T[ of IThing] item) can't be made to work. Because the item argument is implicitly cast to IThing so asking for the index of a not-IThing and null are equivalent and therefore ambiguous?

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Munkeymon posted:

I have a fuzzy familiarity with covariance and contravariance but I don't immediately see why IndexOf(T[ of IThing] item) can't be made to work. Because the item argument is implicitly cast to IThing so asking for the index of a not-IThing and null are equivalent and therefore ambiguous?

The problem is that you're providing an implementation of IList for parameter of type Thing, not IThing. Here's some code to demonstrate:

C# code:
public interface IThing
{
    void DoSomething();
}

public class Thing : IThing
{
    public void DoSomething() { }
    public void DoSomethingElse() { }
}

public class OtherThing : IThing
{
    public void DoSomething() { }
}

public interface IInvariant<T> // similar to IList<T>
{
    T DoInvariantThing(T input);
}

public class InvariantImpl : IInvariant<Thing>
{
    Thing DoInvariantThing(Thing input)
    {
        input.DoSomething();
        input.DoSomethingElse();
        return input;
    }
}


IInvariant<IThing> myInvariant = new InvariantImpl(); // not possible
myInvariant.DoInvariantThing(new OtherThing); // what happens here?
InvariantImpl expects a Thing to be passed in to DoInvariantThing. Because of that, it's allowed to call DoSomethingElse in its implementation, a method that is only implemented on Thing. If I pass in some other IThing to that method, it's not guaranteed to have DoSomethingElse defined.

Bognar fucked around with this message at 20:06 on Dec 3, 2015

NihilCredo
Jun 6, 2011

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

Munkeymon posted:

Just a quick rant but the fact that I can't simply do
C# code:
IList<IThing> things = new List<Thing>();
Combined with the "interfaces for everything everywhere" policy i'm currently working under drives me up the loving wall sometimes.

What is it exactly you want to do that wouldn't work if you did

C# code:
IList<IThing> things = new List<IThing>();
?

Munkeymon
Aug 14, 2003

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



Bognar posted:

The problem is that you're providing an implementation of IList for parameter of type Thing, not IThing.

:doh: hell, I was just thinking about it backwards because it made sense as soon as I read that.

NihilCredo posted:

What is it exactly you want to do that wouldn't work if you did

C# code:
IList<IThing> things = new List<IThing>();
?

Use a method defined to return a List<Thing> without jumping through an annoying hoop.

Munkeymon fucked around with this message at 20:34 on Dec 3, 2015

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.

Munkeymon posted:

Just a quick rant but the fact that I can't simply do
C# code:
IList<IThing> things = new List<Thing>();
Combined with the "interfaces for everything everywhere" policy i'm currently working under drives me up the loving wall sometimes.

C# code:
class Thing : IThing { ... }

class SomeOtherThing : IThing { ... }

IList<IThing> things = new List<Thing>();

things.add(SomeOtherThing);  
This is why. The rest of your code is expecting list "things" to allow any objects that implement IThing, however, you set the value to be a list that only allows a specific implementation. So if that assignment was allowed, it would fail to compile because you cannot add SomeOtherThing to List<Thing>().

ljw1004
Jan 18, 2005

rum

Kuvo posted:

Have any of you ran into an issue with NuGet packages after installing VS15 update 1? Installed the update, went to rebuild my solution and got one of these errors for each project
code:
Your project is not referencing the ".NETFramework,Version=v4.5.2" framework.
Add a reference to ".NETFramework,Version=v4.5.2" in the "frameworks" section
of your project.json, and then re-run NuGet restore.
Each of my projects roots has a project.lock.json file but I don't see any "framework" section in it. All the projects were targeting 4.5.2 before the update and nothing has changed since then. I tried clearing out my packages folder and rebuilding but got the same error. Any ideas?

It's talking about the project.json file, not project.lock.json. (If this is the error message it gives now then I don't understand how it could ever have worked before, unless there were unrelated changes like deleting project.json).

Here's an example. I'm writing a Console app which targets .NETFramework 4.5.2. I wished to use Nuget3 (project.json) instead of NuGet2 (packages.config) because of the advantages it brings, such as not messing up my .csproj file. Here is the project.json that I will use:
code:
{
  "dependencies": {
    "Newtonsoft.Json": "7.0.1"
  },
  "frameworks": {
    "net452": {}
  },
  "runtimes": {
    "win": {}
  }
}
You often have to unload+reload your project if you alter its project.json, or change its frameworks/runtimes section.


Incidentally, I used to have "win-anycpu" in there. In Update1 it seems to require me to change it to just "win". I don't know if that's true, and I don't know the how or why. I haven't been able to find any documentation on the permitted "frameworks" or "runtimes".

ljw1004 fucked around with this message at 00:19 on Dec 4, 2015

ljw1004
Jan 18, 2005

rum

fankey posted:

I'd like to add the ability to cancel (or return false ) the task if the Done handler doesn't get called within a certain amount of time. What would be the easiest way to accomplish this? I assume I need a CancellationSource but can't find a simple example that ties it all together.

I want to walk through this step by step. First off, I think your "Go" method is very nicely written with its use of TaskCompletionSource, but I think it's a poor candidate for returning "async void". I'd make it an async task, and use try/finally to make sure the handlers get unhooked:

code:
    async Task<string> GoAsync(Manager manager)
    {
        TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
        List<string> data = new List<string>();
        Manager.GotDataHandler gdh = (d) => data.Add(d);
        Manager.DoneHandler dh = () => tcs.SetResult(true);
        manager.GotData += gdh;
        manager.Done += dh;
        manager.Go();
        try
        {
            await tcs.Task;
            return String.Join(",", data);
        }
        finally
        {
            manager.GotData -= gdh;
            manager.Done -= dh;
        }
    }
Next off, an important thing about cancellation is that it's cooperative. If a cancellation request comes in, shouldn't you actively tell the manager to stop its work?

You're basically following the "Task-over-event" pattern. I assume that your manager has some cooperative way of telling it to abort, e.g. a method "manager.Abort()" which will request it to stop whatever it's doing, and when it gets round to stopping, then it will fire its DoneHandler(false), where the flag indicates whether it succeeded.

code:
    async Task<string> GoAsync(Manager manager,
                   CancellationToken cancel = default(CancellationToken))
    {
        var tcs = new TaskCompletionSource<string>();
        var data = new List<string>();
        Manager.GotDataHandler gdh = (d) =>
        {
            data.Add(d);
        };
        Manager.DoneHandler dh = (b) =>
        {
            if (b) tcs.SetResult(String.Join(",", data));
            else tcs.SetException(new OperationCanceledException(cancel));
        };
        manager.GotData += gdh;
        manager.Done += dh;
        manager.Go();
        using (cancel.Register(() => manager.Abort()))
        {
            try
            {
                return await tcs.Task;
            }
            finally
            {
                manager.GotData -= gdh;
                manager.Done -= dh;
            }
        }
    }
Now the typical pattern is that the consumer of your GoAsync API can decide whether they want a timeout cancellation or not. Here's how they'd do it:

code:
        var cts = new CancellationTokenSource(500);
        try
        {
            await GoAsync(new Manager(), cts.Token);
        }
        catch (OperationCanceledException ex)
        {
            Console.WriteLine("oops");
        }
It's possible for you to build an internal "linked cancellation token" yourself inside your GoAsync method, in case your GoAsync needs its own internal timeout - and hence has to listen both to cancellation from its internal timeout, and the one provided externally:

code:
    static async Task<string> GoAsync(Manager manager,
                     CancellationToken cancel = default(CancellationToken))
    {
        var cts2 = CancellationTokenSource.CreateLinkedTokenSource(cancel);
        cts2.CancelAfter(500);

        var tcs = new TaskCompletionSource<string>();
        var data = new List<string>();
        Manager.GotDataHandler gdh = (d) =>
        {
            data.Add(d);
        };
        Manager.DoneHandler dh = (b) =>
        {
            if (b) tcs.SetResult(String.Join(",", data));
            else tcs.SetException(new OperationCanceledException(cancel));
        };
        manager.GotData += gdh;
        manager.Done += dh;
        manager.Go();
        using (cts2.Token.Register(() => manager.Abort()))
        {
            try
            {
                return await tcs.Task;
            }
            finally
            {
                manager.GotData -= gdh;
                manager.Done -= dh;
            }
        }
    }
NOTE: In general you have to decide upon your semantics of cancellation. If you request GoAsync to cancel, should its returned Task be cancelled immediately even while the manager continues to run underneath? Or should it merely request the manager to cancel, and then in turn cancel its own returned Task only after the manager has successfully terminated? I definitely prefer the latter because it's cleaner, and defers more flexibility to the caller.

Munkeymon
Aug 14, 2003

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



Begby posted:

C# code:
class Thing : IThing { ... }

class SomeOtherThing : IThing { ... }

IList<IThing> things = new List<Thing>();

things.add(SomeOtherThing);  
This is why. The rest of your code is expecting list "things" to allow any objects that implement IThing, however, you set the value to be a list that only allows a specific implementation. So if that assignment was allowed, it would fail to compile because you cannot add SomeOtherThing to List<Thing>().

It's not so obvious that would be a problem in the case of a container that's just storing and retrieving objects, though, and it seems like you could design a type system where that list could store OtherThings but they'd all come back out as IThings because that's the declared type of the list. Obviously that's not C#'s (the CLR's?) supported type system and again, I'm probably mixing paradigms in my head because I've been all over the place with languages.

epswing
Nov 4, 2003

Soiled Meat
InstallShield is a steaming pile of buggy dogshit and it will be the death of me.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Munkeymon posted:

It's not so obvious that would be a problem in the case of a container that's just storing and retrieving objects, though, and it seems like you could design a type system where that list could store OtherThings but they'd all come back out as IThings because that's the declared type of the list.

The problem isn't really that they all come out as IThings, it's more that when they go in it's expected to be of type Thing. Casting a List<Thing> to IList<IThing> (if it was possible) doesn't change the runtime type, it just changes the representation to the compiler. So the Add method on List<Thing> would still expect a Thing, regardless of it being represented as IList<IThing>.

chippy
Aug 16, 2006

OK I DON'T GET IT

epalm posted:

InstallShield is a steaming pile of buggy dogshit and it will be the death of me.

Worse than ClickOnce?

kingcrimbud
Mar 1, 2007
Oh, Great. Now what?
Why would a sql query generated from Entity Framework take minutes to execute, yet when the same query is run within SSMS, it takes less than a second?

Entity Framework 6.1.3
SQL Server 2005 Enterprise

I'm grabbing the sql generated using the Infrastructure Interception DatabaseLogger registered in web.config. I'm unable to trace or profile in SSMS due to a current lack of permissions so I don't have any other details yet.

Calidus
Oct 31, 2011

Stand back I'm going to try science!

kingcrimbud posted:

Why would a sql query generated from Entity Framework take minutes to execute, yet when the same query is run within SSMS, it takes less than a second?

Entity Framework 6.1.3
SQL Server 2005 Enterprise

I'm grabbing the sql generated using the Infrastructure Interception DatabaseLogger registered in web.config. I'm unable to trace or profile in SSMS due to a current lack of permissions so I don't have any other details yet.

Are you by chance doing a insert? In my experience entity inserts are terribly slow. Entity also seems to take a larger performance hit do to missing keys and indexes than raw sql.

Munkeymon
Aug 14, 2003

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



Bognar posted:

The problem isn't really that they all come out as IThings, it's more that when they go in it's expected to be of type Thing. Casting a List<Thing> to IList<IThing> (if it was possible) doesn't change the runtime type, it just changes the representation to the compiler. So the Add method on List<Thing> would still expect a Thing, regardless of it being represented as IList<IThing>.

Yeah, I get all that. I'm not sure that writing the IL equivalent of ListOfThings.Add(OtherThing) would do when run since I don't expect a list to try to manipulate or interact much with what you hand it. It totally makes sense that it wouldn't Just Work in your previous example, but it (maybe just superficially) looks like you could take the C# type system and extend it a bit to use, say, ref to mean you promise to just store reference(s) to this type without interacting with it in much the same way out was extended. I'm not even sure that'd be useful at this point - just saying it looks feasible.

Does anyone know if there's a ctrl+key combination to add fixed tags like with italics and bold? I'm sick of typing the stupid things.

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

Calidus posted:

Are you by chance doing a insert? In my experience entity inserts are terribly slow. Entity also seems to take a larger performance hit do to missing keys and indexes than raw sql.

It's a simple select, top 100 from table_x, joined to table_y. Filters are on a few table_y columns.

The database has no constraints and I'm not sure the indexes it does have are even relevant. Hard to tell until I can get additional db permissions.

Kuvo
Oct 27, 2008

Blame it on the misfortune of your bark!
Fun Shoe

ljw1004 posted:

It's talking about the project.json file, not project.lock.json. (If this is the error message it gives now then I don't understand how it could ever have worked before, unless there were unrelated changes like deleting project.json).

Here's an example. I'm writing a Console app which targets .NETFramework 4.5.2. I wished to use Nuget3 (project.json) instead of NuGet2 (packages.config) because of the advantages it brings, such as not messing up my .csproj file. Here is the project.json that I will use:
code:
{
  "dependencies": {
    "Newtonsoft.Json": "7.0.1"
  },
  "frameworks": {
    "net452": {}
  },
  "runtimes": {
    "win": {}
  }
}
You often have to unload+reload your project if you alter its project.json, or change its frameworks/runtimes section.


Incidentally, I used to have "win-anycpu" in there. In Update1 it seems to require me to change it to just "win". I don't know if that's true, and I don't know the how or why. I haven't been able to find any documentation on the permitted "frameworks" or "runtimes".

Thanks for the info. What confuses me is that these project have both a packages.config and a project.lock.json, but no project.json. This is strange as I checked the extensions section of VS and it shows NuGet 3.3.0.167 installed, which if i understand right should require the project.json file. Additionally, the project.lock.json file isnt in the format you mentioned (the one described here). I ended up getting the project to build by renaming the project.lock.json file to something else but I'm wondering if this will break the package management in the future

SirViver
Oct 22, 2008
Ok, so, if I want to use ASP.NET 5 but have a third party library that depends on custom configuration sections in the old app/web.config format... am I completely boned? Or is there a way to make these still work?

fankey
Aug 31, 2001

ljw1004 posted:

I want to walk through this step by step....
Thanks for the detailed response. I was confusing timing out an Async call with cancelling an Async call. In my case I don't needs to actually cancel anything on the Manager - in fact there is nothing to cancel. The manager is kind of like a message sniffer that anyone can hook up to. The Done message doesn't really mean that the Manager is done - I probably didn't give it the best name. So lets say there are 2 types of callback from the Manager - Data and FrameEnd. I want to collect all the Data passed in until I get a FrameEnd. If I don't get a FrameEnd in a given amount of time then I want to throw and exception. Taking your suggestions, would something like this work?
code:
class Manager
{
  public delegate void GotDataHandler(string data);
  public event GotDataHandler GotData;
  public delegate void FrameEndHandler();
  public event FrameEndHandler FrameEnd;
}

async Task<List<string>> Go(Manager manager, CancellationToken cancel = default(CancellationToken))
{
  TaskCompletionSource<List<string>> tcs = new TaskCompletionSource<List<string>>();
  List<string> data = new List<string>();
  Manager.GotDataHandler gdh = (d) =>
  {
    data.Add(d);
  };
  manager.GotData += gdh;
  Manager.FrameEndHandler fe = () =>
  {
    tcs.SetResult(data);
  };
  manager.FrameEnd += fe;
  using (cancel.Register(() => tcs.SetException(new OperationCanceledException())))
  {
    try
    {
      return await tcs.Task;
    }
    finally
    {
      manager.GotData -= gdh;
      manager.FrameEnd -= fe;
    }
  }
}

ljw1004
Jan 18, 2005

rum

Kuvo posted:

What confuses me is that these project have both a packages.config and a project.lock.json, but no project.json. This is strange as I checked the extensions section of VS and it shows NuGet 3.3.0.167 installed, which if i understand right should require the project.json file.

The Nuget3.3.0.167 client (and all clients going forwards) understand both NuGet2 "packages.config" and NuGet3 "project.json" style projects.

Your project must be either packages.config based (meaning it lacks both project.json and project.lock.json) or project.json based (meaning it lacks packages.config).

If you have both files then you'll get bizarre error messages. That's because some parts of VS key off the existence of project.lock.json to understand what kind of project you're in, and others key off the existence of project.json/packages.config.

If you wish your project to be a "project.config" style project going forwards, then you should make sure to delete both project.json and project.lock.json if you have them, then unload, then reload.

Do you have project.lock.json checked into source control? It shouldn't be. Project.lock.json is an intermediate file that's generated upon project build (prior to msbuild being invoked). It's always safe to delete this file. I wish they'd stored it in the "obj" directory to make this clear.

ljw1004
Jan 18, 2005

rum

fankey posted:

I want to collect all the Data passed in until I get a FrameEnd. If I don't get a FrameEnd in a given amount of time then I want to throw and exception. Taking your suggestions, would something like this work? ...

That looks exactly right to me!

Kuvo
Oct 27, 2008

Blame it on the misfortune of your bark!
Fun Shoe

ljw1004 posted:

The Nuget3.3.0.167 client (and all clients going forwards) understand both NuGet2 "packages.config" and NuGet3 "project.json" style projects.

Your project must be either packages.config based (meaning it lacks both project.json and project.lock.json) or project.json based (meaning it lacks packages.config).

If you have both files then you'll get bizarre error messages. That's because some parts of VS key off the existence of project.lock.json to understand what kind of project you're in, and others key off the existence of project.json/packages.config.

If you wish your project to be a "project.config" style project going forwards, then you should make sure to delete both project.json and project.lock.json if you have them, then unload, then reload.

Do you have project.lock.json checked into source control? It shouldn't be. Project.lock.json is an intermediate file that's generated upon project build (prior to msbuild being invoked). It's always safe to delete this file. I wish they'd stored it in the "obj" directory to make this clear.

packages.config is in source control but project.json isnt so i guess the VS update somehow generated it, causing the errors. Thanks for the clarification!

Adbot
ADBOT LOVES YOU

redleader
Aug 18, 2005

Engage according to operational parameters

kingcrimbud posted:

Why would a sql query generated from Entity Framework take minutes to execute, yet when the same query is run within SSMS, it takes less than a second?

Entity Framework 6.1.3
SQL Server 2005 Enterprise

I'm grabbing the sql generated using the Infrastructure Interception DatabaseLogger registered in web.config. I'm unable to trace or profile in SSMS due to a current lack of permissions so I don't have any other details yet.

This might be because the execution plan used for the EF query is different to the one used in the SSMS query - SQL Server generates and caches execution plans based on a whole bunch of factors, and it's possible that the SSMS query has different SET options that renders SQL Server unable to reuse the plan from the EF query. Greybeard Erland Sommarskog goes into a hell of a lot of detail on this subject.

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