prevent App.Config compiled into the dll VSTO (C# \ .Net) - c#

I checked prior posts like How do I prevent the app.config from being integrated into a .net Library (dll)
but these did not help me with my situation.
I am having trouble keeping my Outlook addin app.config not compiled into the dll. I assume it's being compiled, as when it first loads I ask the application to show me the path of its configuration file using:
MessageBox.Show(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile.ToString());
This returns a path for a file at
C:\Users\...\AppData\ [random name]\outlookadddin.config
instead of using the app.config which is located in the same folder as the the dll itself.
Can I force configuration manager to refer to the dll in the same folder as the assembly rather than creating one of its own?
UPDATE:
after finding this:
how do I make my application read the application config instead of machine.config?
it seems to partially advance a solution, shortly explained, its a known issue with VSTO being deployed via ClickOnce \ MSI. you need to add |VSTOLOCAL to the registery manifest key path.
Problem im facing now, is that if i install my addin on a Network drive, using |VSTOLOCAL it simply won't load, removing |VSTOLOCAL and it works like a charm. any ideas ?

OK i finally found an answer to this:
it appears since vsto 4.0 - you MUST have |vstolocal at the end of the manifest registry key for it to use the .config file from the folder and not from the cache.
My issue was solved by adding |VSTOLOCAL to the regkey, but since i want the addin dll to be placed on a NETWORK drive, this caused trust issues with outlook, which for some reason appearse to be not supporting network drive-installed addins by default.
These were solved by adding this registry key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\vsto runtime Setup\v4]
"EnableVSTOLocalUNC"=dword:00000001
Everything works well now.
Thanks everyone.

Related

Could load a file or assembly "Renci.SshNet.dll"

Issue :
System.IO.FileNotFoundException: Could not load file or assembly
'Renci.SshNet, Version=2014.4.6.0, Culture=neutral,
PublicKeyToken=1cee9f8bde3db106' or one of its dependencies. The
system cannot find the file specified.
The Project is built on .Net Framework 4 which helps to transfer the files from local onto S FTP Server.
The Code works fine on my local machine without any issue,When deployed on the PROD server and run as per scheduled giving the error as mentioned above.
Let me know what exactly causing this issue.
If not installing from the gallery make sure the DLL is not marked as blocked. Windows will mark the zip and every file in it for security reasons and you will have to unblock them
Are you developing windows or web application? If web application, try enabling an option in IIS application pool -> Advanced Settings, "Enable 32 bit application" to true. This might solve your problem.
In case of windows or console application, select the reference Renci.SshNet dll and go to its properties and set "Specific version" to false.
After recently upgrading my .NET connector it gave the same error. I compile and run my app in VS and it works fine guessing because it copies all the MySQL NET assemblies to the exe folder so what I did is copied Renci.SshNet.dll to the directory of my exe and it worked. For some reason adding the path to the path system variable didn't help. Final solution was to remove the NET Connector and use mysqld in batch to do the selects and updates for the app.
Looks like you're missing the Renci.SshNet.dll.
In your project references you can edit the properties of Renci.SshNet. Make sure "Copy Local" ist set to true. It will copy the dll on build to your output directory (should be bin/Release).

GAC_MSIL and Shell Extensions

I've trying to develop while also creating a COM .DLL for my shell icon overlay and context stuff, so i do some search on the tool to make this happens, then i found SharpShell, the shell extension helper tool.
I've been using sharpshell to create an example .DLL, once its generated, i used their "Server Manager" to automatically helps register my .DLL to the registry and the server is loaded properly.
On the Registry, I've seen them registered properly, but i don't see any change in my UI. So i tried to download "Shell Ext Viewer - Shexview - 64 Bit. "
After i opened my shell lists, i saw my Dll was registered there, but they are reading my .DLL files in C:\Windows\Assembly\GAC_MSIL\ folder.
So i tried browsing them in in my Explorer, but i find out that i dont have GAC Assembly.
I further checked articles for help, i found out that they're .nEt extensions, and i also checked my .NET, all of the .NETs from 4.0 are installed properly, but i dont have GAC_MSIL in my assembly. What should i do in order to tell my Shell to open my dll file into a correct file? is there any a way from visual studio where can i register my Dll and server to a specified folder, instead of GAC_MSIL folder, because i am missing it?
Thank you, and i would really appreciate your help !
There are some limitations for OverlayIcons. You have only 15 slots for OverlayIcons. If you have Dropbox or Google Drive installed (or Subversion) > you have already lost, because no slots are available anymore.
But there some way to make bigger Priority for your ShellExtensions. Read here more https://github.com/dwmkerr/sharpshell/issues/93

