Tag Archives: c#

How to Solve Internal Server Error: /swagger/v1/swagger.json

Sometimes, when running swagger, it will cause“   Internal Server Error /swagger/v1/swagger.json  ” Wrong.

Here are my solutions:

1. First look at the console and check the reason. The reason is: ambiguous HTTP method for action, which is translated as “ambiguous HTTP operation method”. It is estimated that a brother did not indicate the HTTP method when submitting the code.

2. Search all public methods in the controller. In the search result window, press ↓ on the keyboard   and   ↑   Button to quickly switch to search. Finally, it is found that the method is written in public and changed to private.

Conclusion:

Ambiguous HTTP method for action, translated as “ambiguous HTTP operation method”.

There may be no HTTP method written, such as [httpget], [httppost], add to the method.

It may also be caused by writing some methods that should have been private to public.

About error CSC in c# vs: error cs0006: metadata file could not be found

About error CSC in c# vs: error cs0006: metadata file could not be found

Moving a project around in different solutions, the legendary CSC: error cs0006 finally appeared.

When compiling, it is always prompted that an item that does not exist in the reference cannot find the metadata file.

No matter how you delete a project, deleting a reference cannot be generated.

Solution:

Step 1: find your own xxx.csproj project file

Step 2: Rename: add suffix . TXT

Step 3:

Open the csproj project file, find the item containing the reference item in question, and delete the item as a whole.

Error 1 fatal error LNK1220: ‘/PGD‘ requires ‘/LTCG:[PGINSTRUMENT|PGOPTIMIZE]‘ specification

VS2008 compilation of an MFC project pop-up error, looking for a long time, did not find the problem.

  resolvent,

According to the official article:/PGD (specify database for profile guided optimizations) | Microsoft docs

  It says how to solve this problem,

  Setup steps,

1. Open the project property setting (right click on the solution project and select properties),

2. Select link = & gt; Optimization=> Profile Guided Database

3. Select & lt; inherit from parent or project defaults>, Click apply and confirm. Then compile and solve the problem.

[Solved] Error: Another program is already listening on a port that one of our HTTP servers is configured to

Question

    1. Step 1 run
supervisord  -c /etc/supervisor/supervisord.conf

Error

Error: Another program is already listening on a port that one of our HTTP servers is configured to

Solution:

ps -ef | grep supervisord

Turn off the 8079 process

kill -s SIGTERM 8079  

Solution results

supervisord  -c /etc/supervisor/supervisord.conf

No error is the best case, indicating that the process is started successfully

c# Newtonsoft.Json.JsonReaderException: ‘Error reading JArray from JsonReader. Path ‘‘, line 0

When the data queried by c# datatable is converted to JSON object, the following error is reported.

Newtonsoft.Json.JsonReaderException: 'Error reading JArray from JsonReader. Path '', line 0, position 0.

The reason for this problem is that the queried data set directly becomes a string, and then an error is reported when it is empty
solution: add judgment

		if (jsonStr.Length > 0)
                {
                    JArray jArray = JArray.Parse(jsonStr);
                    JProperty Data = new JProperty("Data", jArray);
                    ZzjDataObj.Add(Data);
                }
                else
                {
                    JArray jArray = new JArray();
                    JProperty Data = new JProperty("Data", jArray);
                    ZzjDataObj.Add(Data);
                }

Hololens2 reported an error. Microsoft.windows.system is missing

Assets\Microsoft.MixedReality.WebRTC.Unity\Scripts\Media\LocalVideoSource.cs(234,89): error CS0234: The type or namespace name ‘ProcessorArchitecture’ does not exist in the namespace ‘Microsoft.Windows.System’ (are you missing an assembly reference?)

Click the error reporting line to enter the code:

Method 1: modify the official code pre instruction   UNITY_ Wsa changed to   UNITY_ UWP

Method 2: directly delete the official judgment, and the code judges whether it is hololens1    , Return according to your judgment   True or false

  I use   Method two!

Debug error: abort() has been called error causes and Solutions

report errors

Error reporting reason

    pointer problems, such as illegal pointer access, pointer access out of bounds, memory leakage, memory out of bounds and insufficient memory allocation of multithreaded access resources. Check whether exe and DLL are mixed with different versions of CRT

    terms of settlement

      check that the requested space is not released. Check whether the stack space has been fully allocated. It is recommended that each memory allocation should not be too large, and remember that the release pointer points to an unexpected memory location

[Solved] C# connecting to MySQL database reports an error

C# is fine when calling mysql.data.dll to connect to the local database, but it reports an error when connecting to the mysql server on a remote Linux server
Error log, current connection string
System.Security.Authentication.AuthenticationException: Authentication to host ‘xxx.xxx.xxx.xx’ failed.
at MySql.Data.Common.Ssl.StartSSL(Stream& baseStream, Encoding encoding, String connectionString)
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()

<add key="dbString" value="server=localhost;port=3306;user=root;password=root; database=id3net" />

If the host does not support SSL connection, then SSL connection will not be used

Solution: add sslmode = none after the connection string.

<add key="dbString" value="server=localhost;port=3306;user=root;password=root; database=id3net;SslMode=none" />

C# Error: Import “google/protobuf/timestamp.proto“ was not found or had errors. [How to Solve]

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.

Stackexchange.redis data timeout [How to Solve]

StackExchange.Redis Error when loading large batch of hash data.
StackExchange.Redis.RedisTimeoutException: Timeout performing HGET [email protected]rIncomeDistributionItem, inst: 1, mgr: ExecuteSelect, err: never, queue: 2, qu: 0, qs: 2, qc: 0, wr: 0, wq: 0, in: 0, ar: 0, clientName: xx, serverEndpoint: 192.0.x.x:6379, keyHashSlot: 10857, IOCP: (Busy=0,Free=1000,Min=6,Max=1000), WORKER: (Busy=0,Free=32767,Min=6,Max=32767) (Please take a look at this article for some common client-side issues that can cause。 timeouts: http://stackexchange.github.io/StackExchange.Redis/Timeouts)
According to the information to see IOCP and WORKER Busy are 0, will also report a timeout problem, is expected to be a StackExchange.Redis bug, the solution can be changed to use FreeRedis.

It can be opened with localhost, but not with IP address. The request host name is invalid

Problem point
the webapi compiled by vs can only be used

http://localhost:64734/API/Default/GETIP 

unavailable

http://127.0.0.1:64734/API/Default/GETIP

The solution is
1, find the. Vs folder

2, find the file D: desktop, webapiarduino. Vs, config, applicationhost. Config
the path depends on the project.

D:\Desktop\WebAPIArduino

After searching the localhost, change the localhost to *

the modified result

is valid.