Sponsor: Using RabbitMQ or Azure Service Bus in your .NET systems? Well, you could just use their SDKs and roll your own serialization, routing, outbox, retries, and telemetry. I mean, seriously, how hard could it be?

Visual Studio 2017
For my example, I’ve included a json file called fake.json I pulled from Mockaroo. Here’s a screenshot of VS2017 that shows theData/fakedata.json
file in my solution.

fakedata.json
, and go to Properties, you will be presented with a familiar properties dialog. This is where you can set the Build Action to Embedded Resource

.csproj
If you prefer to edit the .csproj file by hand or are using another IDE/editor, you simply have to add two newItemGroup
‘s.
Make sure the path to your files are relative to your csproj. Here’s a full copy of my solution.
GetManifestResourceStream
Now in your code, you can access the Assembly API to get our your embedded resource. Note thatGetManifestResourceStream
takes a string that represents your file. The path would be the assembly name and the folder structure is used as a namespace.
Also in the above code, the entry assembly (EntryAssembly.csproj/dll) is being used. If you’re embedded resource is in another assembly, you will need to use different reflection code to get that assembly.