Skip to content

Category: C#

XRMToolbox – SQL 4 CDS does not open

Had issues getting SQL 4 CDS to open. I tried reinstalling the plugin and the app, and that didn’t work. Finally went to …\AppData\Roaming\MscrmTools\XrmToolBox\Settings and deleted a file there called “MarkMpn.Sql4Cds.xml”. That seemed to have allowed me back in. Looks like it’s a settings file for SQL 4 CDS. After closing XRMToolbox, the file is regenerated.

Do it at your own risk.

Leave a Comment

Small X Studio – AI Image Generation Entirely in Your Browser

I’ve been experimenting with running AI models locally, exploring different ways to make AI more accessible without depending on cloud services or dedicated AI servers.

My latest project, Small X Studio, takes that experimentation in a different direction: running an AI image generation model directly inside a web browser.

I was inspired by this project https://webllm.mlc.ai/ which allows you to chat with an an agent locally.

Small X Studio is a self-hosted text-to-image application built using .NET 10, JavaScript, ONNX Runtime Web, and Stable Diffusion.

Unlike traditional AI image generation applications, where your browser sends requests to a back-end running the AI model, Small X Studio performs the actual image generation locally in the browser.

The .NET application serves the website and model files. Once the browser loads the model, the image generation process happens entirely on your device.

This means:

  • No cloud AI inference service is required.
  • No dedicated GPU server is needed.
  • Prompts and image generation remain local to the browser.
  • The application can take advantage of supported GPU hardware through WebGPU.
  • CPU-based execution is available as a fallback.
  • The entire application can be self-hosted using Docker.

Code: https://github.com/xavier-hernandez/small-x-studio

Demo/Test Website: https://small-studio.xavier.cc/



Leave a Comment

What is my ip address?

Another “what is my ip address” app.

So far I have 2 apps for telling you your IP address.

One can be found here, https://yourip.sh. This is using GO and was forked from ifconfig.io. I wanted to learn GO so I forked that project and made modifications to it.

Such as…

  • Added MaxMind databases
  • Added dark mode
  • Added the ability to add other HTML elements
  • Added integration with plausible analytics

https://github.com/xavier-hernandez/yourip.sh

My other, older, app can be found here https://whatismyip.biz . This app is built in .NET, Blazor client side, running on a Linux server. This is totally custom built.

Both apps above a are docker images that I’ve created as well.

Leave a Comment

MS Dynamics C# retrieving label/name

This is an example of retrieving the label / name of a code instead of writing another function to look it up.

fakecode --> value (int)
fakecode (formatted) --> FormattedValues["fakecode"]

So in C# you can do:

string labelName =  entity.FormattedValues.Contains("fakecode")
? entity.FormattedValues["fakecode"]
: null;

Or

string labelName = entity.FormattedValues.Contains("fakecode")
? entity.FormattedValues["fakecode"].ToEmptyStringIfNull()
: string.Empty;

Leave a Comment

Upcoming Updates for Azure Pipelines Agents Images – Windows 2019 being deprecated

Upcoming Updates for Azure Pipelines Agents Images

“This deprecation affects Azure DevOps Pipeline customers only if they are using Windows Server 2019 image in a Microsoft Hosted Agent. Please note that it does not impact customers using Windows 2019 in any other Agent (Self-hosted, MDP, VMSS). Refer the guidelines given below to find out the impacted pipelines in your organization. The detailed deprecation plan is outlined below.”

Key Dates:

• Deprecation Start Date: 1st June 2025
• Brownout period: 3rd June 2025 to 24th June 2025
• Full Removal Date: 30th June 2025

Leave a Comment

Azure Pipeline image 20250527.1.0 is missing .NET SDK 9.0.300

I believe this is due to using a .NET Core project using that SDK version. The workaround right now is to add the following task to your pipeline.

For more info: https://developercommunity.visualstudio.com/t/Azure-Pipeline-image-2025052710-is-mis/10913159?sort=newest

Add Task below if using YAML

- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '9.0.203'

If using the classic UI
Add task → search “Use .NET Core SDK (UseDotNet@2)”

Update the version to 9.0.203. The YAML should look like this.

This option did not work for me.

“Workaround that worked for me is setting a restore property BuildWithNetFrameworkHostedCompiler to true as documented here.
This configures the build to use a matching version of the MSBuild with the latest SDK version installed. By default a version available with installed VS is being used, creating a mismatch.”

You can also search for…

<Project Sdk="Microsoft.NET.Sdk/9.0.203">

and if found, replace it with…

<Project Sdk="Microsoft.NET.Sdk">
Leave a Comment

CVS file to parquet file, using .net

https://github.com/xavier-hernandez/csv_to_parquet_dotnet

Converts a csv to a parquet file, per the delimiter, in .NET.

Nuget packages used

  • CsvHelper
  • Parquet.Net

This solution which is “as-is” converts a CSV file into a Parquet file. I created this because I could not find anything .NET based or Windows based that I could use to convert a file. ‘

The solution requires an input file, output file, error file, delimiter, and has header (true/false). If the files does not have a header than a fake header is created for the output file. The file is processed under the assumption that all the columns are strings. If an error occurs for a row then that row is written to the error file to be manually looked at. These errors occur sometimes if the row doesn’t match the columns already created by the first row of data.

