Change config file for Excel Addin - excel

I have created a VSTO Excel Addin in Visual studio. My project included Setting.Settings file and app.config file.
Basically, the Settings.Settings file contains some settings required for the addin, which are based on user preference.
Currently to publish the Excel Addin, I need to build it everytime according to the user requirements by changing values in Settings.Settings file or app.config value.
Is there any way to include App.config file in separate folder while publishing, so that when user runs setup.exe file he can set up the app.config file as per their requirements.
The Settings.Settings file looks like this:
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings"
CurrentProfile="(Default)" GeneratedClassNamespace="ExcelAddinProject.Properties"
GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="TabLabel" Type="System.String" Scope="User">
<Value Profile="(Default)">Testing</Value>
</Setting>
</Settings>
</SettingsFile>
The app.config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup,
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ExcelAddinProject.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<ExcelAddinProject.Properties.Settings>
<setting name="TabLabel" serializeAs="String">
<value>Testing</value>
</setting>
</ExcelAddinProject.Properties.Settings>
</userSettings>
</configuration>
After deployment the folder looks like this:
| ApplicationFiles
ExcelAddinProject
ExcelAddinProject.dll.config.deploy
ExcelAddinProject.dll.deploy
ExcelAddinProject.dll.manifest
ExcelAddinProject
Microsoft.Office.Tools.Common.v4.0.Utilities.dll.deploy
Microsoft.Office.Tools.Excel.v4.0.Utilities.dll.deploy
System.Configuration.ConfigurationManager.dll.deploy
System.Security.AccessControl.dll.deploy
System.Security.Permissions.dll.deploy
System.Security.Principal.Windows.dll.deploy
| ExcelAddinProject VSTO
| setup.exe
The ExcelAddinProject.dll.config.deploy contains global configs, which apply to all users using this addin. I want to be able, to change this config after deployment.
So, how can I change this config file after deployment?
I tried MageUI it seems to work, but it's complicated for the customer to do on their own.
Any answers would be great help, I tried finding answers but nothing seems to work.
Thanks

Related

IIS V10.0 in Windows 10 does not recognise anymore customErrors on web.config with 500.19 0x80070032 error

I use IIS 10 on windows 10, I was use to have web.config files with customErrors, but now it is not accepting it anymore. I been procrastinating hotfixing just removing the line from the webconfig, but now I am trying to figure out what is wrong and fix it once and for all.
Error Source:
<system.web>
<customErrors mode="Off"/>
<httpRuntime targetFramework="4.6.2" />
The machine config has <deployment retail="true" />, and whit this configuration if I remove the tag IIS works fine and the web application is served correctly, if I change the retail setting to false, it will break again asking for the customErrors to be set.
I could not find any information online on this specific type of issue, and I tried to follow also the error code investigation path, but it leads to TLS configuration which in my case is correct and enabled.
After lots of digging I found that one of the machine.config (for the current framework4x and architecture x64) had a missing section in the system.web group:
<sectionGroup name="system.web" type="System.Web.Configuration.SystemWebSectionGroup, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<section name="customErrors" type="System.Web.Configuration.CustomErrorsSection, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
I copied the section from the 32 bit version of the machine.config and this fixed the issue.
This documentation about IIS configuration hierarchy helped me:
https://learn.microsoft.com/en-us/iis/get-started/planning-your-iis-architecture/the-configuration-system-in-iis-7#:~:text=%20At%20the%20root%20%28or%20global%29%20level%2C%20there,global%20defaults%20for%20the%20.NET%20framework...%20More%20

CodeDom Provider could not be located on IIS7

I have added a site on my IIS but when I try to get to the default page, I get the following 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 CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.
Source Error:
Line 12: <system.codedom>
Line 13: <compilers>
Line 14: <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
Line 15: <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
Line 16: </compilers>
Do I need to install the "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" package with nuget to make it works or is it something different ?
You can comment out the entire System.CodeDom section from web.config.
WebApplication projects will have the CodeDom section, WebSite projects wont. Comment it out and it should start working.
Source:
http://www.codeproject.com/Questions/1034471/Unable-to-run-ASP-net-pages-on-web-server
Try running inetmgr (IIS) right click your website and Choose Convert to Application.
This worked for me.
Maybe do you have different version compiler? Try - Project > Manage NuGet Packages... > Browse(tab) > in search input set this:
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
You can install or update or uninstall and install this compiler
I solved similar issue by installing updates TOOLS->NuGetPackage Installer MENU -> ALL-> Update especially for Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Similar answer to Bayak, you have settings in WebConfig that are not compatible for your web server. Visual Studio can add alot of extra weight to the file by default. Trim WebConfig to:
<configuration>
<system.web>
<customErrors mode="Off"></customErrors>
<compilation debug="true" targetFramework="4.6.1"/>
<httpRuntime targetFramework="4.6.1"/>
</system.web>
</configuration>

