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
Night Shade
Jan 13, 2013

Old School

LongSack posted:

I could not, for the life of me, figure out how to use the dictionary’s existing GetEnumerator() to do so. The compiler kept complaining that it couldn’t convert from Dictionary<string,object>.IEnumerator to IEnumerator<Dictionary<string, object>>.

Dictionary<string, object>.Enumerator is IEnumerator<KeyValuePair<string, object>>, not IEnumerator<Dictionary<string, object>>. It enumerates the contents of a single dictionary, whereas an IEnumerator<Dictionary<string, object>> enumerates multiple dictionaries.

Adbot
ADBOT LOVES YOU

Sab669
Sep 24, 2009

I have an application which uses ASP MVC / Razor. I need to add a reference to a DLL we created. Our DLL references newer versions of System.Web.Mvc, System.Web.Razor, System.Web.WebPages, and System.Web.WebPages.Razor

This caused a few issues; I forget the exact error but it was something to the effect of "Reference uses newer versions of other references this project already uses". All I had to do was delete a bunch of those System.Web.* references and re-add them so that it's using the same version as what our DLL uses.

Now I can build and run the application locally. Great!

So I push our DLL, all the System.Web.* DLLs I had to update in the project, and the DLL for this application itself to the web server.

If I try to navigate to the site, I get this error:

quote:

[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection.

Type A originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'.

Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\udsmr.acutefim\e0423e3a\dbc1cb16\assembly\dl3\483af11f\00ba4c26_4e0cd101\System.Web.WebPages.Razor.dll'.

I sort of understand what it's telling me; there's a version error in the DLLs used. But I don't understand why because I can run it locally. I pushed all the relevant DLLs to the server.

It sounds like I just need to update the GAC with v3.0 of the DLL but frankly I (and my boss) am a little reluctant to find out what the repercussions of that might be? We have other, more important, products which also rely on all the MVC DLLs.

Sab669 fucked around with this message at 14:17 on Oct 12, 2018

LongSack
Jan 17, 2003

mystes posted:

What do you mean when you say you want it to be "IEnumerator<Dictionary<string, object>>"? That would enumerate over dictionaries which doesn't make any sense.

If you want IEnumerator<KeyValuePair<string, object>> can't you just cast the return value of GetEnumerator() to that?

Night Shade posted:

Dictionary<string, object>.Enumerator is IEnumerator<KeyValuePair<string, object>>, not IEnumerator<Dictionary<string, object>>. It enumerates the contents of a single dictionary, whereas an IEnumerator<Dictionary<string, object>> enumerates multiple dictionaries.

Ahh ok that makes sense. Thanks!

Mr Shiny Pants
Nov 12, 2012

Sab669 posted:

I have an application which uses ASP MVC / Razor. I need to add a reference to a DLL we created. Our DLL references newer versions of System.Web.Mvc, System.Web.Razor, System.Web.WebPages, and System.Web.WebPages.Razor

This caused a few issues; I forget the exact error but it was something to the effect of "Reference uses newer versions of other references this project already uses". All I had to do was delete a bunch of those System.Web.* references and re-add them so that it's using the same version as what our DLL uses.

Now I can build and run the application locally. Great!

So I push our DLL, all the System.Web.* DLLs I had to update in the project, and the DLL for this application itself to the web server.

If I try to navigate to the site, I get this error:


I sort of understand what it's telling me; there's a version error in the DLLs used. But I don't understand why because I can run it locally. I pushed all the relevant DLLs to the server.

It sounds like I just need to update the GAC with v3.0 of the DLL but frankly I (and my boss) am a little reluctant to find out what the repercussions of that might be? We have other, more important, products which also rely on all the MVC DLLs.

.Net core? You can add a local DLL and it will use that instead of the GAC one.

Don't know if this also works on Windows, but on Linux you can use the following: https://github.com/dotnet/core/blob/master/Documentation/self-contained-linux-apps.md

EssOEss
Oct 23, 2006
128-bit approved

Sab669 posted:

"Reference uses newer versions of other references this project already uses". All I had to do was delete a bunch of those System.Web.* references and re-add them so that it's using the same version as what our DLL uses.

This raises all sorts of questions about how exactly your dependency management is organized and whether it is sane.

However, the fix with .NET Framework is pretty universal: define some assembly binding redirects. Basically, you just tell .NET Framework "whenever someone asks for XYZ.dll version 0.0.0.0-1.2.3.4 always use 1.2.3.4".

Naturally, it only works if the assembly 1.2.3.4 is actually backward compatible but as long as it is a Microsoft assembly, you are pretty safe in assuming that.

Why I wonder about your dependency management is that in many cases, the binding redirects get added automatically these days, at least if you are using latest Visual Studio. Granted, the Microsoft SDKs tend to be buggy as hell when dealing with assembly versioning and packaging, so I am not surprised to hear some things do not work out of the box. Try manually redirecting the assemblies you need.

B-Nasty
May 25, 2005

EssOEss posted:

However, the fix with .NET Framework is pretty universal: define some assembly binding redirects. Basically, you just tell .NET Framework "whenever someone asks for XYZ.dll version 0.0.0.0-1.2.3.4 always use 1.2.3.4".

Also known as the Newtonsoft Json.NET workaround, since every package on earth has a dependency on some version of this rapidly iterated package.

Magnetic North
Dec 15, 2008

Beware the Forest's Mushrooms
Cross posting with the questions thread, as this is a squirrely .NET question.

Magnetic North posted:

So this is a bit of a weird one. I am using C# in Visual Studio 2015. Does anyone know how one could subscribe to an event listener that is a member of a dynamic object that was created through late binding? And/or how to create a method that has a parameter of a type that is only known to an assembly loaded late?

For background: I am trying to do some late binding by dynamically loading a dll file. I made my objects 'dynamic' rather than members of the specific class, used Assembly.LoadFile() to grab the dll. Then I called .GetTypes() and used LINQ to look up the specific type I wanted. Finally, I called Activator.CreateInstance(type, parameters[]) to instantiate them. As far as I can tell, that all worked, in the sense that when I look at the object, it says the type is what I expect.

The part I haven't yet been able to figure out is properly populating an event listener. (Sorry, my event listener fu is weak; I don't know if 'populate' or 'subscribe' or whatever is the right term.) The main problem is that the event raises (returns?) an object type that is known to the dll but not to my class. So I can't just create the method like normal:
code:
private void Listener_ThatsMyEvent(object sender, UnknownObjectType ItsAMystery)
{
    ItsAMystery.MysteryMethod();
}
...since my class doesn't know what UnknownObjectType is. I have seen stuff about MethodInfo objects, but I haven't been able to find a way to create a brand-spanking new method 'object' all on its own. I suspect delegates are the key, but I am bad at this and forgot everything about delegates the last time I needed them 9 months ago.

