Author Archives: Robins

Three methods of referencing DLL in Visual Studio 2015

Copy the DLL file to the directory where the executable is located
 
2. Transfer engineering attributes ->; Configure properties ->; Debugging – & gt; Change the working directory to the directory where the DLL files reside
 
3. Transfer engineering attributes ->; Configure properties ->; Debugging – & gt; Set the environment to the Path= DLL directory, for example: Path=$(SolutionDir)bin
 

Reproduced in: https://www.cnblogs.com/buyishi/p/10236780.html

Using Visual Studio 2015 to create. DLL and use. DLL

Use Visual Studio 2015 to create.dll and use.dll
In this paper, the implementation of an addition and meet function is taken as an example:
Create a DLL project:
1, File — New — Project — Win32 console application. Give it a name, like myadd. Click OK. Next, select DLL(D) for the application type and click Finish.
>
>
>
>
>
>
>
>
> You can delete it. Create a new one. CPP, name “mydll. CPP”, create a new “mydll.h”
3, write an addition and subtraction function for example; In mydll. CPP, write the following:

#include"stdafx.h"
#include"mydll.h"
int add(int a,int b)
{
    return a+b;
}

int sub(int c,int d)
{
    return c-d;
}

4. Write the following in mydll.h:

#pragma once
_declspec(dllexport)int add(int a, int b);
_declspec(dllexport)int sub(int a, int b);

5. Build — Build the solution. (select Debug X86 mode) and it will be in the project root directory (with.sln directory), under the Debug folder. Generate.dll and.lib files.

> File — New — Project — Win32 Console Application Give it a name like MyDllTest, click OK, Next, Console Application (W), Empty Project (E), Finish;
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Right click, add an existing item, and add mydll.h to the header file.

#include<iostream>
#include "mydll.h"
using namespace std;

int main()
{

    int ad, su;
    ad = add(100, 200);
    su = sub(10, 20);
    cout << "ad: " << ad << endl;
    cout << "su: " << su << endl;
    getchar();
    return 0;
}

5, in the project “resource file” right click, add – existing item; Select the.lib file and click OK.
6, Build, Solution, Run That’s it.

Error: importerror: DLL load failed: the page file is too small to complete the operation.

ImporError: DLL Load Failed: The page file is too small to complete operation.

Cause analysis,

2
2
2
2
2
2
2
2
2> Other programs are running, solution: wait for the other programs to finish running or close the other programs. Turn off all useless programs on your computer. Also, Python.ext should not be used by two programs at the same time. For example, if you are using PyDev + Anaconda, turn one off. *

The pychar / pytorch page file is too small to complete the operation

Possible reasons for
If baidu, most can tell you is because virtual memory is insufficient, let you increase virtual memory. On Windows, PyTorch may have a problem with its num_workers, which needs to be set to 0.
The solution
The lack of virtual memory may not be a setup problem, but it may simply be a lack of disk space. I cleaned up the disk and the problem was solved successfully.

Jedis exception resolution: noauth authentication required

The introduction
Before, the project worked just fine because the default was DB0. Then the new requirement came, instead of default DB0, it chose DB for the parameter.
the modified code is as follows, but an error NOAUTH Authentication required.

The solution
The problem is usually a password error, or a problem with the firewall on the Redis machine not turning off the lights.
I checked the password firewall etc and there is no problem.
later through the debug finally found the problem, modify the code is as follows:

when selecting a number the db, it needs to connect redis, but now I will choose the library code on the configuration code before the number, lead to the newspaper password error problem.
conclusion
The problem is actually very simple, actually calm down and think carefully can know what is wrong.
Programming requires a quiet mind, otherwise it is really difficult to make progress, I hope to remind myself.

An error was reported when springboot connected to redis Servlet.service () for servlet [dispatcherServlet] in context with path [] threw e

Made a day, finally 11 o ‘clock more than solved, record once. SerializationException: Cannot SerializationException: Cannot SerializationException: Cannot SerializationException: Cannot SerializationException: Cannot SerializationException: Cannot SerializationException: Cannot SerializationException: Cannot SerializationException:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.io.NotSerializableException: com.wanghaixin.springboot.model.Student] with root cause
Solution:
NotSerializable is not serialized objects, object Article cannot be serialized therefore appeared this problem.
JavaBeans to cache must implement the Serializable interface, because Spring serializes objects before storing them in Redis
For this exception, just modify the corresponding JavaBean object, mine is Student

public class Student implements Serializable 

Spring boot project running error: Servlet.service () for servlet [dispatcherServlet] threw exception

spring boot
spring boot
spring boot
spring boot
spring boot
spring boot
Error output from console:

2020-06-29 12:25:44.780 ERROR 1968 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] threw exception

java.lang.StackOverflowError: null
	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:583) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	

: The @Autowired annotation is not added to the implementation class in the Service layer. This will cause the implementation class to lack dependencies. An error will occur if the dependencies cannot be found after the project is started.
Original code:

   private EmployeeDao employeeDao;

Modified code after adding annotations:

 @Autowired
   private EmployeeDao employeeDao;

The problem is resolved by adding the @Autowired annotation.

Setting up a virtual environment for jupyter notebook

After create the virtual environment, start jupyter can’t find the environment, the solution is as follows:
1. First activate the virtual environment

activate py3

2. Install ipykernel

conda install ipykernel

3. Create the kernel file

conda install -n py3 ipykernel

4. Write the environment into the Notebook kernel

python -m ipykernel install --user --name py3 --display-name "py3"

The first Py3 is the name of the virtual environment, and the second Py3 is the name displayed in the Jupyter.

The process of creating the virtual environment is really bumpy. I just encountered another problem. After creating a new Notebook, it keeps showing that it is connecting to the service.
pip uninstall tornado pip install tornado==5.0.0

Reference links

add conda jupyter environment jupyter notebook open file times wrong: the connection to backend service failed to build a…