Getting rid of App.exe.config - vb.net

I am working on a vb.net application that uses SQLite and since it was compiled against the version 2 of the .net framework, i added this line to my config file
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
My final objective for the application is to make it a standalone, so not a single file except the exe (well the application will generate a file for the database, but my point is i want the user to only download 1 single file).
And i noticed that when i build it, the config file is always copied, and if i run the application without the config file, i would get the uncaught exception "legacy" error..
Is there any way to either include that config during runtime? or perhaps catch some type of exception to prevent that dialog from showing up and scaring the user (i know this probably not the best approach)
I have searched and found other similar problems on SO but none of the questions i found got to a solution that worked for me so i would appreciate your help.

While it is possible to set the legacy runtime policy at runtime, I would recommend deploying as an installer.
well the application will generate a file for the database, but my point is i want the user to only download 1 single file
They could download your installer, which could take care of setting up everything correctly. This is likely to be required in any case, as SQLite will need its own DLLs as well as your .exe to be there in the deployment.

Related

How Can We Determine Which App.Config File Is Loading in VSTO Outlook Add-In?

We have a very strange problem with our VSTO Add-In.
In our Add-In there are label controls that read label text values from an app.config file and display text from the configuration file to the user:
<!-- app.config -->
<configuration>
<configSections>
...
</configSections>
<!-- start applicationSettings -->
<applicationSettings>
<OurVSTOAddIn.MySettings>
<setting name="ackMsg" serializeAs="String">
<value>Some text here that we want to display and change</value>
</setting>
...
<OurVSTOAddIn.MySettings>
</applicationSettings>
</configuration>
'vb.net code
objCheckDialog.lblAttachmentsMsg.Text = My.Settings("attachmentsAckMsg").ToString()
objCheckDialog.lblAttachmentsMsg.Visible = True
We recently updated the app.config file to replace English display information with Kanjii for our end-users in Japan.
When we rebuilt the MSI and installed on our test machine, the add-in isn't displaying Kanjii (although it display correctly in development).
Now we're wondering if the configuration file in the installation directory is being read at all or if the information is cached or the add-in is reading from another file somewhere.
What's even more strange is that we've changed other values in our app.config file that are being used in code logic, and these seem to load properly.
We're currently using Procmon in an effort to find out how the config file is loaded, however, while filtering on the following:
Process Name contains Outlook
Path Contains "OurOutlookPlugInName"
This produces over 400 results but we don't see any file handling for our config file unless I debug the code in Visual Studio.
On our installation machine, we also removed the configuration file from the installation directory thinking this might be a clue as to whether the Add-In is reading the configuration file from the installation directory, but it had no effect, and the Add-In loaded normally displaying English instead of Kanjii again.
All of the configuration settins are at the Application Level.
Is there a way for us to tell where our Add-In is loading our configuration file from?
Have we done something incorrect in our MSI build that would prevent the updated configuration file from loading?
UPDATE:
I opened the dll file in the C:\Program Files (x86)\OurVSTOAddIn installation directory using Telerik JustDecompile to see if the configuration settings were written somewhere in the dll and I can see that under OurVSTOAddIn->My Settings there are definitely DefaultSettingValues there, as shown below:
This would make sense since these are Application Scoped Settings and this would prevent a user from changing config settings.
But I'm thinking if we use Application Scoped variables, each time we'll need to rebuild the msi for release, which doesn't make sense to me since the reason we want to use configuration settings for the project is to not need to rebuild for configuration changes.

Success of reading values from registry depends on if the application was built in IDE or from command line

I'm facing a really strange problem.
I have an application built in C++ Builder 2010. This application reads and writes a bit to the registry. Since it's a 32-bit application these keys end up in the wow6432Node. Every now and then it has appeared as though it has trouble reading the values from the registry. But only when build on the build server (using TeamCity) and never on the dev machines. Often a new commit and a rebuild would make the issue go away so it was hard to diagnose.
After some testing I noticed that I was able to reproduce it on the dev machine to. But only when building from the command line by calling msbuild manually. If the exact same project is built within the IDE there are no issues. But the exe produced when building from the command line, for some reason, can't read values from the registry.
There are no errors or warnings during builds. No files it can't find due to invalid paths or anything like that. Since msbuild is, as far as I can tell, used by the IDE when building to this has me scratching my head. I have tried to manually use different versions of msbuild etc, but nothing works.
So basically, on the same machine, my produced exe behaves differently depending on if I manually started the build from the command line or if the IDE started the build.
What on earth could this be?
After spending a lot of time trying to force the application to use specific registry views etc I was encouraged to look into the UAC manifest settings. I found that the application did in fact have a manifest file, named correctly and in the correct spot. It was also included in the .cbproj file and compiled by the resource compiler.
But, something got me thinking that perhaps it's not being used correctly. After some digging it seems like if runtime themes is enabled for the project that will create a "default" application manifest that will be used.
Disabling runtime themes will allow the compiler to actually use your custom application maniftest file (not exactly well documented, but I have found that to be the case with a lot of Embarcaderos things). By doing this I was able to set the required execution level for the application and things started to work just fine.
You can still manually enable the support for runtime themes in the maniftest file you create. You forms might look a bit strange in the ide since that will think that runtime themes are disabled.
To manually add runtime theme support you add the dependency to your custom application maniftest.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
...
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*"
/>
</dependentAssembly>
</dependency>
...
</assembly>
Save it as Foo.exe.manifest, where Foo.exe is your application name.
You then create a .rc file for your application. For instance FooManifest.rc
#define MANIFEST_RESOURCE_ID 1
#define RT_MANIFEST 24
MANIFEST_RESOURCE_ID RT_MANIFEST "Foo.exe.manifest"
Now you will be able to build your application using your own custom application manifest and still maintain support for runtime themes.

