machine.config problems

Discussion in 'Databases' started by Dell, Mar 8, 2010.

  1. I'm very new to and web hosting. I'm familiar with Visual Studio, somewhat familiar with SQL. I've got Nopcommerce running fine on my local machine, have been playiing around today with trying to use VS to publish it to the Winhost server. Was getting errors, mostly related to the correct SQL connection string, trying to understand them and work through them etc. I finally got Nopcommerce to connect OK. So to see if I learned anything I deleted the SQL database and connection string and started over. Now no matter what I do (seemingly) I get the following:

    Server Error in '/' Application.
    Configuration Error 
    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 
    Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.
    Source Error: 
    [No relevant source lines]
    Source File: machine.config    Line: 160 
    Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016 
    This appears with no database created in Control Panel, with a database created in Control Panel, with NopCommerce not having a valid connection string, with Nopcommerce having a valid connection string. I can't find a machine.config anywhere on the website. Any help would be appreciated. I'm stuck.
    Last edited by a moderator: Oct 14, 2015
  2. Ray


    LocalSQLServer is the default connection string name for most .Net application. If you do not have this connection string name you may want to specifically remove it from your web.config file. This should over ride what is on the servers configuration file and bypass looking for LocalSQLServer.
  3. Indeed ;-)

    ScottGu have been prompting all of us to use the Add/Remove features for some time now.

    As a precaution LocalSQLServer can be overridden in each conn like this:

    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data;Initial Catalog=SQL_007_Maga;User ID=SQL_007_Maga_user;Password=SomePwHere" providerName="System.Data.SqlClient"/>
    <remove name="SQL_Maga_userConnectionString"/>
    <add name="SQL_Maga_userConnectionString" connectionString="Data;Initial Catalog=SQL_007_Maga;User ID=SQL_007_Maga_user;Password=SomePwHere" providerName="System.Data.SqlClient"/>

    See how slick? ;-)
    You can add and remove as needed and you should always Clear first, as shown above.
  4. Gofer01

    Gofer01 Amateur Web Application Developer

    I had the same problem yesterday. Go in rename web.config to web1.confg and then with VS 2008, or VWD or Expression Web 3 create a new web.config. This should work. It worked for me.

    Another way is to log in via IIS 7.0 manager to your site on Winhost Clicked on the DB connectionstring icon and delete the db entry that causing the issue. That will modify the web.config file at the same time you can put in the correct tcp connection string to the db

    IIS 7.0 Manager is a free download. I think I saw a hyperlink some where on this site. If it's not here do a goggle search on IIS 7.0 Manager

    By The way the machine.config file is on your computer at this location C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config

    The web.config is partly created from machine.config file. I think it's neat how the netframework and web applications interact with each other. This file is located at the same place on every Microsoft O/S with the latest version of Microsoft Netframework installed.
    Last edited by a moderator: Oct 14, 2015
  5. All these responses are great! I appreciate the info and suggestions. Being new to web development, I hadn't thought of looking in the web.config file. Thanks for the help. Dell
  6. Ray


    Don't forget the IIS 7 Manager. IIS 7 Manager is basically a GUI extension to the web.config file. You can connect to our server using IIS 7 Manager and navigate to the module/button labeled Connection Strings. You can eitehr remove or define the connection string name 'LocalSQLServer'. for me this is easier then manually modifying elements in your web.config file especially when defining a connection string name.
    Last edited by a moderator: Oct 14, 2015
  7. True dat! :)
    I'm in love with the IIS7 Manager, it rocks.
  8. Gofer01

    Gofer01 Amateur Web Application Developer

    When you create a site on your local computer and then build it. The build is working with netframework and The build is creating the dll's. on your computer.

    Once you plublish your site to WebHost web server. you only plublishing the files. You leave the dll's behind.

    The 1st user that actualy visit the web page application that you plublish on the web server is actally involking the build command on the web server. and at that time the dll's are created on the web server from the netframework thats installed on that server O/S

    Every user afterwords will have the page or application loads faster because the dll's are allready created.
  9. I didn't know that. When I use VS to publish to the server, it goes through a complete build first, then starts (terribly slowly) FTPing the files to the server, including (I believe) all the .dll files in the bin subdirectory. Do I misunderstand what it is doing?
  10. Really? You sure about that?

    The "first" user will load the application into memory on the server (or start up the application so it can compile, if need be), and subsequent loads will be faster. But the application doesn't stay in memory forever, and once it drops out (if no one is using it for a period of time), the process starts over again with the next user.
  11. Gofer01

    Gofer01 Amateur Web Application Developer

    Yes Sir I'm sure about that. I just took a payed course through one of Microsoft learning programs about a month ago and I passed the course at 85%. I only talking about the very 1st time that the web application is run on the IIS Server. They might have paid me or I might of paid them. I can't say much about that. Under a legal agreement. I can say I have 11 months to get a full functing business web application up and running to keep what I currently have and to advanced to the next stage.

    I think you are talking about the rest of the time.
  12. Ray


    Dell I just want to warn you about ASP.Net Deployment types specifically with precompile applications. It is possible to deploy an application and precompile it as it is being transfered over to a hosting server, but this will require specific features and tools to be installed on the server. Tools and features that are not normally suited for a shared hosting environment. When you want to precompile a web application, you will need to run the precompilation directly on your computer and then upload the precompiled files to our server using FTP. With the precompiled method, the assemblies and components maybe merged all to one file where as if it is not precompiled you may have multiple assemblies and components (dll files) existing in the Bin folder.
  13. The difference is in shared hosting and a default development setup that you might run on your own computer.

    As far as shared hosting is concerned, it does not typically work as you have described, so I just want to make sure others don't read your post and expect that behavior on our servers.

    You have to include any .dll files that you generate along with your custom application. The server is not going to generate them for you.
  14. I also have the same problem
    can we just let the application(nopcommerce) manage on it's own?we can enter credentials @ setup
    It can save a lot of time, we can avoid publishing to server via SQL server management studio in local machine
    Any ideas?
  15. Ray


    What do you mean 'manage on it's own'? If you want a specific application to run on its own application pool you'll need to order a new site account for it.
  16. Sorry to answer to this post, but I am having horrible times with this. I keep deleting the localsqlconnection from machine.config, from everywhere and using the manager and it is still giving me the same error page :(

    WoW I had a horrible time setting this up. This was something...

    Everything is in Knowledge base thought :) Good job :)

Share This Page