I am using electron-edge-js to call a C# DLL.
Within the DLL, the App.config file is called out for server connection information.
return (ServiceDetailConfiguration)ConfigurationManager.GetSection(ServiceDetailConfiguration.ServiceDetailConfigurationConst);
In my js file calling the dll, I can successfully call out to the dll, and process information. That is, until I hit the above line, I get a null exception thrown as it can't find the app.config.
I've tried the below:
Load WCF app.config bindings in edge.js app
working with electron-edge-js for existing dll with app.config
Without much luck.
In my package.json file, the name is "firstelectronapp".
When i build the file, I output it as "test.exe"
So i've attempted these files in the same root folder as the test.exe file with no luck:
first.exe.config
firstelectronapp.exe.config
test.exe.config
node.exe.config
Is there something I'm missing? I wrote a quick C# app with an app.config that calls the dll, and when stepping through it I can tell that's what the issue is.
The config file should be renamed electron.exe.config and placed in the same directory as electron.exe - i.e. node_modules\electron\dist.
I just ran into this when needing to add a bindingRedirect. Putting it in the above file solved it.
Also, if you're using electron-builder for packaging the app, you can easily include the config file in the packaged application by adding it to the extraFiles collection in the build configuration, for instance:
"extraFiles": [
{
"from": "app.config",
"to": "my-electron-app-name.exe.config"
}
]
Related
When Running a console app packaged to a single .exe with costura.fody I appear to be unable to access my app.config resulting in the error
System.InvalidOperationException: No connection string named 'volumeEntities' could be found in the application config file.
at System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()
When I test in my nunit test project the app.config I added there which contains the connection string works.
I have an app.config added to the only other project in the solution.
It contains the correct connection string
In properties the Startup Object is set to 'Uploader.Program'
Am I missing some way of setting the project as the start up rather than the program class? How can I get the executable to find the app.config?
Fody costura does not package the app.config file with the executable so that you can change information in the app.config without recompiling. Copy the .exe.config to the same folder as the executable.
I am very new to C# and I have read several posts about using configuration files. I have perhaps a very basic question I have been unable to find an answer to. I created a Config folder inside my project to put some path information for input/output files. There also seems to be a Config folder inside the \bin\debug\folder. My App.config file points to Config\appSettings.config. I can't figure out which Config folder is getting used in my project. Is it the Config folder I created or is it the Config folder inside the \bin\debug\ folder? Thanks in advance for any help and I hope I followed all the rules for posting a question.
I think that it's potentially both files.
Whenever you build your application, the compiled .exe, .dll and .config files are copied or written to the \bin\debug folder. The application is then run from the \bin\debug folder. The App.config file in your project directory gets automatically transformed into a file called ProjectName.exe.config which is what the ConfigurationManager class looks for.
If you use configSource in your App.config file to reference another configuration file such as Config\appSettings.config then this will also need to be copied to your \bin\debug folder so that it can be can be accessed when your program is run.
I have created a WCF web service which has references to some class library (BO.dll,BLL.dll,DAL.dll) ,and invoke their methods . one of the libraries(DAL.dll) need a config file to read some settings like connection string . then the config file is located near to the dll files .
but when I use the service, it has error which the "could not find file C:\windows\microsoft.NET\FrameWork\v4.0.30319\Temporary ASP.NET Files\SampleService(some temp folder)\myConfigFile.config"
I should say that, dll code read the config file as a simple xml file. and extract the settings.
why it looks for in this address ?
where should I put the config file to be accessible by the dll ?
It is because for DLL you need to use your webservice's configuration file for DLL if you are reading connection string using
System.Configuration.ConfigurationManger.AppConfig class.
Otherwise you can reading manually.
This link might help you
Reading dll.config (not app.config!) from a plugin module
I am building an application that calls upon a compiled executable. Said executable's source code project file is referenced by the solution file for the parent application. The child executable is a stand alone command line application. The parent is a effectively a GUI wrapper to the console application. When I compile the console application, I have access to all of log4net's functionality that has been built into the application. However, when I compile the parent project that references the console application's source code files, everything runs correctly but no logs are generated. What would cause this error to occur, and how can this occurrence be fixed? log4net's internal debugging mechanism doesn't throw any messages.
For log4net to start logging within the referenced assembly you will have to:
Call the Configure() function of log4net by either calling log4net.Config.XmlConfigurator.Configure() when your application starts, or by adding [assembly: log4net.Config.XmlConfigurator(Watch=true)] to the AssemblyInfo.cs file of your wrapper application.
Create an log4net configuration section in the app.config for your GUI wrapper if you haven't already done so. Add an app.config file to your project, and copy your log4net configuration information from the referenced library into it.
Ensure that the account running the application has access to write and create files within the log directory (assuming your using file-based logging).
For more info about setting up your config see: http://logging.apache.org/log4net/release/manual/configuration.html
I know it's too late but anyway just for reference.
Set log4net.Internal.Debug = true in your application and you might see the problem on the console. (do this programmatically since your application might not be able to find it's config file, which was what happened in my case)
On the Process p, after you exec the process using p.start() try to write the stdout to console with this;
Console.write(p.StandardOutput.ReadToEnd());
You should be able to see the problem. (why log4net isn't getting configured or why it isn't logging)
In my case it was looking for the app.config file in the parent process's working directory. (my app and it's config are present elsewhere on the file system)
I have a config file in my C# class library called MyLibrary.config, in vs 2008.
I created another project, say a simple console app, add reference by "Browsing" the MyLibrary.dll in the bin directory of the class library project, and when I compile, the MyLibrary.config is not including in the bin directory of the output in the console app.
How can I set it so I can include it when I reference the dll?
Cheers
You can't. Your console application is expecting to find a config file with prefix the same as the name as the console application (MyConsoleApplication.exe -> MyConsoleApplication.exe.config.).
In some situations you can share a config file by using the file attribute on the appSettings element:
<appSettings
file="path">
</appSettings>
Note that path is relative to the executing assembly.
As a side note, DLLs do not even use the config file that you've defined in the project. Again, configuration information is read from the a config file with prefix the same as the executing assembly. Thus, even when MyLibrary.dll tries to yank configuration information out of a config file, it will be reading the config file for the executing assembly, not MyLibrary.dll.config.
For more on how config files work, see MSDN.
The standard way to use a config file is to have it the same as the executable, adding a reference to a dll will not include its config file and as far as I know dll's don't load config files on their own, rather they rely on the executable that reference them.
Beyond not being able to do this, I would also advise against this approach.
Rather than trying to tighly couple your settings to the DLL library, consider more of a "Dependency Injection" type approach - i.e. where you pass in the value dependencies (i.e. settings) to the code you are calling (i.e. the library).
The advantage in this is you are not tied to a single method of storing settings. You can then use a database, different config file formats... even hard-coding. It also makes unit testing easier by removing the external file dependency.
There are different ways to implement this, however one example is to pass the configuration settings into the constructor of the class(s) that uses them.