windows forms load report failed

I am developing a Windows Form application using Visual Studio 2010 and framework 4.0. I have a number of reports that this application will use.
My solution is divided up into folders so that I can keep my files organized. I have a process in one folder that is trying to load the Crystal Report located in another folder.
When I try to load the report file, I get an error "Load Report Failed". A Google search says it either cannot find the file or the folder does not have permission to access it. Since this is a WinForms application, I do not think the permissions have anything to do with the error since this application and all its folders are included in the overall assembly. I have tried - in debug mode - to use difference file naming to include the folder using just about every combination I can think of but to no avail.
I cannot see why the error occurs. Any clues?
Dim rpt As New ReportDocument
With rpt
.Load("Form1500_0212.rpt")
.SetParameterValue(0, bID)
.SetParameterValue(1, ProviderID)
.VerifyDatabase()
End With
Dim frm As New frmViewReport()
frm.ShowDialog()
there are a lot of possibilities why this is happening..
first, try to specify the full filepath for this line of code
.Load("fullfilepath")
'e.g., "C:\EmailSys-Phase2\Code\EmailSystem1\xtalReport.rpt"
second, have you installed the runtimes for crystal reports? You can get it here
third, have you tried adding this on your app.config file?
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
fourth, try checking if your target framework is set to .NET Framework 4.0 AND NOT .NET Framework 4.0 Client Profile (I think you're okay with this step already)
I also discovered that you need to change the property for "Copy to Output Directory" needs to be set to "Copy Always" so that the report definition is available in the executable path. Now my code works with this
With rpt
.Load(Application.StartupPath + "\Form1500_0212.rpt")
.SetParameterValue(0, bID)
.SetParameterValue(1, ProviderID)
End With

Dotfuscator : Error after obfuscation

I am using dotfuscator to obfuscate my vb.net application(myapp.exe). But i am getting error while running the obfuscated file.
Below is the error when i open the exe which is obfuscated.
"The settings property 'Import' was not found. ImportSetting"
My application uses .config(myapp.exe.config) file which has setting like below
<userSettings>
<myapp.My.MySettings>
<setting name="Import" serializeAs="String">
<value>True</value>
</setting>
</myapp.My.MySettings>
</userSettings>
If i don't obfuscate then application works fine. The error comes only if i obfuscate the my application.
Procedure i follow during obfuscation:
First i open create new project in dotfuscator.
In add input assembly i add myapp.exe and myapp.vshost.exe file from the bin folder of my project.
In build menu i select destination directory and click on build.
Now obfuscated file will be generated which i will use.
So please help me to solve this error.
You may have to manually exclude ImportSetting from renaming. If this doesn't solve your problem you should probably contact Dotfuscator Support
Note that running the obfuscator will rename everything to hide it's purpose. See here, http://msdn.microsoft.com/en-US/library/ms227212(v=vs.80).aspx.
My guess is that your <myapp.My.Settings> would have to be changed to the obfuscated name. I'm not sure how you would determine that however.
Edit: It looks like dotfuscator outputs a map.xml file that specifies all the stuff that was renamed. You should be able to lookup myapp and see what it got renamed to, then update the .config file.

Team Foundation Server build is transforming web.config TWICE, and the second time is wrong

I have a TFS build definition set up with the following information in the Process -> Advanced -> MSBuild Arguments section: (the [] bracketed values are omitted in this post for security)
/p:DeployOnBuild=True
/p:MSDeployPublishMethod=RemoteAgent
/p:MSDeployServiceUrl=[URL]
/p:DeployIisAppPath=[IISPATH]
/p:UserName=[USERNAME]
/p:Password=[PASSWORD]
/p:CreatePackageOnPublish=True
/p:DeployTarget=MSDeployPublish
/p:Configuration=Development
Here's the issue I have. I have many configurations set up in my web project, and the Development configuration is one of them. If I leave off the "/p:Configuration=Development" and build the project, which then auto-deploys to our dev environment, the web.config transform is wrong. It's replacing my connection string info with the information from another configuration.
If I put the "/p:Configuration=Development" back into the MSBuild arg list and open the web.config file in VS2010 during the build process, the first time the web.config is changed outside my IDE, I can see that the appropriate web.config transform has been made in accordance with the Development configuration, but then the web.config file is changed AGAIN, and it's back to the improper configuration.
My thought here is that when leaving the "/p:Configuration=Development" on, MSBuild is getting it right, but whatever process that is called from MSBuild (I'm assuming MSDeploy) to actually deploy the site to the server is getting it wrong.
Oh, and I'm using an IIS6 server, not IIS7, so any IIS7-specific functionality won't really help me.
Any ideas here of how to fix this problem?
EDIT - Fix
So, some colleagues and I spent some time on this and eventually rebuilt our environments for an unrelated reason. After rebuilding, we started to see the same thing happening. We took a look at the IIS Temporary Compressed Files (C:\inetpub\temp\IIS Temporary Compressed Files) folder and noticed a lot of old info being stored. We deleted everything from that folder and ran iisreset, and the build worked as expected.
-- Original Post
I am having the exact same issue. I have looked at every output file I can think of on the build server and they are all correct. However, when msdeploy is called, the transform seems to happen (based on modified date) but is done wrong. I have also tried grabbing the deployment.zip and importing application on the web sever, which does deploy correctly. Does anyone know how to intercept the msdeploy call from the build server to see what exactly the command contains. I have tried procmon, but not having much luck.