Could load a file or assembly "Renci.SshNet.dll" - c#

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).

Related

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

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.

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.

On server works but after the publishing i get an error

I have ASP.NET v3.5 website project. My project works at visual stduio on server.But after the publishing, i get error.
"Could not load the assembly 'App_Web_wkfb1ehc'. Make sure that it is compiled before accessing the page."
i think this is an Application Pool problem but i don't know how to fix
This is annoying since I have seen this before and I'm trying to recall how we fixed it.
One thing we did do we totally delete the contents of the site's bin folder on the server, then re-deployed. Basically when you compile your site's code, VS will generate these "App_Web_*" names for the DLL files and sometimes a new DLL file is compiled for a page code-behind, but an old DLL for that page is hanging around in the bin folder, which can cause the error you are seeing (at least I think that's was we thought the problem was :) )
Another thing you could do is to set fixed DLL namings for your project. Info on how to do that can be found here: http://msdn.microsoft.com/en-us/library/aa992037(v=vs.80).aspx. If you still get problems after changing that setting, then have a look at this SO question:
ASP.NET WebForms Deployment - Setting the compiled \bin directory DLL names

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?

Clickonce deploy external dll reference not found

I'm trying to deploy an application written in wpf c#. I use an external library (irrklang). I added a reference in visual studio to that dll (it is placed in the same folder as the executable). It shows up in my application files, I deploy, install on a different machine and I get the file not found exception. I looked up the exe folder and the DLL is in the folder.
What am I doing wrong, the reference seems to be correct but the program isn't finding the dll at all
UPDATE: added solution below. Still same error:(
Check the following points:
Properties of the DLL -> Use local copy = true
Project Properties -> ClickOnce Properties -> ApplicationFiles -> Check if your dll is enlisted and manually set "Include" on it.
Then try again. ClickOnce often has annoying bugs.
Found it, the external dll requires the visual studio redistributable.

Categories