The other side of the problem is that I can't actually do the subscribing, as if you go:
code:
Listener += Listener_ThatsMyEvent
... it complains that it cannot use a method group as an argument to a dynamically dispatched operator. Contextually, this makes me think that this limitation is normal. I tried making it an 'object' but that just seemed to behave as its own overload (nothing hit my breakpoint). I know I can get the Listener type and get the AddMethod MethodInfo out of it, but the next step has eluded me. I was trying to find what is the non-syntactic sugar version of "+=" in that context to see if I could make it work from there, but didn't find it. Maybe it is just 'AddMethod'?

I hope that is enough information to start with. I've been staring at this for a few days now, so my sense of what is normal and not is a bit skewed.

amotea
Mar 23, 2008
Grimey Drawer
Is anyone else experiencing problems with the VS2017 C# debugger? It often won't let me inspect variables or properties of class instances, i.e. they just show up empty in the watch window or VS goes in an 'evaluating expression' loading loop or 'The debugger is unable to evaluate this expression'.

These issues started like a year ago.

Ape Fist
Feb 23, 2007

Nowadays, you can do anything that you want; anal, oral, fisting, but you need to be wearing gloves, condoms, protection.
So I've started a front-end job with a company that uses MVC 5 and something called Episerver.

I'm Angular dev, but we don't really do many SPA's because we're using MVC, and while no one has asked me to learn anything to do with .NET, I hate being completely ignorant about a part of the stack I'm working on so I'm doing a Udemy course on MVC 5, not even Core, and I just want to say I think MVC 5 owns, and C# owns, and one day I'll do a Core course as well just to do something more modern but still. It's dope and I love it and its cool and I just wanted to say that. You can also really see how MicroSoft were thinking when they created TypeScript because its clearly inspired, I think, by C#.

