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
Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Chiming in to bitch about VS2015 and package management. It's now impossible to install the package MvvmCross into a Xamarin.iOS or Xamarin.Android app. I have to open up VS2013 and use NuGet there to get things working.

Adbot
ADBOT LOVES YOU

ljw1004
Jan 18, 2005

rum

Gul Banana posted:

it's a new world out there.

sadly, the only one of these which supports .NET 4.5 is the bolded one - this is an xproj rather than a csproj, a DNX project. no good for my purposes since some of the libraries I'd like to build are written in VB (which DNX does not support). so, no project.json yet.

What do you mean by "supports .NET45"? I don't understand... There are two basic ideas:

(1) .NET45 refers to the desktop framework. This can be used by a regular class library, or a DNX class library, or by any of the traditional desktop app types (e.g. console app, WPF, WinForms, ...). It can also be used by a Portable Class Library, although depending on your choice of targets you might get only a subset of .NET45. I don't know what you're targeting, but if you want .NET45 then there's definitely a ClassLibrary or PortableClassLibrary out there that you can use.

(2) Theoretically it's possible to use project.json in any project type. First, for any project type, it can be used as an alternative to packages.config for referencing NuGet packages. Second, for UWP+DNX+ModernPCL only so far, it's also used as the means to reference .NET runtime+framework themselves. (in all other project types the reference to runtime+framework is implicit or done differently).

The first aspect I called out isn't yet finished. But you can see it in action, e.g. start with a new console app targeting .NET46, then add this project.json and unload+reload the project.
code:
{
  "dependencies": {
    "Newtonsoft.Json": "7.0.1"
  },
  "frameworks": {
    "net46": { }
  },
  "runtimes": {
    "win-anycpu": { }
  }
}

EssOEss
Oct 23, 2006
128-bit approved
I am really struggling to make sense of what people speak of now with this proliferation of different types of .NET. For example, when you say "UWP+DNX+ModernPCL", what exactly do you mean? Is there a standard reference to understand the different variations? I have seen various blog posts that aim to explain but then I see other posts use different but similar terminology and get all confused. This is the first I hear of ModernPCL.

On another topic, I noticed the Universal Windows Platform presentation had a tidbit that Microsoft no longer cares so much for nitpicking about UX rules, just makes recommendations. Can anyone confirm this appears to be the case in practice (and not just some dev-schmoozing in the video)? Right now, customers get all sort of headaches when we have to tell them that their apps violate Windows Phone rules and will not be accepted; not to mention Xbox, which is on a whole other level of crazy. Would be pretty sweet if this hassle is now reduced.

EssOEss fucked around with this message at 17:16 on Aug 13, 2015

Captain Capacitor
Jan 21, 2008

The code you say?
Seconding Paket. It's not as well integrated with VS as nuget, but you can import your packages.config as a start.

Also I think I should write a Type Provider for GraphQL, it looks neat.

SirViver
Oct 22, 2008
Is there any rough estimate as to when VS 2015 SP1 will come out yet? Or any way to join a beta program of sorts to get developer builds faster (like it was done for Windows 10)?

