When using c# as the development language to convert Pb files into CS files, I believe many people will encounter a very difficult problem
The first question: in the protoc3 environment, import timestamp. In the header, import “Google/protobuf/timestamp. Proto”; Exceptions will be thrown when: Google/protobuf/timestamp. Proto “was not found or had errors;
Solution [sharing of original articles by blogger “pamxy”:
(Note: it was found later that it is not necessary to add this directory, because the timestamp.pb.cc file generated by timestamp.proto has been compiled as the source code when compiling libprotobuf.lib file, and libprotobuf.lib is also used in compiling protoc.exe, so it is natural to default that there is already a source code, so there is no need to import it again!)
Just delete the import “Google/protobuf/timestamp. Proto”.
Second question: ” google.protobuf.Timestamp” is not defined.
Under normal circumstances, there is no need to import google.protobuf.timestamp directly in the protoc3 environment, because in the compilation process, the problem will be read in the Lib file, but if timestamp is called in the file, it is as follows:
It is necessary to call the timestamp file in the header, but bloggers are always prompted during the call ” google.protobuf.Timestamp” is not defined.
There is really no way, so I have to find the path of this file: timestamp.proto file in protobuf master \ SRC \ Google \ protobuf folder, directly copy the file to the same level directory of the file you want to compile, and then modify the timestamp file in the header. The call path: Import “timestamp. Proto”;
Finally, the file was finally solved…….
The third question: how to call after converting the protocol file into a CS file?
a. Found in referenced project: Tools & gt& gt; Nuget package manager & gt& gt; Nuget package for management solution & gt& gt; Search for “Google. Protocolbuffers” and install
B, directly convert the protoc file into the CS file, and call it in the project.
This small problem is recorded, which is also convenient for you to use as a reference when you encounter this problem.
Read More:
- ImportError: No module named google.protobuf.internal
- Echars 5.0 Import Error: “export ‘default’ (imported as ‘echarts’) was not found in ‘echarts’
- The imported project “c:\Microsoft.Cpp.Default.props” was not found
- Google Play googleapi: Error 403: Google Play Android Developer API has not been used in project
- ValueError: Input 0 of node import/save/Assign was passed float from import/beta1_power:0 incompatib
- [Solved] panic: proto: duplicate enum registered: raftpb.EntryType
- JSON parse error: raw timestamp (1595952000000) not allowed for
- [Solved] FileUploadException: the request was rejected because no multipart boundary was found
- [Solved] Vscode Error: “export ‘default‘ (imported as ‘VueRouter‘) was not found in ‘vue-router‘
- [Solved] Eureka Startup Error: Root name (‘timestamp‘) does not match expected type EurekaApplications
- [Solved] Vue3 Error: export ‘createRouter‘ was not found in ‘vue-router‘
- [Solved] Instantiation of ‘sdram_model_plus‘ failed. The design unit was not found.
- Cordova – CordovaError: Promise rejected with non-error: ‘ios-deploy was not found
- JSP error: The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
- Postgis Install Error: could not load library “C:\……“:The specified module could not be found.
- Grpc Error: failed to unmarshal the received message proto: can‘t skip unknown wire type 7
- [Solved] Error: Main class not found or could not be loaded com.jawasoft.
- [Solved] fatal error C1083: Could Not Open Unable to open include file:“stdint.h”: No such file or directory
- Swagger-ui.html Open Error: There was an unexpected error (type=Not Found, status=404)
- The SDK of Android webrtc compiled with Ninja – C out / release command reported an error, and the Android NDK processing method could not be found