C# Application publishing issues

I have just created a Windows 7 Desktop Application that allows you to essentially record your screen. I have included all the resources. I am treating it like a "load from CD" type app, as it requires some files as resources. When executing the files to the folder I have made on my desktop, I obviously get the Application files folder, with the manifest and DEPLOY files in; along with the ClickOnce.exe launcher. I then also get the DVD/CD setup.exe file and another clickonce app.
Which installer should I use? And why am I getting these errors? See Below:
When clicking the setup.exe, I receive this error: http://pastebin.com/kgXSnMJY
When Clicking the Clickonce app I get a similar error: http://pastebin.com/1CCT1CKx
What could my issue be?
I managed to avert this, by compiling the files like a "release" inside of a debug. The issue was with the resources I was using, the .dll's did not seem to download correctly (at least I don't think so). Thanks for all the advice and help :)

Loading the application manifest in .NET

I have a ClickOnce application deployed to a virtual machine, Windows 7 32-bit. This application uses some COM components so to get the application working I have created manifests for both the COM assembly and the the application, i.e.
application1.exe and
application1.exe.manifest
comAssembly1.dll and
comAssembly1.x.manifest
Following information from here.
To ensure the application is working, I have run regsvr32 on the COM assembly and all is OK. I then un-registered the assembly and was hoping that all would continue to work. Sadly, it is not the case.
My first port of call was to check my manifests. These match the article referenced above as well as others I have read. So I wanted to check if the manifest was being loaded. I have Process Monitor running and have put a filter on to show only access of files named "application1.exe.manifest", and I don't see any. Having a bit of a google I don't seem to be able to find anywhere that says when then manifest is loaded or by which process.
Have any of you had this problem before? If so, did you discover the cause?
Or is there some magic switch I need in my ClickOnce manifests to tell it to use a manifest file?
And for my own information, when would you expect to see you applications manifest being accessed?
A separate .manifest file will only be used by Windows if the executable doesn't contain an embedded manifest. Problem is that any C# executable already has one. A simple one that's auto-generated by the compiler, it declares the program compatible with UAC.
Project + Add New Item, pick the Application Manifest File item template. It will open in the editor, showing those UAC entries. Move your reg-free COM manifest entries into this one and deploy your app without the .manifest files.

ClickOnce with external EXE will not validate

Here's a famous error I'm getting on VS 2010, using ClickOnce deployment. It works fine locally as well as with a setup deployment. The publishing is working fine.
Here's the error I receive when I try to install the application from the ClickOnce:
'Reference in the manifest does not match the identity of the downloaded assembly CrmSvcUtil.exe.'
I've tried the most popular solution (as well as all the other solution I found on internet) http://geekswithblogs.net/rakker/archive/2007/12/06/117449.aspx
I really don't know what to do. The CrmSvcUtil.exe is in my required files (added by itself... but if I remove it, the ClickOnce stops working at all)
Do you have any other idea of how to fix that? Or a workaround?
Thank you very much!
Is CrmSvcUtil.exe your main executable, or is it an additional executable in your application? It sounds like a change is being made to that file after the manifest has been created such that the file hash no longer matches (this can happen, for instance, if you sign your assembly after the manifest has been created).
Do you have that exe added to your project? What is the build action (should be 'content') and what is 'copy to output directory' ? (should be 'copy always').
Is that executable signed?
Are you publishing with Visual Studio?
Are you re-signing with Mage or MageUI after it is initially published?

Categories