This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15391|Reply: 1

[ASP.NET] asp.net The code user under the mvc project did not handle the TypeInitializationException

[Copy link]
Posted on 8/29/2015 7:09:58 PM | | | |


The project is made of MVC plus three layers together, there is this error, it took half an hour to get it done, let's talk about the solution and reason!

The model layer prioritizes reading the web.config under the mvc and does not read its own app.config, which should be consistent with the connectionStrings under the web.config node  


Solution:


Put the MVC project in web.config
<connectionStrings>
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-StudentMVC-20150818051648;Integrated Security=SSPI" />
  </connectionStrings>
Replace the node information in app.config of the model layer



Refer to the article below!


The specified named connection is not found in the configuration, is not planned for use with the EntityClient provider, or is invalid.         
(1)web:
You need to add a connectionString node to the client configuration file, which describes the connection information of the EntityClient.
For example:   

Add a connectionString node to web.config, which describes the connection information of the EntityClient. (connectionString is missing some information, so it is error.) )


(2)winfrom:
Add a connectionString node to app.config, which describes the connection information of the EntityClient. (connectionString is missing some information, so it is error.) )


(3) An error message appears when calling the ADO.NET Entity Data Model of another library:
"The specified named connection is not found in the configuration, is not planned for use with the EntityClient provider, or is invalid." } System.Exception {System.ArgumentException}

It is generally said that your connectstring is not set up, but it is indeed set in the class library of your Data Model.

Workaround: Your current project also needs to configure the same connectstring to avoid errors, add the same connectionStrings to App.Config or Web.config and the library where the Data Model is located






Previous:Ashley Madison website database download, total 9.69G, with Thunderbolt BT download link
Next:How to send a VPN
Posted on 8/31/2015 12:48:45 PM |
I deleted all three layers, leaving only one BaseDAO
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com