Posts

FINALLY remove unused reference is here

 i normally do not check release notes, but something pushed me to do it this time when i was about to upgrade to Visual Studio version 16.10.4, and I FOUND THIS ! Although the screen shot doesn't till what type of reference this would handle, is it only limited to NuGet packages? dose it extend to directly referenced DLLs (yes some folks still do that!) Framework files? Anyway i am existed to try this out and will update this with any findings i feel worth to share, so stay tuned! UPDATE: i am very disappointed, it's marking needed referenced projects and packages as not needed!, like i have it in a using for a class, and it's in bright white because it's used, and i can see it's being used, still it get in as unused reference, while other projects i get a message that there isn't any unused references! hope Microsoft fix this, it's really a neat feature specially for Blazor WASM , where every mb count

Visual Studio, Blazor WASM, and Docker

 So as usual my attempts to create something take to places where i find things do not work the way i wanted, then i find myself searching for a way to get things to work i want them, and in this case it might be the way a lot of people want to. last weekend i wanted to explore how easy or hard to containerize / Dockrize a .NET5 back-end, Blazor WASM front-end app. for the back-end things were super easy, just right click, add docker support, add containers orchestration and all was working, running, and debugging according to plan. Now when i tried to do the same for a Blazor WASM project things got a it ugly, seems like Visual Studio generate these according to project type, and i guess it saw the Blazor WASM as another .NET hosted web app, which is and is not quite! See Blazor WASM are entirely client side running, the server is there to just provide files but no process occur at the server, so technically you can host a Blazor WASM app on any web server (like Nginx) without the nee

Simple PayPal page with Vue

So, i needed to create a pay page for my company site www.upwardinfo.com. i choose to go with PayPal buttons on an HTML page, simple and fast. but i needed more, so it thought why shouldn’t i hook PayPal buttons to a simple Vue can’t app, and do some URL parameters that can be intercepted by JS (yes you can so that!). The idea was simple, have an HTML and JS script you can host anywhere, and the page should be able to have two URL parameters for a description /name and amount to be paid, if those values did not exist an input field should be available for user input, and as I have Vue why not do some validations as well. If you want to take a look on the code and use it on your page visit this code repo.

Blazor how to generate that SHA256 check

So ... I see that Balzor + .NET 5 (where did Core go?!!) is now do have what i want to get my things running but of course as always something was missing, see Blazor lazy loading is just the thing i was looking for but it doesn’t work unless i reference the module/razor component library on the main project, which i exactly what is don't want. Fortunately this time everything was kind of there, just a bit trouble to do myself. See if you create a client side Razor app, you get blazor.boot.json file generated and on that file you get lazyAssembly entry which supposed to make browsers only get these assemblies if needed (can't see this working on Firefox or Chrome but that's another story), and if you list your assembly there and follow instructions in here magic happen and the page you created on your razor component library works! But, first you need to be able to calculate that sha256 value for your assembly! Which at first i couldn’t figure out how, but then found this

EF Core two data models on two separate projects / dlls with a relationship

Again stuck on my learn / dream project WorkNxt , what i though is a very simple task turn out to be a bit tricky. as i am trying to separate each module and load things at runtime and use DI, i encountered a problem that one of the data models i created under one module need to have EF relationship with another data model on another module, each of course was on a separate project / dll. ideally i didn't want to reference the other module project but to make things even more difficult this was one-to-one relationship and i needed it from both sides and i needed to use it on a ThenInclude as i want to include data from one of the models on the results of the other one. So even if i was ok with cross modules reference which i was trying to avoid i will fall for circular reference trap as you would need to use each class on the other to create the relationship. After many hours of banging my head against the wall, and trying a couple of suggestions from EF core team through the issu

Tabulator on Bootstrap tab

As i was going on my project WorkNxt , i found a new interesting problem. i mean this one of the main reasons i started this anyway, is to find and solve interesting problems!  i am using Tabulator and Bootstrap along with other JS and CSS libraries on this project, and what i wanted was very simple, to have a bootstrap tab navigator with two tabs each with a Tabulator table on it. Simple?, not really, see what i found out is for some reason Tabulator might have trouble rendering in a Div with css display set to none, which is exactly the not shown yet tab(s) would be. How did i resolve this, and i would dare to say it's a very good solution, is the little JS script below function redrawTable() { tabulatorTable.redraw(); $('#detials-tab a[href="#TargetTab"]').unbind('shown.bs.tab', redrawTable); } $('#detials-tab a[href="#TargetTab"]').on('shown.bs.tab', redrawTable);

How to load a DLL and runtime, invoke a method my name, get result object and use it as a parameter on another unkown DLL .NET Core

That post title took me a while to come up with, but my idea is pretty simple, what id you need sort of a bootstrap that don't reference DLLs, still be able to manage a simple operation of of invoking methods and pass results to the next DLL on the list. C# and .NET Core as a strong type based doesn't really have obvious ways to accomplish this, but i think i got to it with the following code, what do you think? string sourceAsmName = "DllToLoadName"; Assembly sourceAsm = AssemblyLoadContext.Default.LoadFromAssemblyPath(AppContext.BaseDirectory + sourceAsmName + @".dll"); AssemblyLoadHelper.LoadReferencedAssemblies(sourceAsm); Type sourceType = sourceAsm.GetType(sourceAsmName + "." + source); MethodInfo? sourceMethod = sourceType.GetMethod("extract"); object? sourceInstance = Activator.CreateInstance(sourceType, new object[] { _config, _logger }); Task sourceTask = (Task)sourceMethod.Invoke(sourceInstance, null); _logger.LogInformati