I think I'll go back to VS 2013 for the time being, as I feel it's just too buggy and slow to use for daily development :(. There seem to be a lot more situations where the UI just hangs completely for 2-3 seconds (also freezing other VS 2015 instances for some reason), which gets really irritating after a while. Also I have to say Edit & Continue has proven rather useless to me so far:
  • It's much slower to start editing. Hangs for a good while whereas VS 2013 editing started instantly.
  • Editing methods containing Lambda expressions seem to randomly complain about changing the type of the Lambda parameters for no discernible reason, preventing EnC.
  • There seems to be a bug where class member references are broken somehow (??). Specifically I see this behavior in ASP.NET WebForms where I have some class object as Page member that I access in Page_Load(). After I EnC, the member reference will not only be null, but so broken that you can't even assign a value to it. The debugger doesn't show any value when you mouseover the variable. Assignments to it "succeed", but no value is shown afterwards either. Accessing the member causes a NullReferenceException.

ljw1004
Jan 18, 2005

rum

EssOEss posted:

I am really struggling to make sense of what people speak of now with this proliferation of different types of .NET. For example, when you say "UWP+DNX+ModernPCL", what exactly do you mean? Is there a standard reference to understand the different variations? I have seen various blog posts that aim to explain but then I see other posts use different but similar terminology and get all confused. This is the first I hear of ModernPCL.

Sorry, ModernPCL was a lazy non-standard word I used.



UWP = "Universal Windows Platform" = Windows 10

DNX = ASP.NET Core 5.0

PCL = "Portable Class Library". There is a new kind of portable class library that was introduced with VS2015 (so long as you install the Win10 tools). Look at these two PCLS...

The one on the left is what you're familiar with, and is how PCLs have always worked. The one on the right is what you get if you write a PCL which targets either all or a subset of .NET4.6 + Windows10 + ASP.NET Core 5.0. What's different about it is that it doesn't have a normal implicit reference to a fixed version of the .NET framework. Instead it references the .NET framework via a NuGet package. I've been informally calling this new kind a "NuPCL" or a "ModernPCL" but they're both bad names and I should find a better name...

Gul Banana
Nov 28, 2003

ljw1004 posted:

What do you mean by "supports .NET45"? I don't understand...

i mean, supports targetting the full .net 4.5 API set, such that it can be referenced by desktop applications without requiring an update to 4.6.
existing class library builds can do this, as can xproj (but not for VB code). pcl cannot. therefore, i can't use project.json yet.

it's not that the new stuff is bad, but like, the reality of the market.. most of our clients are using windows 7 and .net 4.5, maybe 4.5.1 or 4.5.2. you know how conservative business can be about upgrades, so it'll be maybe a year or two before i can depend on newer stuff than that (for these libraries).

not quoting the rest of your post because i already understand that stuff and don't want to get in the way of the explanations :)

ljw1004
Jan 18, 2005

rum

SirViver, could you email me please lwischik@microsoft.com because I'd like to put you in touch directly with the perf devs and EnC devs to dig deeper into what you observed. The general feedback we've heard has actually been that VS2015 is faster than VS2013 - faster IDE and faster build - so I suspect there's something specific going on with your machine, maybe related to a faulty upgrade/install or maybe to a third-party tool.


* "When is the next VS2015 update coming out?" - sorry we haven't announced anything yet. If the past is anything to go by, updates come out quarterly. But really the intent of your question is "when will the problems you encountered be fixed?" and that requires us to identify the problems first, so please do email!

* "Is there any kind of a beta program to get builds faster?" - we were releasing VS2015 builds publically all along (CTP1...6) basically like the "fast track". We released the RC, kind of like the "slow track". At some points the quality of our internal builds was too low for either track but still needed testing, so we also did private drops for folks who were willing to soldier through bad known bugs. That required a high degree of commitment! I believe the same thing will happen going forwards.

ljw1004
Jan 18, 2005

rum

Gul Banana posted:

i mean, supports targetting the full .net 4.5 API set, such that it can be referenced by desktop applications without requiring an update to 4.6.
existing class library builds can do this, as can xproj (but not for VB code). pcl cannot. therefore, i can't use project.json yet.

I see. I mentioned that this isn't finished yet. Here's what you can do, and how to work around the "not finished yet" part...

(1) Create a normal ClassLibrary targeting .NET4.5.

(2) Add this project.json file, unload then reload, then build. This lets you use project.json in your class library.
code:
{
  "dependencies": {
    "Newtonsoft.Json": "7.0.1"
  },
  "frameworks": {
    "net45": { }
  },
  "runtimes": {
    "win-anycpu": { }
  }
}
(3) Now create a .NET45 application, e.g. a ConsoleApp. You can add a reference to the class library.

What's not finished yet: if you try to run the result, you'll see that Json.Net (which was referenced by the class library) is needed by the app for it to run. And it's failing to pick up this fact. So you have to work around it. One way to work around it is if you release your class library as a NuGet itself, one which pulls in Json.Net as a dependency via its NuSpec. Another way is to add a reference to Json.Net from the console app itself.

This same workaround is needed for any kind of reference that your ClassLibrary pulls in via NuGet. It's needed because the console app isn't itself also a project.json thing, and we only implemented transitive NuGet restore wholly within the project.json world.

ljw1004
Jan 18, 2005

rum

Bognar posted:

Chiming in to bitch about VS2015 and package management. It's now impossible to install the package MvvmCross into a Xamarin.iOS or Xamarin.Android app. I have to open up VS2013 and use NuGet there to get things working.

Thanks Bognar. We chatted internally and I filed this bug to track it: https://github.com/NuGet/Home/issues/1172

Gul Banana
Nov 28, 2003

that workaround would be sufficient for some layers of our stack, so i'll try it out some time!

if project.json is going to be supported in arbitrary projects (specifically, desktop and old-ASP.NET projects), it would neatly take care of all my problems; the transitive internal+external update would just be a matter of editing a version at the top level. we could just have a script that goes through a solution and changes "OurCompany.Package.92.0" to "OurCompany.Package.93.0-pre"..

Gul Banana fucked around with this message at 19:10 on Aug 13, 2015

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

SirViver posted:

Is there any rough estimate as to when VS 2015 SP1 will come out yet? Or any way to join a beta program of sorts to get developer builds faster (like it was done for Windows 10)?

Microsoft doesn't do service packs anymore, they do (roughly) quarterly updates. So I'd expect VS 2015 Update 1 to come out late October/early November.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

ljw1004 posted:

Thanks Bognar. We chatted internally and I filed this bug to track it: https://github.com/NuGet/Home/issues/1172

Awesome, thanks for looking into it!

Mr Shiny Pants
Nov 12, 2012
You'd think unzipping a file in a PCL would be a solved problem by now.

Anybody know of a good unzipper for PCLs?

I've tried a few and they seem to suck, so now I just use System.IO.Compression but I seem to have to handle extracting manually instead of just saying: "Here is a Zip file, extract its contents to this directory" and be done.

The extractarchive extension method does not seem to work in a PCL (The one from system.io.compression.filesystem).

raminasi
Jan 25, 2005

a last drink with no ice
I'm having trouble getting ILMerge to work. I can execute the merge fine, but at a certain point in my code a TypeInitializationException is thrown, with a CryptographicException ("Specified key is not a valid size for this algorithm") as its inner exception. My application doesn't deal with crypto at all, so I assume this is some kind of assembly resolution/loading thing.

What's weird is that this exception isn't thrown from any of the assemblies that went into the merge. (Later in this code path that assembly will be called into, but it hasn't yet. The type that failed to load is called "<Module>" which I assume is CLR-speak for "who knows," and I can't figure it what it is any other way.

Any ideas?

e: By screwing around in the Immediate window, I have learned that this exception is thrown whenever I try to use a type found in the merged-in library.

edit 2: I believe the culprit is the fact that the library I am attempting to merge in has been obfuscated.

raminasi fucked around with this message at 23:31 on Aug 13, 2015

RICHUNCLEPENNYBAGS
Dec 21, 2010
Is locally hosted Katana (I had OWIN here but that's the auth stuff, right? Whoops) + WebAPI a viable solution for desktop (well, single user I guess) apps? I have a bunch of code generation tools that make writing Angular stuff really quick, I hate Windows Forms, and I'm kind of on the fence about learning WPF just for personal projects when I don't like writing UI stuff very much in the first place. I guess I'm imagining something a bit like SANZBD where the UI is all through a browser window.

RICHUNCLEPENNYBAGS fucked around with this message at 03:19 on Aug 14, 2015

Gul Banana
Nov 28, 2003

that's feasible. the ui might not be very nice but it's a tested approach.

SirViver
Oct 22, 2008
Thanks, I'll try to contact you in the next few days. I did send those "frown" reports with the tag you mentioned earlier - do you know if anything useful could be gleaned from those yet?


In the meanwhile, a short documentary about the EnC bug I mentioned.

Start with a bog-standard ASP.NET Web Form (derived from a base class that ultimately derives from Page), with some business object members:


Then EnC the Page_Load method, for example I added a dummy if (true) { } below there. The method is barely 20 lines long and contains nothing fancy; no LINQ or lambda expressions or anything.

Boom, all the member fields are broken now and you will get NullRef exceptions when trying to access them. Looking at them in Watch reveals a really strange error:


After some further digging it appears the fields have somehow been duplicated during the EnC recompile, quite rightfully confusing both debugger and runtime:

(duplicated configBPO member not shown).

Welp. :psyduck:

SirViver
Oct 22, 2008
HA, I found the bug!

I was trying to create a minimal repro case, and the error somehow seemed to be related to the specific assembly the referenced member's type is defined in - if I put the same dummy class I used for testing in in a new class library it worked. Having members referencing both the "broken" assembly and the newly created one resulted in only the broken-assembly-members being screwed up after EnC.

On a hunch I decided to make sure the assembly properties are equal between the both and suddenly I could reproduce the error even with the new class library. Turns out if you use an auto-generated assembly version number EnC breaks member references to types defined in that assembly.


The repro code is literally this:

Main console project...

Program.cs
C# code:
using EnCClassLibrary;

namespace EditAndContinueConsoleTest
{
	class Program
	{
		static SomeClass someClass;

		static void Main(string[] args)
		{
			someClass = new SomeClass(); 
			someClass.SomeProperty = 1; // Step until here, EnC below, continue execution --> will throw NullReferenceException

			if (true) { } // EnC this to false (or whatever - specifics don't matter, just trigger EnC)
		}
	}
}
...referencing the "EnCClassLibrary" (doesn't matter if via project or assembly reference), in which you have

AssemblyInfo.cs
C# code:
...
[assembly: AssemblyVersion("1.0.*")]
...
SomeClass.cs
C# code:
namespace EnCClassLibrary
{
    public class SomeClass
    {
		public int SomeProperty { get; set; }

		public SomeClass()
		{

		}
    }
}

Mr Shiny Pants
Nov 12, 2012
I am trying to POST a file with HttpClient from my PCL and I keep getting "204 No Content" back from my WebApi server.

I've been scouring the internet, but I keep coming up empty with why this is.

I ripped out all the using statements figuring I might dispose too soon, but no luck. It might be that I am staring too long at this already and missing something obvious.

Code:

code:
 var client = new System.Net.Http.HttpClient();
            var uploadStream = await inspectionZipFile.OpenAsync(FileAccess.Read);
            var stream = new MemoryStream();  <-- this is temporary, just to check if my stream gets filled, it does.
            await uploadStream.CopyToAsync(stream);
            await uploadStream.FlushAsync();
            stream.Position = 0;
            var multiContent = new MultipartFormDataContent();
            
                var content = new StreamContent(stream);
                content.Headers.Add("Content-Type", "application/zip");
                content.Headers.Add("Content-Disposition", "form-data; name=\"file\"; filename=\"" + inspectionZipFile.Name + "\"");
                multiContent.Add(content, "Inspection", inspectionZipFile.Name);
                //multiContent.Headers.Add("Content-Type", "application/zip");
                //var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost:52958/api/inspections");
                //request.Content = multiContent;
                //request.Content.Headers.Add("Content-Type", "application/octet-stream");
                var result = await client.PostAsync("http://localhost:52958/api/inspections", multiContent);

            //}
WebApi controller:
code:
[HttpPost]
        public void Post()
        {
            var bla = "bla";
        }
Any ideas?

Edit: Well I am stupid, you need to handle the files in the Controller otherwise it won't work. I don't know why I assumed I would see the files in the request. Probably because of working with NancyFX.
It works now.

Mr Shiny Pants fucked around with this message at 15:45 on Aug 14, 2015

EssOEss
Oct 23, 2006
128-bit approved

Captain Capacitor posted:

I'm doing an internal move today to a team that has put me in the position of being able to talk to the Azure product teams more directly. I've sent a message, but this applies to anyone who has an issue. I can't guarantee anything but I can now yell at people louder.

Can you get a definitive statement whether "error 19 - physical connection not usable" is a normal thing when accessing Azure SQL Database? Really, I understand that occasional interruptions are fine in Azure and we deal with it by using retry logic but interestingly enough, this and some other (timeout) exceptions are not handled by SqlAzureExecutionStrategy and we have no far not been able to determine if this is something to expect during normal operations or some abnormality to push harder to get fixed. If it's normal, we can either retry or to tell our customers it is normal Azure behavior but right now, our ops team is rather uncertain on how to even interpret this situation. Such failures occur 4-5 times a day.

RICHUNCLEPENNYBAGS
Dec 21, 2010
I've got some code that tries to start up a new app domain, then load an assembly (whose path is passed in by string), then reflect over it, then dispose of the app domain, but it fails to load the specified DLL because of dependency issues. I have to admit I don't know a lot about AppDomains and assembly loading so I'm not sure where to start looking for the issue. Ideas?

SirViver
Oct 22, 2008
I've now also managed reproduce the EnC slowness independently from my work environment; simply put, VS2015 EnC can't deal with large assemblies.

I wrote a small tool that generates random classes with some properties, methods, and a member variable of the previously generated class, to have some class coupling (broken up every 10 classes, so the hierarchy doesn't get ridiculous). I let it churn out some 2000 classes that I put into a class library, which ended up being about 400K LOC that compiles to a 17.5MB assembly. That's pretty much exactly twice the size of our actual business logic assembly, but if anything it just demonstrates the issue even better.

I tested this on my home machine - which is a fair bit faster than my work machine, so the results would be even worse there - with a completely fresh install of VS2015 Enterprise. Here are the results when I try to EnC some code in one of the generated classes:
pre:
VS2013
Start editing code: immediate
Apply changes: 4 seconds

VS2015
Start editing code: 63 seconds on first edit, afterwards immediate
Apply changes: 1 second
During those 63 seconds VS is completely unresponsive and pegs one core on 100%. There doesn't seem to be any significant disk or memory activity. In a PerfView ETL trace it looked like VS is performing a Roslyn(?) parse of the entire assembly source code, but then again I'm far from competent at interpreting those traces; stuff like for example OTHER <<mscorlib.ni!System.Runtime.CompilerServices.AsyncMethodBuilderCore+ContinuationWrapper.Invoke()>> shows up, so I think it's a reasonable guess.

Note that removing the class coupling entirely significantly speeds this up (about 3 seconds to start editing), but then again a completely flat hierarchy wouldn't exactly be a realistic test. Reducing the project to "only" 1000 classes (half LOC + size) also significantly reduces the delay down to a mere 10 seconds, which is closer to the hang times I'm seeing on my work machine with our actual project. It does suggest that there are some areas in the code parser that have algorithmic complexity issues, seeing how doubling the amount of classes produces six times longer hangs.

Incidentally, if I regenerate those 2000 classes while VS is open, VS2013 will immediately detect the changes and ask to reload, whereas VS2015 will reproducibly hang (presumably for 63ish seconds) before it does anything - though I didn't wait it out but force killed the process instead.

In general it seems VS2015 has a lot more operations tied to some background compilation/parsing process that, if it takes long to complete, will freeze the entire UI. I believe this may also be the cause for the hanging issues I have with the New Project respectively Extensions and Updates dialogs, as both work fine without a project loaded, but hang when I first open our main project. Once the hang resolves, opening the dialog again works as it should, which is similar behavior as seen with EnC.

In fact, let me just try this right now... YES, the New Project dialog also hangs on my home machine with the large generated project opened. So I think that one's confirmed too.

Now, I'm not saying it is desirable to have such large assemblies in the first place, but the reality of the matter is that it does happen and that VS2013 deals with it without complaint, whereas '15 chokes and dies. Though looking at the problem also seems to suggest a common source, so maybe a single fix is all that's needed to squash a wide array of performance issues. Doesn't mean that the fix will be easy, though.

@ljw1004: I'll send you the details and repro code Monday morning (CET).

ljw1004
Jan 18, 2005

rum

SirViver posted:

HA, I found the bug! ... On a hunch I decided to make sure the assembly properties are equal between the both and suddenly I could reproduce the error even with the new class library. Turns out if you use an auto-generated assembly version number EnC breaks member references to types defined in that assembly.

SirVivier, thanks for the clean and simple bug report. I took the liberty of filing it on github: https://github.com/dotnet/roslyn/issues/4575. (Edit: wow, more of the compiler devs are piling on. Looks like auto-generated assembly versions have wider implications.)

The main EnC dev seems to have a fix for it, under testing. If he fixes it now then I guess it will get into the next VS2015 update.



Edit: Thanks also for investigating the slowness. We did perf tests on projects as big as yours but we generally tried to do it on "real-world" projects rather than synthesized assemblies. Maybe our test suites were off. I look forward to your email on Monday and we'll chat further.

ljw1004 fucked around with this message at 00:28 on Aug 16, 2015

Boz0r
Sep 7, 2006
The Rocketship in action.
I'm making a boardgame in C#, and I have the following function to reset the board:

code:
        public void ResetBoard()
        {
            GameTiles = new IGameTile[BoardWidth, BoardHeight];

            for (int y = 0; y < BoardHeight; y++)
            {
                for (int x = 0; x < BoardWidth; x++)
                {
                    GameTiles[x,y] = new OpenTile();
                }
            }
        }
I'd like to move the tile type to a parameter, so I can reset the board to an arbitrary tile type. How do I do this?

Kekekela
Oct 28, 2004
The two ways I see are with a generic method:

code:
	public void ResetBoard<TTile>() where TTile : new(){
		...
		GameTiles[x,y] = new TTile();
		...
	}
Or I guess exactly what you asked for :downs: , passing in a param
code:
	public void ResetBoard(Type t) {
		...
		GameTiles[x,y] = Activator.CreateInstance(t);
		...
	}
Apologies for any syntax errors, I'm on my mac but that should be the gist.


e:
to call the first one:
code:
	foo.ResetBoard<OpenTile>();
to call the second one:
code:
	foo.ResetBoard(typeof(OpenTile));

Kekekela fucked around with this message at 02:02 on Aug 17, 2015

Nth Doctor
Sep 7, 2010

Darkrai used Dream Eater!
It's super effective!


Boz0r posted:

I'm making a boardgame in C#, and I have the following function to reset the board:

code:
GameTiles = new IGameTile[BoardWidth, BoardHeight];

You can call a constructor on an interface? :confused:
Is there some activation-chicanery going on or did the actual class get anonymized away?

Gul Banana
Nov 28, 2003

RICHUNCLEPENNYBAGS posted:

I've got some code that tries to start up a new app domain, then load an assembly (whose path is passed in by string), then reflect over it, then dispose of the app domain, but it fails to load the specified DLL because of dependency issues. I have to admit I don't know a lot about AppDomains and assembly loading so I'm not sure where to start looking for the issue. Ideas?

if you use Assembly.LoadXXX methods which take a file argument, they won't automatically resolve dependencies. the methods which take an assembly *name* will look it up (and its dependencies) by the normal resolution mechanisms.
you may also be able to use Assembly.ReflectionOnlyLoad().

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

Nth Doctor posted:

You can call a constructor on an interface? :confused:
Is there some activation-chicanery going on or did the actual class get anonymized away?

It's a new instance of array, set to default(IFoo) iirc.

Kekekela
Oct 28, 2004

Nth Doctor posted:

You can call a constructor on an interface? :confused:
Is there some activation-chicanery going on or did the actual class get anonymized away?

He's initializing a multidimensional array.

Nth Doctor
Sep 7, 2010

Darkrai used Dream Eater!
It's super effective!


dougdrums posted:

It's a new instance of array, set to default(IFoo) iirc.


Kekekela posted:

He's initializing a multidimensional array.

Christ. Of course.
That will teach me to read C# before coffee.

triple sulk
Sep 17, 2014



Wrong thread, oops.

RICHUNCLEPENNYBAGS
Dec 21, 2010

Gul Banana posted:

if you use Assembly.LoadXXX methods which take a file argument, they won't automatically resolve dependencies. the methods which take an assembly *name* will look it up (and its dependencies) by the normal resolution mechanisms.
you may also be able to use Assembly.ReflectionOnlyLoad().

My program exists to reflect over arbitrary assemblies... how can I deal with resolving dependencies? I think I can pretty much assume the dependencies are always in the same directory as the assembly I'm reflecting over.

I don't think ReflectionOnlyLoad will work because I need to reflect into the depndencies to get some classes.

It seemed like it might work to switch to LoadFrom from LoadFile (it worked in a test), but then it didn't work in the actual program. >:[

RICHUNCLEPENNYBAGS fucked around with this message at 16:45 on Aug 16, 2015

ljw1004
Jan 18, 2005

rum

RICHUNCLEPENNYBAGS posted:

My program exists to reflect over arbitrary assemblies... how can I deal with resolving dependencies? I think I can pretty much assume the dependencies are always in the same directory as the assembly I'm reflecting over.

The answer depends a lot on what you're aiming to do.

The thing is, Assembly.Load is kind of heavyweight. It really means getting the CLR to load the assembly and do all its stuff. If you merely need metadata from the assembly, you might consider either CCI, or the newly released System.Reflection.Metadata (you can get it via NuGet) which is what the Roslyn compilers themselves use to read metadata.

Here's some code I wrote that uses System.Reflection.Metadata to read all the assemblies in an appx package, and enumerate all their types:
https://github.com/ljw1004/blog/blob/master/Appx/AnalyseAppxFiles/Module1.vb
code:
Using pereader As New Reflection.PortableExecutable.PEReader(stream)
   Dim assembly = Reflection.Metadata.PEReaderExtensions.GetMetadataReader(pereader)
   For Each typeDefHandle In assembly.TypeDefinitions
      Dim typeDef = assembly.GetTypeDefinition(typeDefHandle)
      Dim typeName = assembly.GetString(typeDef.Name)
   Next
End Using
You can see that System.Reflection.Metadata is pretty lightweight - it doesn't dig into the metadata any more than you explicitly ask it to. That's because the VB/C# compilers need to be able to read in metadata as efficiently as possible.


Of course, if your code actually requires things to be properly resolved, then this lightweight approach won't help you as much since you'd have to resolve them yourself.

RICHUNCLEPENNYBAGS
Dec 21, 2010
I already have the code written that works with the regular Assembly class so really I'm trying to retro-fit it so it doesn't lock the file.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
I'm trying to find resources on developing an OAuth 2.0 service provider and coming up short. Everything seems to be geared around the client side of things but where can I find some kind of guide for developing the server side? So I want people to be able to use OAuth 2.0 to authenticate with our user database. Has anyone done anything like this? Any resources you can point me to?

RICHUNCLEPENNYBAGS
Dec 21, 2010

The Wizard of Poz posted:

I'm trying to find resources on developing an OAuth 2.0 service provider and coming up short. Everything seems to be geared around the client side of things but where can I find some kind of guide for developing the server side? So I want people to be able to use OAuth 2.0 to authenticate with our user database. Has anyone done anything like this? Any resources you can point me to?

Never done it but I've heard of Dotnetopenauth which seems to support both. http://dotnetopenauth.net/

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

RICHUNCLEPENNYBAGS posted:

Never done it but I've heard of Dotnetopenauth which seems to support both. http://dotnetopenauth.net/

I came across that but I can't find any documentation whatsoever to support the theory that it can be used to build an OAuth 2.0 server. This is the frustration I keep encountering, it seems like no one in the world is interested in building their own OAuth server, they're only interested in talking to existing OAuth servers like Google and Facebook etc.

RICHUNCLEPENNYBAGS
Dec 21, 2010

The Wizard of Poz posted:

I came across that but I can't find any documentation whatsoever to support the theory that it can be used to build an OAuth 2.0 server. This is the frustration I keep encountering, it seems like no one in the world is interested in building their own OAuth server, they're only interested in talking to existing OAuth servers like Google and Facebook etc.

Here you go.

Adbot
ADBOT LOVES YOU

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

Open ID is not the same as OAuth 2.0.

Edit: and even if it were, the documentation on same is virtually non-existent.

putin is a cunt fucked around with this message at 04:55 on Aug 17, 2015

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