CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Database name not found in config file...strange

rated by 0 users
Answered (Not Verified) This post has 0 verified answers | 11 Replies | 2 Followers

Top 150 Contributor
50 Posts
Pavel posted on Tue, Feb 14 2012 12:12 PM

I got this message("Database name not found in config file")...but not for all objects.

As soon as I use code locally from VS there is no problem.

I start my ServerHost on IIS and start receiving this message...but not for all objects.

Of course, this line

 Using ctx = ConnectionManager(Of SqlConnection).GetManager("MyConnectionString")

is exactly the same for every object.

What could be the reason for such a behaviour?

Thanks,

All Replies

Top 10 Contributor
9,270 Posts

That is strange behavior, I have no idea.

The GetManager method just uses the standard System.Configuration types to get the connection string - the code in GetManager isn't fancy by any means.

Rocky

Top 10 Contributor
1,770 Posts

Are you using N-Tier (remote DataPortal)?
What is the UI?

If NTier - it could be that some code is executing on the client (without connection string in app.config) by using [RunLocal] attribute on DataPortal XYZ methods.

 

Jonny Bekkum, Norway CslaContrib Coordinator

Top 150 Contributor
50 Posts
Answered (Not Verified) Pavel replied on Tue, Feb 14 2012 2:09 PM
Suggested by JonnyBee

It's 3 tier setup with remote DataPortal on IIS, as described in the last books. Connecting string is only on remote host in web config file.

UI is WinForms.....I can see that it happened with a new added classes only.

Any cashe problems on IIS?///but I did not changed the name of the ConnectionString.

...I am testing it on the same computer using localhost.

It happened on Update/Add methods of a new added object.

 

[RunLocal]...Should I remove it and run it on server side?

 

Top 10 Contributor
1,770 Posts

Hi,

If your new classes has [RunLocal] attribute on DataPortal_XYZ then they will be called on the client - not sent to the server and that would explain why your code is not able to get the ConnectionString.

Jonny Bekkum, Norway CslaContrib Coordinator

Top 150 Contributor
50 Posts
Pavel replied on Tue, Feb 14 2012 2:19 PM

I just remove [RunLocal] attribute and still got the message.

I added ConnectionString

<connectionStrings>
    <add name="ConnectionString"
      connectionString="Data Source=EES-SQL-02;Initial Catalog=EER_Testing;User ID=***;Password=*******"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

into config file together with

  <appSettings>
    <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WcfProxy, Csla" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
  </appSettings>
  <system.serviceModel>
    <client>
      <endpoint name="WcfDataPortal" address="http://localhost:1179/WcfPortal.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_IWcfPortal" contract="Csla.Server.Hosts.IWcfPortal" />
    </client>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647" receiveTimeout="10" sendTimeout="10">
          <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647" maxNameTableCharCount="2147483647" maxDepth="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>

It fixed the problem but I am not sure if I run it remotely with both parts in my config on client.

Top 10 Contributor
1,770 Posts

I would remove the connection string from the client app.config.

Recompile and redistribute the client and server assemblies.

Do NOT use RunLocal attribute on methods that must connect to the database.

It's OK to use RunLocal attribute on DataPortal_Create methods that do not require data access (or connect to the database).

 

Jonny Bekkum, Norway CslaContrib Coordinator

Top 150 Contributor
50 Posts
Pavel replied on Tue, Feb 14 2012 2:29 PM

I tried all of those.

RunLocal only on DataPortal_Create methods.

Recompile both parts(client and server), update all references....and still have this message.

Could IsDatabaseName parameter in GetManager function be critical for this issue?

 

 

Top 150 Contributor
50 Posts
Pavel replied on Tue, Feb 14 2012 3:01 PM

Unbelievable !!!!

I have tried everything and still have this error message. I have no idea what else should I try to check to solve the problem.

Top 10 Contributor
9,270 Posts

Try directly calling the System. Configuration API to get the connection string yourself and see what you get.

Or try using the API to get a made-up entry so you can put this made-up entry on the client AND server with different values. That might help you figure out which config file is being used.

Rocky

Top 10 Contributor
1,770 Posts
JonnyBee replied on Tue, Feb 14 2012 10:41 PM

Hi,

My best guess is that some of the new code is not using DataPortal as it should and tries to do data access locally on the client.

Make sure to setup a n-tier development environment and inspect the error message and call stack - this should give a clear indication of how that method is called.

Jonny Bekkum, Norway CslaContrib Coordinator

Top 150 Contributor
50 Posts
Pavel replied on Wed, Feb 15 2012 8:13 AM

Thanks,

Obviously, that my client is trying to go to database locally without calling remote Data Portal.

Morning is always the better time to think over the yesterday's problemsSmile

I think that problem solved. At least I know where to go.

Thanks again for your help,

 

Page 1 of 1 (12 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems