Cannot cast object of type "DAL.XXXX" to type "IDAL.XXXX"

This problem occurred during the reconstruction of the computer room in the past two days. I found a few blogs from the Internet, all of which talked about the interface problem. However, after experimenting in this direction for countless times, I found that my problem is not here. , Because my interface is no problem.

First, attach a solution to the unimplemented interface problem:

The location where the error is reported is in the reflection factory:

Then, first look at whether your DAL layer inherits this interface:

If you see that this does not solve your problem, then continue to do the following steps:

First, open the properties of the DAL layer → build → output → output path, and select under the bin\Debug folder of your UI layer

This path is the location where you save the file. If it is the default location, it should be in the C drive. Then create a new project and check the save location. Then regenerate the solution to solve the problem perfectly.

Personal guess is wrong, it may be that your changes are not saved in the dll file, so you cannot connect to the interface. The reason why I have this problem is because of another problem I encountered, copying the dll file directly to the UI layer file, so in the regenerated solution, the copied dll file cannot be updated.

Guess you like

Origin blog.csdn.net/weixin_37081112/article/details/106036832