Log file not created in the appData in VSTO using log4net - vsto

I have created an addin using VSTo 2010 and my application as soon as it starts, the folders are created in the AppData path. For my other windows desktop application, the log file is created as soon as the application starts up, and the same implementation is used for my addin also. Bu I am getting an error saying "Couuld not find part of the path". The file name is configured as ${APPDATA}\My Application\Project\My Project\ExcelLogs.log. I have copied the Excel.exe.config to the programFilesx86-> Microsoft Office -> Office 14. And have added [assembly: log4net.Config.XmlConfigurator(Watch = true)] in the assemblyInfo class. The AppData path is configured as m_strGeneralFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Config.APPDATA_PATH; But still as soon as the application starts i get the error.

Related

VSTO appSettings of Word AddIn cannot be changed after using MSI installer (generated through Wix)

I have a Word AddIn which uses one setting to retrieve information from a webservice. This setting is stored in de settings section of the project (see image)
To be able to change this setting after the application is compiled, the access modifier is set to public. When I compile the application and use it in Word, I only have to change the ConfigURL in de [applicaitonname].dll.config. This works perfectly, the new URL is applied when trying to retrieve information from another webserivce address (URL).
In this project, I also have a Wix project to create an MSI for this AddIn. Now when I use the MSI to install the AddIn on a computer and after the installation, I change the ConfigURL, the new value is not applied, it still uses the value which was set when creating the MSI.
does anyone know if it is possible to create an MSI for deployment, and still able to change settings values in the config file after installation?
I assume that your Wix project installs the AddIn in the Program Files folder. If that's the case then most likely your user doesn't have the write permissions to this folder. You can either adjust your Wix project to setup necessary permissions to the AddIn's folder or deploy your configuration file to a different location e.g. %APPDATA%\Roaming\[AppName].
From what I've found the VSTO customization DLLs are always loaded from a temporary folder location and not from the original location irrespective of whether ClickOnce cache is used or not. The location of the temporary folder is the Shadow copy folder of .NET framework which is mentioned under the registry key HKCU\Software\Microsoft\Fusion\DownloadCacheLocation.
Shadow Copy is a feature where DLLs can be updated while they are being used. To implement this feature, DLLs are copied to a temporary location when they are being used so that DLL at original location can be updated.
The Shadow copy feature has been used in VSTO from the initial version and there is no way to disable it. Shadow copy can be disabled for .NET AppDomain while creating an AppDomain but in the case of VSTO customization, the developer has no control over the way AppDomain is created and hence cannot configure the behavior.
In order to load a configuration file, it must be located in the same folder where the assembly is loaded from. Unfortunately, your config file does not get copied to the shadow cache so it seems it uses some hardcoded values.
In order to solve this issue, you can explicitly load a configuration file from the installation folder. Take a look at this answer for more information.

"Configuration System Failed to Initialize" when .Net Executable moved to Program Files (x86) folder

I have a baffling one: A call to GetSetting from within my VB.Net (v4.5.2) Windows Forms app results in a "Configuration System Failed to Initialize" error--but only when the .exe and the .exe.config are moved to their deployment folder in C:\Program Files (x86)\MySubfolder. As soon as I drag the same two files out to the desktop (or anywhere else) it runs without error. (And for that matter, the development copy runs as well).
What could be causing this, and what steps can I take to troubleshoot?

My program stop working after I upgraded to windows 10

The program used to do fine. Then I upgrade to Windows 10 and now I have these 2 error when running the program in Visual Studio.
Warning 1 : Cannot find wrapper assembly for type library "Microsoft.mshtml". Verify that (1) the COM component is registered correctly and (2) your target platform is the same as the bitness of the COM component. For example, if the COM component is 32-bit, your target platform must not be 64-bit.
 
Error 2 : Unable to open module file "C:\Users\jim2\AppData\Local\Temp.NETFramework,Version=v4.0.AssemblyAttributes.vb" : The system cannot find the file specified.
Basically, my code builds fine when I was in windows 7. I upgraded to windows 10 and then I got this error.
I've checked C:\Users\jim2\AppData\Local\Temp\ folder.
There is no file .NETFramework,Version=v4.0.AssemblyAttributes.vb. I don't know how it happened in Windows 7. In Windows 7, before I upgraded, the program compiled just fine.
It seems that this issue is about files that are not there, but searched by project. After deleting it from project the files got created. Now, I still have the same problem.
I guess you are referencing INTERNET EXPLORER which is NOT installed into that Windows 10. The default browser is EDGE and probably the called function of IE is not present in that new browser.
Your question needs more details...
UPDATE:
The Microsoft.mshtml.dll file is a PIA file (from Office). You can try one of these solutions (it may vary sometimes from machine to machine):
1) remove Microsoft.Mshtml.dll reference from your project.
2) Use ADD REFERENCE, NET, select the PIA file
3) In DLL properties, set the COPY LOCAL = TRUE.
But, if the system reports "The module is not signed", you may also try:
1) remove Microsoft.Mshtml.dll reference from your project.
2) Use ADD REFERENCE and choose BROWSE.
3) Point to "C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies" (it depends of x32/x64 systems) and select directly the microsoft.mshtml.dll file.
4) Set the COPY LOCAL = TRUE too.
I just want to add to David BS answer.
It seems that the original microsoft.mshtml is gone in windows 10 and deleting and referencing it works. No need to set copy=true, etc.
I am using version 7.0.3300.0

