I have developed a simple .EXE in Visual Studio 2015, which adds an item to the specified SharePoint site and List when the user runs some process.
The file is saved in a shared network drive, and everything seems to work perfectly except for one detail.
I can't seem to work out how to run the EXE without having the following .dll files saved in the same folder:
Microsoft.SharePoint.Client.Runtime.dll
Microsoft.SharePoint.Client.dll
If I move these from the folder in which the EXE is saved in, I get this error message when running the exe:
Unhandled Exception: System.IO.FileNotFoundException: Couldt not load file or assembly 'Microsoft.SharePoint.Client, Version=15.0.0.0, Culture=neutral ... Or one of its dependencies ...
I (think) I have set up 'strong named assembly' by following these instructions in VS for the app, and I was able to add the SharePoint dlls to the GAC by using the VS command line and gacutil.exe (with a successful confirmation message), but I am still unable to run the EXE without having the 2 .dll files present.
Note: I developed the app to target .NET-4, but the users will be accessing the files from a system with .NET-3.5 installed, however the server on which the EXE is saved on does have the .NET-4 environment.
I was able to achieve this by using a tool called ILMerge which can be found here and is available as a NuGet package.
ILMerge allows you to merge dlls and exe files into a single exe
Related
I have an application that uses a handful of home brewed assemblies that builds and runs fine in VS2015 and when files are copied locally.
When I copy the folder structure from release to a server location, and run the exe from the Mapped drive path (H:/) it fails to find one of my DLL files. If I use the UNC path it loads fine. I have tried using fuslog (Assembly Binding Log) but it doesn't give me any useful information.
If there is any other information you need to help me troubleshoot, then ask away.
Thanks!
NOTES:
Using .NET 4.5.2
I did deploy as "Release"
Other Assemblies load fine and are noted as "operation successful" in fuslog.
I am trying to build a project in C# which uses some unmanaged dll files (MSVCRT.DLL, DFORRT.DLL, ...). There is no direct reference to the MSVCRT.DLL file in the project(this file is referenced by another dll and not directly by my program)
I want this dlls to be copied to bin directory. if i set build action to Content i get this error on run time:
The procedure entry point _wcstoui64 could not be located in dynamic link library msvcrt.dll.
Which is weird. I cant use other build actions because i want my dlls to be published too(Build action=None wont cause any error but doesn't let me to publish my dlls)
If i completely remove all references to all the dlls and treat them like data files, or pictures(files that are not used in code but should be copied to the output) again i get the same error.
What is causing the problem? how can i publish my dlls?
My C# application runs fine (in both Debug and Release mode) when I run it through Visual Studio 2012 or executing the .exe through Debug/Release folder, but it fails when I copy that .exe to some other location and run it. The error message that I receive is:
Could not load file or assembly 'bms.Common, Version=5.0.0.1006, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
I am copying the .exe from Debug/Release folder to some folder. Am I doing it wrong?
In Debug folder exists only .exe file? No other dlls? You should copy all .dll files from Debug folder to target directory along with .exe file.
If you want package all libraries into one executable assembly then look at ILMerge utility http://www.microsoft.com/en-us/download/details.aspx?id=17630
usage:
C:\Program Files (x86)\Microsoft\ILMerge>ilmerge C:\my.exe C:\my.dll /out:C:\merged.exe
Generally speaking, you should be deploying the DLLs in the same folder as the executable. With .NET we don't usually compile everything into one big .exe the same way you might link a c program.
There are certain exceptions: for example, you could put the DLLs in the GAC or put them somewhere else and provide what is known as a "probing path." Those are advanced approaches which should not be used unless you know what you're doing.
For complete information on how .NET resolves DLL references, I suggest you read here.
I have a c# console application that is using JSON and it works fine when run on my development machine. When i try to move the application to another machine to run it i get the following exception when it comes to the part of my code which requires json:
Could not load file or assembly, newtonsoft.json 4.5.0.0
I presume i need to download/install this on the machine i want to run the application on. How would i go about doing that?
Download the Newtonsoft.Json.dll from http://json.codeplex.com/releases/view/107620 and place it in application's BIN folder.
Locate the missing assembly in the solution explorer (under references), right-click and select properties, then select
copy local: true
and the dll will be copied to your output folder and should be distributed with your program.
I had developed a Desktop Application in .Net. I had published and deployed it in my Client's System. But while my client running that setup, an error message is displayed :
Unable to install or run the application. The application requires that assembly Microsoft.SqlServer.Diagnastics.STrace Version 10.0.0.0 be installed in the Global Assembly Cache (GAC) first
What should I do for this ?
Open project Properties form Solution explorer in visual studio
Properties->Publish -> Application Files
In Applications Files window check Show all files at the right bottom. change publish Status of "Microsoft.SqlServer.Types.dll" "Prerequisite(Auto)" to Include click ok and publish Application.
Probably, this dll is not present in Global Assembly Cache.
you can add an assembly to GAC by following command:
GACUTIL –i <Path to Microsoft.SqlServer.Diagnostics.STrace.dll>
to find if STrace.dll file is present on your client computer, you can search it with this command line:
dir Microsoft.SqlServer.Diagnostics.STrace.dll /s
if the file is found, use the previous anwser command line to add the dll to the global asembly cache
If not, you have to add this file as prerequisit in your deployment project
if you have a setup project (lik installshield / MS setup project / Clickonce project, the prerequisit can be added on your setup project properties.
when you add a prerequisit, you should be able to choose if the prerequisit has to be packaged with your application or downloaded from the publisher site.
What solved my problem was I had to do what #ShahidRaees did except include all of the assemblies. I selected all of them except for the file ending in .pdb.
Selecting all of them should automatically update the GAC when you install the program, but I'm not 100% sure.