The only other Windows app I could find was this https://superintendent.app but you need to load all the data then export it.

Further enhancements:

  • I wrote a batch function to process the file faster but the count appears to be off. Not sure why.
  • Performance enhancements. Currently reads and coverts file row by row; which is why I tried doing batches.
  • Better errors handling
  • Except arguments from the console
  • Read from file and do not load file into memory

Note

  • The current solution loads the entire file into memory so be sure you have enough RAM to process the file otherwise your system might become unstable. If your debugging then the memory footprint will be bigger than if you use release.
Leave a Comment

Install dotnet core on Ubuntu 22.04

These are the steps I used to install dotnet core on Ubuntu 22.04, both the SDK and the runtime.

apt update
apt install -y apt-transport-https
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
apt update
apt install -y dotnet-sdk-7.0
apt update
apt install -y aspnetcore-runtime-7.0

To verify installation run the following commands. If the below doesn’t work try to open a new ssh session or terminal.

dotnet --list-runtimes

Microsoft.AspNetCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

dotnet --list-sdks

7.0.102 [/usr/share/dotnet/sdk]
root@srv4311:~# 

If you tried previously to install version 7.0 make sure you remove/purge the old version from the system. Something like below.

apt remove --purge dotnet-sdk-6.0 dotnet-runtime-6.0
apt auto-remove

Also maybe delete the .dotnet folder in your home directory.

Leave a Comment

Getting error An unhandled exception has occurred. See browser dev tools for details.

I deleted all the CSS from site.css and replaced it with mine of course but after that, I started receiving the following error “Getting error An unhandled exception has occurred. See browser dev tools for details. Reload”. It looks like this occurs because blazor needs at least 2 styles to display errors.

Found my answer here.

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

Leave a Comment

.NET and TLS

  • Before .NET 4.6 – TLS 1.1 is default and negotiations start down
  • .NET 4.6 – TLS 1.2 is default and negotiations start down
  • .NET 4.7 – the default value of this property is SecurityProtocolType.SystemDefault. This allows .NET Framework networking APIs based on SslStream (such as FTP, HTTP, and SMTP) to inherit the default security protocols from the operating system or from any custom configurations performed by a system administrator.
Leave a Comment

.net core api to retrieve dns records

Built a .net core api using swagger, dnsclient.net, and rollbar. Have a look here https://github.com/xavier-hernandez/dnsclient-api .

Here is the README:

I created a YAML file built on OpenAPI 3.0 standards for my endpoints(paths) and models. I generated the stub code on https://editor.swagger.io/ then tweaked, fixed, and updated the code. Creating the stub code really gives a great head start.

I kept authentication simple, it’s using an API key sent in the header request. Currently the API key is hardcoded to “1” but maybe later I’ll use a database or something to store API keys. I might host this somewhere if it’s something I find interesting to host. Tie it maybe to a MySQL/MariaDB database.

The library being used to retrieve DNS information is called DnsClient.NET https://github.com/MichaCo/DnsClient.NET and available as a nuget package.

I’m also using https://rollbar.com/ which is an easy way to log errors and information. Maybe if I host it on Azure I’ll use Application Insights.

Leave a Comment

Hide JSON properties in the result set if not set or null, using .net core 3.1 and Newtonsoft

Need to hide properties in your JSON result for a .net core API. Add the following line in your Startup.cs file. Just like below.

opts.SerializerSettings.NullValueHandling = NullValueHandling.Ignore

services.AddMvc(options =>
                {
                    options.InputFormatters.RemoveType<Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter>();
		    options.OutputFormatters.RemoveType<Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter>();
                })
                .AddNewtonsoftJson(opts =>
               {
                    opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                    opts.SerializerSettings.Converters.Add(new StringEnumConverter(new CamelCaseNamingStrategy()));
                    opts.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
                })
                .AddXmlSerializerFormatters();

Leave a Comment

HTTP Error 500.35 – ANCM Multiple In-Process Applications in same Process (using IIS Express)

I got this error today and was causing me a headache. I stopped all apps running in IIS Express, tried switching releases, etc. But seems like this is a bug in Visual Studio 2019.

Stop your application, close the solution, delete the .vs folder in the solution, open it back up and it should work.

https://stackoverflow.com/questions/58246822/http-error-500-35-ancm-multiple-in-process-applications-in-same-process-asp-ne

Leave a Comment

.net core – launchSettings.json and gitignore

If your working with other developers this file should not be ignored within your .gitignore file. Its useful for environmental and other settings.

I’m not sure why the template I downloaded had it ignored. Seems like its been an issue for a while and has been corrected a few times.

https://stackoverflow.com/questions/47377058/should-i-ignore-launchsettings-json-file-from-being-committed-in-git

https://github.com/github/VisualStudio/issues/1405

Leave a Comment

Access Modifiers (C# Programming Guide)

All types and type members have an accessibility level, which controls whether they can be used from other code in your assembly or other assemblies. You can use the following access modifiers to specify the accessibility of a type or member when you declare it:

public

The type or member can be accessed by any other code in the same assembly or another assembly that references it.

private

The type or member can be accessed only by code in the same class or struct.

protected

The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.

internal

The type or member can be accessed by any code in the same assembly, but not from another assembly.

protected internal

The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.

http://msdn.microsoft.com/en-us/library/ms173121.aspx

Leave a Comment