TFS Build 2010 CodeActivity: Cannot Load Assembly in XAML

I am attempting to add a custom “activitycode” to a TFS Build. I wrote this months ago and had it working on a now defunct test environment. I am attempting to resurrect the use of the code onto a new test platform, and am running into issues.
When I open my build.xaml, I receive the dreaded red-box of pain where my custom activity should be, stating “Assembly could not be loaded because of an error in the XAML.” In the ErrorList, I also have found “Could not find type '.DeploySSRSReportActivity' in assembly 'ReportingServicesDeploy'.”
I have confirmed that my DLL is checked into source control and that the build controller is pointing to it.
Peeking into the raw XAML, I see that the build.xaml file defines the assembly as
xmlns:rsd="clr-namespace:;assembly=ReportingServicesDeploy
The line where my custom activity (and where V.S. finds the error) is:
<rsd:DeploySSRSReportActivity CurrentBuild="[BuildDetail]"
SourcesDirectory="[SourcesDirectory]"
mtbwt:BuildTrackingParticipant.Importance="High"
xmlns:mtvc="clr-namespace:Microsoft.TeamFoundation.VersionControl.Client;assembly=Microsoft.TeamFoundation.VersionControl.Client"
xmlns:mtvco="clr- namespace:Microsoft.TeamFoundation.VersionControl.Common;assembly=Microsoft.TeamFoundation.VersionControl.Common"
xmlns:ras="clr-namespace:ReportingServicesDeploy;assembly=ReportingServicesDeploy"
xmlns:rsd="clr-namespace:;assembly=ReportingServicesDeploy"
xmlns:sad="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:sad1="clr-namespace:System.Activities.Debugger;assembly=System.Activities" />
The DLL is named ReportingServicesDeploy.dll. The namespace within the DLL is ReportingServicesDeploy, and the name of the activity class is DeploySSRSReportActivity.
Where is the linkage failing so that I am getting that error?
When your attempting to edit the xaml your doing this on your machine directly, tfs and sourcecontrol is not involved, the location on server for controller is where build agent will look for assemblies during the build and where VS will get them when opening build definition for config.
Your error possibly is coused by old version being used.
The assemblies must be available for visual studio on your machine - one option is to add them to GAC or to post in VS bin folders. Start new instance of studio afterwards
To intall into GAC run this from Visual Studio command line:
gacutil /i "Path\To\YourAssembly.dll"
To remove assembly run following from Visual Studio command line:
gacutil /u "YourAssembly"
For studio assemblies i believe this is the folder:
Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies

Location of VB.NET Windows Service My.Settings - settings

I have a VB.NET solution built in Visual Studio 2010. It consists of a class project, a service, and a setup project. I have successfully created a setup, and run the setup from the "Release" directory of the setup project (outside of Visual Studio). It installed the service (on the same machine as where the project is), and the service seems to be running fine. The service executable is installed in a directory under c:\program files (x86)\ along with some DLL's it is dependent of.
The service (actually the class project I mentioned above) uses some settings from My.Settings. As far as I know these settings are stored in a app.config file in the project directory, as well as in a settings.settings file in the My Project directory under the project directory.
Neither of these files are installed by the installer. But the service can only run if it can read the settings. So where does my service get these settings from? To check if it still reads the settings from the VS project directory, I have temporarily renamed that directory, but that didn't affect the correct operation of the service.
look on this path. Find your service name and navigate down until you find user.config
C:\Windows\System32\config\systemprofile\AppData\Local\
The user.config only has the settings that your service has updated the others will in the exe.config on the service install path.
Protected Overrides Sub OnStart(ByVal args() As String)
My.Settings.TimerMsInterval = thisTimer.Interval
My.Settings.MoreMsgs = My.Settings.MoreMsgs
My.Settings.LastTime = My.Settings.LastTime
My.Settings.Save()
EventLog.WriteEntry("Startup Parameters: TimerMsInterval: LastTime: MoreMsgs " & thisTimer.Interval.ToString & " : " & My.Settings.LastTime & " : " & My.Settings.MoreMsgs)
End Sub
Have a look in the Virtual Store C:\Users\User_name\AppData\Local\VirtualStore\
I found the answer myself: the settings of the class project are stored within the class projects DLL-file. So they cannot be edited after the service (that uses this DLL) has been installed.