I'll start here: I know nothing about SmartClient, .Net, DotNetNuke, etc etc. This is a "see if alison can help" project for a client's app/ site developed 6 years ago by a company that won't help. I'm just a front-end developer- I've googled all I can. If I don't understand the advice given here, I'm passing on assisting the client. Just thought I would give it a whirl. Here goes:
We simply need to change a key -> value in the configuration of their desktop app which connects to a web service (ASEPublisher). I have FTP and SQL Server access, but that's it.
The desktop app folder contains the following files:
DataPublisher.exe
DataPublisher.exe.config
DataPublisher.pdb
OleDBDataAccess.dll
OleDbDataAccess.pdb
Their website contains a folder called "smartclient" that contains the same files.
I just need to change all of the urls in the code below and have the application update to use the new urls. Obviously just changing this file on the desktop and restarting the app didn't do it. So, here I am. I hope this isn't too vague. If you need more info, I can try to provide it.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="DataPublisher.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="DefaultFilePath" value="I:\Staff\fakefolder\database\SA Data.mdb" />
<add key="DefaultASEFilePath" value="I:\Staff\fakefolder\database\SA Data.mdb" />
<add key="CNN" value="Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" />
<add key="WebSvcUrl" value="http://www.fakedomain.org/admin/ClassPublisher.asmx" />
<add key="ASEWebSvcUrl" value="http://www.fakedomain.org/admin/ASEWebService.asmx" />
</appSettings>
<applicationSettings>
<DataPublisher.Properties.Settings>
<setting name="DataPublisher_ClassPublisherWS_ClassPublisher"
serializeAs="String">
<value>http://www.fakedomain.org/admin/ClassPublisher.asmx</value>
</setting>
<setting name="DataPublisher_ASEPublisherWS_ASEWebService" serializeAs="String">
<value>http://www.fakedomain.org/admin/ASEWebService.asmx</value>
</setting>
</DataPublisher.Properties.Settings>
</applicationSettings>
</configuration>
Related
I am trying the RemObject Hydra to embed a WPF module inside a VCL app.
In this WPF module, I have Grid Controls, and EntityFramework DataContext. It's connectionString, providers and everything stored in a app.config.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="ModelConnection" connectionString="character set=UTF8;data source=localhost;initial catalog=PATHTODATABASE.FDB;user id=SYSDBA;password=MASTERKEY" providerName="FirebirdSql.Data.FirebirdClient" />
</connectionStrings>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="FirebirdSql.Data.EntityFramework6.FbConnectionFactory, EntityFramework.Firebird" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="FirebirdSql.Data.FirebirdClient" type="FirebirdSql.Data.EntityFramework6.FbProviderServices, EntityFramework.Firebird" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="FirebirdSql.Data.FirebirdClient" />
<add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient" />
</DbProviderFactories>
</system.data></configuration>
The next step was to make the VCL host with delphi then load the WPF module's .dll using the HYModuleManager component. This is pretty straigtforward :
procedure TMainForm.FormCreate(Sender: TObject);
begin
HYModuleManager1.LoadModule('%path%\to\wpf\module\GridsModule.dll');
HYModuleManager1.CreateVisualPlugin('ClientGridView', fInstance, Panel1);
end;
I run the application in Delphi. But this error is thrown :
(Translation : An exception was thrown by the target of an invocation)
So with a little more research, I run this application (HydraHost.exe) using VisualStudio, and realize that this si the exception thrown by the module :
System.InvalidOperationException : 'No connection string named 'ModelConnection' could be found in the application config file.'
I then decide to write a WPF host. I set the WPF Host App.config to include the connection string and provider infos. To no surprise, everything works fine.
So, with the VCL host, the connectionString is not found. With the WPF host, it is. My conclusion is that the app.config is not loaded by the VCL host but it is loaded by the WPF host.
So what I did next is to manually copy the WPFHost.dll.config to VCLHost.exe.config as suggested by one of the answers, but same error, connectionString is not found.
So my question is : How can I "link" a .exe.config to a VCL app built with Delphi?
You should rename your app.config to YourExeName.exe.config as it's probably now YourDllName.dll.config
So, I have created a console application, added the entity framework nuget package, created a dbcontext and enabled migrations for my project.
However, I don't see the database anywhere. The database exists since I can query it when I run the application but since I haven't entered a connection string I don't see it anywhere in my SQL Management Studio.
My question is, where do Visual Studio "hide" this database?
Btw, I'm using EF6 Code First.
EDIT: Here is my app.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Add this to constructor of the context to see the default connection string used.
public class MyContext : DbContext
{
public MyContext()
{
Console.WriteLine(this.Database.Connection.ConnectionString);
}
}
Usually it creates the database in v11.0 or mssqllocaldb(in you app.config it is mssqllocaldb) instance of sqllocaldb.
The database file can be located at Users folder(Windows 8.1):
C:\Users\{UserName}\ApplicationName.ContextName.mdf
My requirement is as follows.
1)I want to use the application settings to read a location path and use it in my project to read the files in that folder.
--- I achieved this by creating a setting with the path and I used to read the path from that settings in the project as follows
Properties.Settings.Default.XMLModelPath
2)Now the actual requirement is I want that app.config of the class library to be available in the bin so that I can update the path if there are any changes required later and every time I run the application, the settings of that project should read this file and update its value.
Is there a way to achieve this or suggest any other possible ways.?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyClass.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<MyClass.Properties.Settings>
<setting name="XMLModelPath" serializeAs="String">
<value>C:\Resources\</value>
</setting>
</MyClass.Properties.Settings>
</applicationSettings>
</configuration>
This is my app.config file of the class. I want this to be available in bin and the settings of the project to be updated everytime I run my application.
I am creating a WPF application, having classical architecture: UI layer, business logic layer and infrastructure layer. I decided to split configuration in two files: app.config file, containing common app configuration, and dll.config, containing connection string to use in DbContext for domain model storage. The second .config file should be sticked to business logic DLL, while first file sticked to corresponding UI executable (there will be one more UI with it's own configuration).
app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<enterpriseLibrary.ConfigurationSource selectedSource="Winter DAL Configuration">
<sources>
<add name="Winter DAL Configuration" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
filePath="dll.config" />
</sources>
</enterpriseLibrary.ConfigurationSource>
</configuration>
dll.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<dataConfiguration defaultDatabase="WinterContext" />
<connectionStrings>
<add name="WinterContext" connectionString="Data Source=Winter.sdf"
providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
</configuration>
Now, when I'm starting the app, DbContext throws an exception saying it cannot find connection string with specified name. If I move connection string from dll.config to app.config - all working fine.
Maybe I must explicitly load configuration somehow? Or?.. What do I do wrong?
Thx in advance!
Based on the config files supplied, Entity Framework went looking in app.config of root in start project and didnt find the EF content. Especially the Connection string.
When you first used UF it would have created such entries, perhaps in the model project.
IM using EF5.0 so careful with cut and paste on Entity Section .
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<connectionStrings>
<add name="CONTEXT_NAME_HERE"
providerName="System.Data.SqlClient"
connectionString="Data Source=YOURDB_SERVER;Initial Catalog=YOUR_DBNAME;Integrated Security=True;MultipleActiveResultSets=True;App=EntityFramework" />
</connectionStrings>
</configuration>
I hope I understood your question, you want to structure your app.configs as a hierarchy, which is valid, in web applications that is very common, the easiest way to let .net help you with the merging is specifiying the regions of app.config in all those configurations that need to be bounded, and in the inner configurations you can override the values until you have the last one, for example:
ROOT APPCONFIG
<configuration>
<commonCollection>
<add key="first" value="1" />
<add key="second" value="2" />
<add key="third" value="3" />
</commonCollection>
</configuration>
INNER APPCONFIG
<configuration>
<commonCollection>
<remove key="first" />
<add key="first" value="10" />
</commonCollection>
</configuration>
Results:
ROOT APPCONFIG
first : 1
second: 2
third: 3
INNER APPCONFIG
first: 10
second: 2
third: 3
EDIT
for your EF context, to set the connection string in the constructor :
public MyContextDB() :base("name=DefaultConnection")
{
//other initializers
}
hope it helps,
This is a WPF app which references an Entity Framework class library. In the App.config of the class library project I have this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
</configuration>
All very standard. What I want to do is to add a connection string which will enable me to connect to remote server via a URL to the database. Is this going to be possible?
I've tried something like this:
<connectionStrings>
<add name="LanguageEntities" connectionString="metadata=res://*/LanguageModel.csdl|res://*/LanguageModel.ssdl|res://*/LanguageModel.msl;provider=System.Data.SqlClient;provider connection string="data source=http://www.myweb.net:667;User ID=Remote;Password=cleverstring;initial catalog=LanguageModel.LanguageEntities;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
But my app seems to default to the local connection without giving me an error message.
Any suggestions gratefully received.
Many thanks!