Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

642
Views
c# protobuf System.Runtime.CompilerServices.Unsafe

I am using Visual Studio 2019, Windows 10, .Net Framework 4.8. (if you need more info ask)

I have a model.proto file that compiles into Model.pb.cs, and I use in my project.

When I fill the model with data and try to save it into a file ....

using PMOD = MyProtobuf.Model;

using NLog;
using NetMQ;
using NetMQ.Sockets;
using System;
using System.Text;
using System.IO;

var req = PMOD.MyDataModel();
// fill up req with all data ...
using (var file_output = File.Create("path/to/save/PB/file/into")) {
   using (var stream_output = new Google.Protobuf.CodedOutputStream(file_output)) {
      req.WriteTo(stream_output); <---- this one gives errors
   }
}

This happens.

Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

this is my program.csproj

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

  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>
    <PlatformTarget>x64</PlatformTarget>
    <OutputType>Library</OutputType>
  </PropertyGroup>

  <ItemGroup>
      <Protobuf Include="../../protobuf/model.proto" Link="model.proto" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="coverlet.msbuild" Version="3.0.3">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Google.Protobuf" Version="3.15.6" />
    <PackageReference Include="Grpc" Version="2.36.4" />
    <PackageReference Include="MathNet.Numerics" Version="4.15.0" />
    <PackageReference Include="MathNet.Spatial" Version="0.6.0" />
    <PackageReference Include="NetMQ" Version="4.0.1.6" />
    <PackageReference Include="NLog" Version="4.7.9" />
    <PackageReference Include="System.Text.Json" Version="5.0.2" />
  </ItemGroup>

  etc etc ... with files to compile
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!