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