mystes
May 31, 2006

Has anyone used System.Speech.Synthesis.SpeechSynthesizer and if so have you noticed it getting louder if you pause and then resume?

Shy
Mar 20, 2010

Ape Fist posted:

You can also really see how MicroSoft were thinking when they created TypeScript because its clearly inspired, I think, by C#.

It's even made by the same person!

chglcu
May 17, 2007

I'm so bored with the USA.

amotea posted:

Is anyone else experiencing problems with the VS2017 C# debugger? It often won't let me inspect variables or properties of class instances, i.e. they just show up empty in the watch window or VS goes in an 'evaluating expression' loading loop or 'The debugger is unable to evaluate this expression'.

These issues started like a year ago.

I have this happen somewhat often when debugging Unity stuff. I had assumed it was related to using the Unity debugger, but haven't really done much non-Unity C# development recently, so it could be more widespread. I also pretty frequently run into the debugger UI just not refreshing until the window is resized. Restarting Visual Studio usually clears that one up.

downout
Jul 6, 2009

amotea posted:

Is anyone else experiencing problems with the VS2017 C# debugger? It often won't let me inspect variables or properties of class instances, i.e. they just show up empty in the watch window or VS goes in an 'evaluating expression' loading loop or 'The debugger is unable to evaluate this expression'.

These issues started like a year ago.

Ive recently switched to a project in vs2017, and ive had a similar experience. My mvc application causes the browser to think the application is unresponsive while the debugger churns through a minor variable. I was wondering if it was the project, but this makes it sound like a more general issue. Probably some random debugging option in vs needs disabled or something

Munkeymon
Aug 14, 2003

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



Magnetic North posted:

Cross posting with the questions thread, as this is a squirrely .NET question.

Have you read https://docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/how-to-hook-up-a-delegate-using-reflection ?

amotea posted:

Is anyone else experiencing problems with the VS2017 C# debugger? It often won't let me inspect variables or properties of class instances, i.e. they just show up empty in the watch window or VS goes in an 'evaluating expression' loading loop or 'The debugger is unable to evaluate this expression'.

These issues started like a year ago.

This kind of thing happens to me when there's a lot of system memory pressure (as in getting near 150% of physical RAM) or if there's a DLL mismatch. If it's happening consistently, I'd guess it's the former unless you're doing a lot of Forms custom control development which IME tends to get a lot of DLLs stuck in the GAC, but I haven't done that since 2012 (year and VS version).

LongSack
Jan 17, 2003

This is more of a VS question, rather than strictly .NET, but I’m hoping someone can help me with this.

Working on a fancy replacement for MessageBox which is completely customizable, from the window icon, to the text in the buttons, whatever. But I want to provide some defaults. I am using pack URI’s to pull the images from the library assembly rather than the calling assembly.

But it wasn’t working. Each button image and the main icon threw an exception, the root of which was an IOException saying the resource couldn’t be located. After struggling with it for way too long (I was close to abandoning the project), I did a clean and a build. And I got an error message from my test app build that said the library couldn’t be located. Aha! It’s building them in the wrong order. So I added a dependency in the test app to the library and rebuilt. Presto - everything worked. Suddenly with no other change the images loaded.

I’m curious what’s the difference of merely adding the library to the test app’s references versus doing that and adding the dependency. Why did that make so much difference? In this case, both assemblies are in the same solution, rather than my normal usage of the library from a separate solution.

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

Ape Fist posted:

So I've started a front-end job with a company that uses MVC 5 and something called Episerver.

I'm Angular dev, but we don't really do many SPA's because we're using MVC, and while no one has asked me to learn anything to do with .NET, I hate being completely ignorant about a part of the stack I'm working on so I'm doing a Udemy course on MVC 5, not even Core, and I just want to say I think MVC 5 owns, and C# owns, and one day I'll do a Core course as well just to do something more modern but still. It's dope and I love it and its cool and I just wanted to say that. You can also really see how MicroSoft were thinking when they created TypeScript because its clearly inspired, I think, by C#.

