Unable to install or run the application....in Desktop Application - c#

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.

Related

ClickOnce deployed application can't find external DLL

I have this WinForms application that uses an external dll file (Winppla.dll) so I can print tags in my Argox printer. Since I cannot add the dll file as a reference to the project, I use the command [DllImport("Winppla.dll")] on my class.
When I run the project in Visual Studio, it works perfectly.
Then I published my application using ClickOnce and when I try to run the application, I get the message error saying that the Winppla.dll could not be found, even though I am running it on my machine.
I tried to:
copy the file to the bin folder of the project before publishing
copy the file to the packages folder of the application before publishing
copy the file to the latest version folder on the Application Files folder (on the publishing location of the application)
add the file as a resource on the project
add a folder with the file as a Reference Path on the project
but none of these worked.
This project also uses SAP CrystalReports, and it works just fine.
Any ideas about how to make it work?
Following #Bearcat9425 instructions in the comments section of the question, I finally solved the problem:
Copy the file to the project folder and include it on the project
(on Solution Explorer, click on 'Show All Files', then right-click in the file and select 'Include In Project')
Mark the file as one of the application files on my publish tab
(right-click on my project and select 'Properties', then go to Publish tab and click on 'Application Files' and make sure the Winppla.dll is marked as 'Include')
Copy the Winppla.dll file to a shared folder in our server (I placed it on the same folder where I placed the setup of my application)
On each DllImport command write the complete path to the file shared location: [DllImport(#"\\the-path-on-the-server\Winppla.dll")]
Publish!

How to update the assemblies and file using setup project?

I've created a windows application in C#. The application has check for update feature. Whenever an update to the application is available, it downloads the setup file.
When we run the new setup it is successfully installed and we can see the new version in control panel. But the problem is that the assembly files and other files in installation directory are not updated. They are still the previous version of files.
I have set the following properties of the installer project:
- DetectNewInstalledVersion : true
- RemovePreviousVersion: true
Am I missing any property of setup project or is there any other approach to do that. I don't want to use any third party tool for setup creation.
You must increment the file versions of those files that need replacing. That's because of the Windows Installer file replacement rules.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa367835(v=vs.85).aspx

How to include SharePoint assemblies in EXE after publishing

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

How to include the reference of DocumentFormat.OpenXml.dll on Mono2.10?

I am using C#.net Windows Desktop Application.I want to run these application with other platform also. So, i am using Mono 2.10 as a cross compiler.While running,unexpectedly my Application is terminated by saying the error message like
Error:Could not open the selected folder.
Could not load a file or assembly 'DocumentFormat.OpenXml.dll,version=2.0.5022.0, culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
I don't know what is problem here...I have installed openxml sdk2.0 on c:\program files\open xml sdk\v2\lib\DocumentFormat.OpenXml.dll.
and also put my application eXe on on the same place for testing purpose...
Please guide me to solve this issue...
Being new to this myself, here's what I did:
I'm using MS Visual Studio 2010 Pro.
Download and install the OpenXML SDK
Within my project in Visual Studio, select "Project" then "Add Reference"
Select the "Browse" tab
In the "Look in:" pull down, navigate to:
C:\Program Files(x86)\Open XML SDK\V2.0\lib and select the "DocumentFormat.OpenXml.dll
Hit OK
In the "Solution Explorer" (on the right for me), the "References" folder now shows the DocumentFormat.OpenXML library.
Right-click on it and select Properties
In the Properties panel, change "Copy Local" to "True".
You should be off and running now using the DocumentFormat classes.
You should also ensure you set a reference to WindowsBase. This is required to use the SDK as it handles System.IO.Packaging (which is used for unzipping and opening the compressed .docx/.xlsx/.pptx as an OPC document).
select DocumentFormat.OpenXml under references , view it's properties, and set the Copy Local option to True so that it copies it to the output folder. That worked for me.
Goto Nuget Package manager and search for openxml. And install DocumentFormat.OpenXml
What worked for me:
Add a folder to the project call it ThirdParty.
Add in the ThirdParty folder both DocumentFormat.OpenXML.dll and WindowsBase.dll
Make sure the the project uses the ThirdParty dir as reference for both the DLLs
Build and published to an external server.
Well, In my applications I just need to Add a reference to "DocumentFormat.OpenXml" under .Net tab and both references (DocumentFormat.OpenXml and WindowsBase) are always added automatically. But They are not included within the Bin folder. So when the Application is published to an external server I always place DocumentFormat.OpenXml.dll under the Bin folder manually. Or set the reference "Copy Local" property to true.
You need to have DocumentFormat.OpenXML.dll in the same folder as your application - or in the 'bin' path if you are developing an ASP.NET application. However, I'm not certain that the OpenXML SDK is supported on non-Windows operating systems - you may need to look into a third-party solution.
Yes, this answer is right, the only difference is that you copy your .dll into bin folder of the project.
After viewing and changed the properties to DocumentFormat.OpenXml, I also had to change the Specific Version to false.
I found that when mixed with PCL libraries the above problem presented itself, and whilst it is true that the WindowsBase library contains System.IO.Packaging I was using the OpenXMLSDK-MOT 2.6.0.0 library which itself provides it's own copy of the physical System.IO.Packaging library. The reference that was missing for me could be found as follows in the csharp project
<Reference Include="System.IO.Packaging, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\OpenXMLSDK-MOT.2.6.0.0\lib\System.IO.Packaging.dll</HintPath>
<Private>True</Private>
</Reference>
I downgraded my version of the XMLSDK to 2.6 which then seemed to fix this problem up for me. But you can see there is a physical assembly System.IO.Packaging.dll
The issue for me was that DocumentFormat.OpenXml.dll existed in the Global Assembly Cache (GAC) on my Win7 development box. So when publishing my project in VS2013, it found the file in the GAC and therefore omitted it from being copied to the publish folder.
Solution: remove the DLL from the GAC.
Open the GAC root in Windows Explorer (Win7: %windir%\Microsoft.NET\assembly)
Search for OpenXml
Delete any appropriate folders (or to be safe, cut them out to your desktop in case you should want to restore them)
There may be a more proper way to remove a GAC file (below), but that is what I did and it worked.
gacutil –u DocumentFormat.OpenXml.dll
Hope that helps!

how to deploy my application?

I want to deploy my application. i followed this step but i can't get the .exe file. steps:
Step I:
Create one Windows based application in VS.Net using any of the Languages i.e. C# or VB.Net.
Step II:
After your program is running and you are ready for the setup. To add setup to your existing application go to Go to File > Add Project > New Project.
After your program is running and you are ready for the setup. To add setup to your existing application go to Go to File > Add Project > New Project.
The window appears like below and you select the Project as Setup Project and give a Name and its Location.
Step III:
After creating setup project right click on project and than select view, it will show different possible operations, which you can perform with this setup project.
The options available are
File System
Registry
File Types
User interfaces
Custom Actions
Launch conditions
Step IV:
Click on File system, it is used to create file system on the target machine. Through this you can specify what details you want to provide at the target machine.
Step V:
Now in the new window, its time to add the files & folder’s used by the application.
First we add the Project Output file. Click on Project Output and a new popup appears. Select the appropriate choice. For a normal project we select as Primary Output File & Content Files.
it is used to create file system on the target machine. Through this you can specify what details you want to provide at the target machine.
To add Icons/Any specific folders, click on Add > Folder and Folder is added. Rename the folder as per your project requirements
After the Folder is create then add the files to the setup. These will be installed in the same fashion on the target machine
Step VI:
Now we are about to create the setup before that we will setup the program icon. To do it we will do this process :
When you click on Browse, a window gets popup. Now as the icons are already added into the application setup, just click on Browse to pint to that icon and click on ok.
Step VII:
Now final step is compile the setup project. After compilation you will notice that it has generated Setup.msi in the same location which you provided when you initially created the setup project.
You can supply this msi the target machine, when you run this msi at target machine it will create a virtual directory as well as create same folder structure, which you have specified in File System. This installer will also install the specified those libraries in the registry which are specified in the Registry.
Now you can browse that application at the target machine in same way as you have done at your own machine.
What I could understand is, you have got some problem with deploying the EXE file.
This is the best tutorial I have ever seen for creating EXE or MSI files:
http://balanagaraj.wordpress.com/2007/05/29/create-exe-or-setup-file-in-net-windows-application/

Categories

Resources