Typed DataSets and App.Config...A Cautionary Tale

I am working on a project where I have separated the Typed DataSets into a separate Assembly.  I nievely made the Typed DataSets use a named Connection String in this assembly.  So when I attached to the Database when creating my DataSets, I saw that it was using a Connection String called "MyConnection".

In this assembly, the designer created an app.config and a Settings.setting object.  All sounded good.  So in my ASP.NET 2.0 project, I setup the connection string in the web.config and called it "MyConnection".  This all worked until I deployed it to a server, when all hell broke loose.  After deployment, my code that did *not* use Typed DataSets (mostly DataSources) worked fine with my new "MyConnection" connection string...but...

Everywhere I used the Typed DataSets it was failing to connect to the database.  When I looked at it it seems that the Typed DataSets were using the connection string I used on my dev box...but no app.config to be seen.  How was it getting that bad connection string?  Well it seems that the connection string information is being embedded as the "default" connection string to use if it can't find the connection string in the configuration.  Ok, this is bad...I'd hate for my assembly to actually have stuff like my password embedded in it, but I doubt that happens.  I was using integrated security so I haven't tested the password embedding yet.

But what is strange is the connection string was in the web.config.  What gives?  Well the Typed DataSet satellite assembly named my connection string with namespace and setting prefixes.  "MyConnection" became "MyApp.Properties.Settings.MyConnection" because the serialization of the name includes all of that.  Yeech...

For now I added that as a connection string to my web.config and got over my initial issue, but I am still digging to find a better solution.  I'll let you know what I find.

Comments:

I am trying Visual Web Developer abd Visual Basic 2005 Express Edition and faced something quite similar. I created a typed dataset called MyFirstDataset in Visual Web Developer, which in turn created a MyFirstDataset.xsd file. Got all MyFirstDataset.* files from project folder, copied them to a Visual Basic project folder created previously. On Visual Basic, add MyFirstDataset.xsd file to the project and project does not work. Any tip(s) on that?

Regards,

Luciano Evaristo Guerche
Taboao da Serra, SP, Brazil

Right click on the .xsd file and view the properties. Then set the Toolname to MSDataSetGenerator. That's the magic to make it become a Typed DataSet again.

HTH
Shawn


 



 
Save Cancel