I remember my first C# experience after working entirely in PHP. Man did I enjoy C# then, and I still love it now. Also good work on making the frontend/backend jump! Too many people (backend AND frontend devs alike) refuse to touch code outside of their comfort zone.

amotea
Mar 23, 2008
Grimey Drawer
The current problems I was having with the debugger were probably caused by this mess: https://github.com/dotnet/standard/issues/481

I have a .NET 4.6.1 unit test project that uses some fancy testing libraries that have a dependency on netstandard something something .NET Core 2 Netstandard 1.6 Desktop Targeting Pack PCL DNX and the thing crashes with a missing System.Runtime.dll dependency which I shouldn't need.

The takeaway seems to be: only use the new Core/Netstandard stuff if you are on .NET 4.7.x.

EssOEss
Oct 23, 2006
128-bit approved
At least 4.7.1 still has idiotic issues with Microsoft assemblies like System.Runtime not loading.

Naturally, Microsoft closes the issue because you can hack around it by modifying your project file and using non-default settings or whatever the gently caress that is.

I find hilarious the Rider developer who is also a BenchmarkDotNet developer saying "just use Rider". If Rider can unfuck Microsoft's dependency mess, it might actually have a case to make!

Scikar
Nov 20, 2005

5? Seriously?

How often does upgrading .NET version actually break things in code? It feels to me like 95% of the problems you can run into are things like this where the tooling ends up linking the wrong assemblies. But that complicated tooling only seems to exist in the first place to try to make things backwards compatible with previous attempts to deal with DLL hell. I'm trying to think what would be the biggest problem if there was a hard cutoff with Standard 2.0 and Framework 4.7, and the main one I can come up with is projects that depend on abandoned libraries where the only NuGet packages available are targeting something older. But then people shouldn't be using abandoned libraries that aren't getting security updates so...

EssOEss
Oct 23, 2006
128-bit approved
Yeah, overengineered dependency management is 90% of this hell. Microsoft really messed it up for a few years and we all have to suffer the fallout for a long time to come.

I look back on the "drop a DLL file into the lib directory" days with yearning.

amotea
Mar 23, 2008
Grimey Drawer

Scikar posted:

How often does upgrading .NET version actually break things in code? It feels to me like 95% of the problems you can run into are things like this where the tooling ends up linking the wrong assemblies. But that complicated tooling only seems to exist in the first place to try to make things backwards compatible with previous attempts to deal with DLL hell. I'm trying to think what would be the biggest problem if there was a hard cutoff with Standard 2.0 and Framework 4.7, and the main one I can come up with is projects that depend on abandoned libraries where the only NuGet packages available are targeting something older. But then people shouldn't be using abandoned libraries that aren't getting security updates so...

I agree, but at the same time I'm working with vendor libraries (non-.NET) that are 13+ years old.

Another example: some customers were still running Windows XP only 2 years ago.

amotea
Mar 23, 2008
Grimey Drawer

EssOEss posted:

Yeah, overengineered dependency management is 90% of this hell. Microsoft really messed it up for a few years and we all have to suffer the fallout for a long time to come.

I look back on the "drop a DLL file into the lib directory" days with yearning.

It also seems NuGet is getting some secret magic fixes/workarounds for .NET eco-system issues now and then, while Paket sort of has to figure things out on its own. Kind of lovely, since Paket was the only viable way of managing dependencies for 1-2 years when NuGet was terrible.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Scikar posted:

How often does upgrading .NET version actually break things in code?

Almost never, but when it does, it sucks.

It's usually your own fault (e.g. relying on implementation-specific behavior that's not guaranteed), or a well-documented breaking change that people ignore and then complain about. But there have been legit nasty bugs that have slipped by Microsoft.

Munkeymon
Aug 14, 2003

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



LongSack posted:

This is more of a VS question, rather than strictly .NET, but I’m hoping someone can help me with this.

Working on a fancy replacement for MessageBox which is completely customizable, from the window icon, to the text in the buttons, whatever. But I want to provide some defaults. I am using pack URI’s to pull the images from the library assembly rather than the calling assembly.

But it wasn’t working. Each button image and the main icon threw an exception, the root of which was an IOException saying the resource couldn’t be located. After struggling with it for way too long (I was close to abandoning the project), I did a clean and a build. And I got an error message from my test app build that said the library couldn’t be located. Aha! It’s building them in the wrong order. So I added a dependency in the test app to the library and rebuilt. Presto - everything worked. Suddenly with no other change the images loaded.

I’m curious what’s the difference of merely adding the library to the test app’s references versus doing that and adding the dependency. Why did that make so much difference? In this case, both assemblies are in the same solution, rather than my normal usage of the library from a separate solution.

I don't understand the distinction you're making between a 'reference' and a 'dependency' here and maybe I'm not the only one?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Munkeymon posted:

I don't understand the distinction you're making between a 'reference' and a 'dependency' here and maybe I'm not the only one?

I think he's referring to a project reference vs a direct assembly reference.

Mr Shiny Pants
Nov 12, 2012

New Yorp New Yorp posted:

Almost never, but when it does, it sucks.

It's usually your own fault (e.g. relying on implementation-specific behavior that's not guaranteed), or a well-documented breaking change that people ignore and then complain about. But there have been legit nasty bugs that have slipped by Microsoft.

It should not be this complicated in the first place, dependency hell in TYOOL 2018 is just stupid. Especially when it was better in the past. Which framework do you target? Do we have it installed? Great we'll use that.

I have never from 2010 onward had as many stupid things that needed fixing by editing a csproj or an fsproj than in the last couple of years since the whole netstandard shitshow started happening.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Mr Shiny Pants posted:

It should not be this complicated in the first place, dependency hell in TYOOL 2018 is just stupid. Especially when it was better in the past. Which framework do you target? Do we have it installed? Great we'll use that.

I have never from 2010 onward had as many stupid things that needed fixing by editing a csproj or an fsproj than in the last couple of years since the whole netstandard shitshow started happening.

No, I totally agree. They decided to replicate the worst part of the node ecosystem.

Mr Shiny Pants
Nov 12, 2012

New Yorp New Yorp posted:

No, I totally agree. They decided to replicate the worst part of the node ecosystem.

Don't get me started on the "let's make System.Text a separate download, you guys like modules right?"

Ugh.

Collateral Damage
Jun 13, 2009

amotea posted:

I agree, but at the same time I'm working with vendor libraries (non-.NET) that are 13+ years old.

Another example: some customers were still running Windows XP only 2 years ago.
And the reason you have to deal with that bullshit is because Microsoft allows people to get away with it. Allowing software to be backwards compatible forever makes people lazy. "Why should we upgrade as long as it works*?"

(*) because IT keeps giving it digital CPR and hamstringing development in other areas to cater to the application.

When Apple switched from PowerPC to x86 they included PPC emulation but clearly told everyone that it was a stopgap measure and would go away. Then they dropped PowerPC support like a hot potato and people just had to loving deal with it. They've also announced ending support for x86 soon. Microsoft at the very least needs to do the same for obsolete versions of NET.

Munkeymon
Aug 14, 2003

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



"Hey Microsoft, you need to lose a bunch of enterprise business for my comfort!"

"Why are you laughing? This is important!"

Shy
Mar 20, 2010

Yeah apple can drop support left and right because no one runs important software on it.

Mr Shiny Pants
Nov 12, 2012
Apple is not the greatest example, but the way MS handled the whole netstandard/.net/net core stuff is pretty lousy.

amotea
Mar 23, 2008
Grimey Drawer

Mr Shiny Pants posted:

Don't get me started on the "let's make System.Text a separate download, you guys like modules right?"

Ugh.

I may have news, I read this while crawling Github for bits and pieces:

quote:

With respect to the OP comment. Those DLLs are no longer distributed via nuget. NuGet dependencies for framework components/netstandard had too many issues. We've gone back to the "inbox" model where 4.7.1 has reabsorbed all these DLLs back into the framework. You'll find the reference dlls provided by the targeting pack, just like any other inbox dll. The implementations will available in the GAC. It is by design that we'll ignore the package versions and unify to the targeting-pack version. Those DLLs are no longer distributed via NuGet.
https://github.com/dotnet/corefx/issues/31536#issuecomment-409643768

I think this is about what you're referring to, but who knows.

mystes
May 31, 2006

Good, I think they had gone a bit overboard.

Scikar
Nov 20, 2005

5? Seriously?

I don't think MS should immediately give up on backwards compatibility, but it should be more visible when it happens. Compare the way that Chrome is moving towards labelling sites as Not Secure when they don't run TLS but you can still access them, whereas when MS finally took steps to stop applications from writing to Program Files (which they told developers not to do from day 1), they just silently and unreliably redirected to the rear end end of the file system, instead of popping some kind of "this application is doing something really dumb and if you haven't spent any money on it yet don't sign a contract unless you like working with poo poo software" warning.

mystes
May 31, 2006

Scikar posted:

I don't think MS should immediately give up on backwards compatibility, but it should be more visible when it happens. Compare the way that Chrome is moving towards labelling sites as Not Secure when they don't run TLS but you can still access them, whereas when MS finally took steps to stop applications from writing to Program Files (which they told developers not to do from day 1), they just silently and unreliably redirected to the rear end end of the file system, instead of popping some kind of "this application is doing something really dumb and if you haven't spent any money on it yet don't sign a contract unless you like working with poo poo software" warning.
This was the idea behind making UAC really annoying in Vista (prompting developers to fix their software) but it wasn't received too well by the general public.

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

EssOEss posted:

At least 4.7.1 still has idiotic issues with Microsoft assemblies like System.Runtime not loading.

Naturally, Microsoft closes the issue because you can hack around it by modifying your project file and using non-default settings or whatever the gently caress that is.

I find hilarious the Rider developer who is also a BenchmarkDotNet developer saying "just use Rider". If Rider can unfuck Microsoft's dependency mess, it might actually have a case to make!

I gave Rider a try for a little bit and regretted it and went right back to VS + ReSharper (with VS Code for quick changes).

Ireland Sucks
May 16, 2004

I have a C++ Win32 program that processes lots of data as it is generated and renders it as pretty graphs. I want to port it to .NET Core because writing and distributing C++ for multiple platforms is just hateful, I need it to run on Linux and quite enjoy C#. I hoped to take advantage of the rewrite by redoing the GUI as a fancy Javascript thing because i'd like it to make it more modular/extendable (eg: allow people to write their own renderers/workers) and that seems like a good way of getting around the relative immaturity of cross-platform GUI offerings for Core. The only thing I can see that might meet the requirements is Electron .NET. The examples I've seen look a lot prettier than Qt (which I'd be moving away from) but

A: it's .NET running in Electron, so it needs separate distributions for each OS (I guess I can deal with that, still easier than C++)

B: everyone here seems to think that Electron is not only the worst thing that has ever happened to programming but is also horribly slow - which will probably hurt a lot bearing in mind the existing performance hit from going from native binaries to JIT.

Are there any better alternatives? Am I just trying to do something which is a bad idea? If that fails - is Qt relatively usable for Core?

thanks!

LongSack
Jan 17, 2003

Munkeymon posted:

I don't understand the distinction you're making between a 'reference' and a 'dependency' here and maybe I'm not the only one?

One is right-clicking on References and choosing “Add a Reference” and picking the DLL. This is what I do when referencing my library from a different solution.

What apparently fixed my problem is an additional step that I took which was right-clicking on my test project there’s an option somewhere in there to add a dependency. This option doesn’t appear if there is only one project in the solution. Adding the dependency in addition to adding the reference (which is required to use the library at all) is what seemed to fix my problem with pack uris.

Adbot
ADBOT LOVES YOU

SirViver
Oct 22, 2008
The issue arises because you use a DLL/assembly reference to the output of a project in your solution instead of using a project reference - without explicitly telling VS that there is a dependency it doesn't know that the project happens to generate the referenced DLL*. The consequence of this is that VS will happily compile both projects in parallel instead of the actual required build order, resulting in a race condition of whether the referenced DLL will still (or already) exist when the referencing project is built.

Usually this results in weird build errors where a namespace that clearly exists cannot be found during compilation or where a DLL mysteriously cannot be copied to the output folder. I guess the Pack URI mechanism needs to access the source assemblies at some point during compilation and silently fails if it can't, resulting in broken resource images.

* Technically it likely could deduce that is the case, but honestly it's probably better it doesn't. Unless such heuristics are rock solid they just lead to random issues or broken behavior in edge cases. At most I'd have VS generate a clippy-like notification that it detected this case and whether to fix it, but not automagically assume stuff behind the scenes.

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