SpecFlow + Coded UI - Step Definition Report - Could not load file or assembly

I am not able to extract a Step Definition Report from my project.
The following error occurred:
Could not load file or assembly 'Smoke.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Notes:
specflow.exe.config was added with the suggested content:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0.30319" />
</startup>
</configuration>
Target framework: .NET Framework 4
Platform target: Any CPU
The test project is a Coded UI + SpecFlow project
Any suggestion is welcomed. Thanks!

IISExpress Log File Location

IISExpress writes log and configuration data to pre-determined location out of the box.
The directory is an "IISExpress" directory stored in a user's Documents directory.
In the directory is stored the following folders files underneath.
Config
Logs
TraceLogFiles
The location of my home directory is on a network share, determined by group policy
Currently we are encountering scenarios where visual studio locks up when stopping debugging Silverlight applications using IIS Express.
I was looking to change the location for the log & configuration data for IISExpress to see if this fixes the problem of visual studio locking up. Is it possible to change the default location of log & config files ?
1 . By default applicationhost.config file defines following two log file locations. Here IIS_USER_HOME would be expanded as %userprofile%\documents\IISExpress\.
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" />
</siteDefaults>
You can update above directory paths to change the log file locations.
2 . If you are running IIS Express from command line, you can use '/config' switch to provide configuration file of your choice. Following link may help you http://learn.iis.net/page.aspx/870/running-iis-express-from-the-command-line/
http://www.iis.net/configreference/system.applicationhost/sites/sitedefaults
<configuration>
<system.applicationHost>
<sites>
<siteDefaults>
<logFile
logFormat="W3C"
directory="%SystemDrive%\inetpub\logs\LogFiles"
enabled="true"
/>
<traceFailedRequestsLogging
enabled="true"
directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles"
maxLogFiles="20"
/>
<limits connectionTimeout="00:01:00" />
<ftpServer serverAutoStart="true" />
<bindings>
<binding
protocol="http"
bindingInformation="127.0.0.1:8080:"
/>
</bindings>
</siteDefaults>
</sites>
</system.applicationHost>
</configuration>
I find web.config documentation is a messy. It is therefore better to provide a complete parent history than a floating snippet with the expectation that the reader naturally knows where it goes.
By default it will be in:
C:\Users\ user_name \Documents\IISExpress\Logs\

Is there a way to force the refresh the meta model, which SubSonic builds after a DDL change in the DataBase

E.g. when I add a new table it does not appear in the Northwind namespace untill I remove the project folder from :
C:\Users\userName\AppData\Local\Temp\Temporary ASP.NET Files\
or add and readd the SubSonic.dll
I have the following configuration :
<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic"></section>
....
<SubSonicService defaultProvider="Northwind">
<providers>
<clear/>
<add name="Northwind"
type="SubSonic.SqlDataProvider, SubSonic"
connectionStringName="Northwind"
generatedNamespace="Northwind"/>
</providers>
</SubSonicService>
<connectionStrings>
<add name="Northwind" connectionString="Data Source=.;Database=Northwind;Integrated Security=true;"/>
</connectionStrings>
....
<compilation debug="true">
<buildProviders>
<add extension=".abp" type="SubSonic.BuildProvider, SubSonic"/>
</buildProviders>
...
<pages>
<controls>
<add assembly="SubSonic" namespace="SubSonic" tagPrefix="subsonic"/>
The issue here is that the BuildProvider doesn't "go off" unless you change the abp file in App_Code. It's a hack, but if you want it to work you need to open that file up and change it somehow by adding a space or something - then it will kick off the builder.
I'm working on some T4 templates so you don't have to do this. Also - you can use our commandline tool to generate the stuff to file for you:
http://subsonicproject.com/subcommander/using-the-command-line-tool-subcommander/
Thanks, both worked !
Either as you said to simply change the *.abp file ( added couple of spaces)
or
sonic.exe generate /config "D:\path\to\my\web.config"
P.S.
I have a D:\temp\utils folder , where I keep all the command line tools used ... and it is part of the %PATH% environmental variable ...
and it took me couple of minutes to realize that I had to copy the whole :
D:\libs\orm\SubSonic_2.1_Final_Source\src\SubSonic\bin\Debug directory to that command line tools folder ...
Edit: Even faster with VS External Tool command :
Tools - External Tools - Add
Title: SubSonic
Command: D:\path\to\sonic.exe
Arguments: generate /config "D:\path\to\my\web.config"
Initial Directory: {$ProjectDir}
Tools - Options - Keyboard
Find tools Subsonic
for it to work from anywhere on the command line

Resources