HtmlAgilityPack Reference not found only after building my application - c#

I have been using HTMLAgilityPack from within Visual Studio without a single problem. I extracted HtmlAgilityPack to my HD, and added the file HtmlAgilityPack.dll as a reference to my C# application. Again everything is working splendid from within Visual Studio. I then built my solution and attempted to run my application outside of visual studio (as a standalone desktop executable file) and I get the following error when I run my application:
"Unhanded exception has occurred in your application. If you click
Continue, the application will .... Could not load file or assembly
'HtmlAgilityPack, Version=1.4.0.0.
Culture=neutral.PublicKeyToken=bd319b...' or one of its dependencies.
The system cannot find the file specified."
How is is possible that the system can't find the file specified? Visual Studio had no trouble finding it...
I can provide any additional information upon request.
Thank you for any help with this one - Evan

I figured this one out. The problem was that I was using an EXPERIMENTAL copy of HtmlAgilityPack. I changed over to the 'full' version HERE and everything works great now!

The assembly HtmlAgilityPack.dll is needed for your program to run. At runtime, the CLR will look for it in several palaces. The most convenient ones are:
GAC
Local directory (that's where VS finds it when it executes it).
So either make sure HtmlAgilityPack.dll is in the same directory as you EXE, or put it into the GAC (using gacutil.exe).

Build the solution not only the project.
Select your solution and press ctrl + Shift + B

Related

"Error while trying to run project: Unable to start program". Can run program only once. Then VS needs restart

I'm running my .NET 4.0 (C#) project in debug mode after I start VS2013. It runs just fine.
The second time I start it from VS, I get the Dialog box that says "Error while trying to run project: Unable to start program C:\path\to\file.exe"
The process is still alive in the Taskmanager when I dismiss the dialog box.
From Windows Explorer, I can run the program just fine. And after closing it, the process is gone too from the Task Manager.
A rebuild doesn't help.
Is this a common problem with a known solution?
I had an issue similar to this and I had to clear the component cache instruction can be found Here.
Hope this helps.
For my case, it cause by Platform target, you could force choose it to x86 or x64 which your project is:
Each Project's Properties > Build > Platform target
As I pointed out also here, the only solution that worked for me was to disable the ConEmu integration:
ConEmu → Settings → Integration → Default term → disable Force ConEmu as default terminal for console applications
Some users reported that it was enough for them to disable the Aggressive mode in that same settings tab; that wasn't the case for me though.
The topic is old, but this might help someone else.
So in my case I made a file in Visual Studio with .cp extension (accidentally deleted the last 'p') this made visual studio just "include" the the file and not mark it as a compilation unit, thus not compiling it, I looked the *.vcxproj file in a text editor and found out about this, so if you open the project file in a notepad or something just find your file at the bottom usually and change from <Item .../> to <ClCompile .../>
I was getting similar errors. I just had to restart visual studio. Sometime couple times a day.
I had a similar error and resolved it by cleaning the solution. Right-click the solution name in Solution Explorer and choose Clean Solution.
I found a solution here:
Please check "Use Managed Compatibility Mode" under Tools|->Options->Debugging->General.
I'm Brazilian, I don't speak English very well. I did this translation on google translator.
I know the topic is old, but it can still help someone.
I had this same problem in the following situation, I have a dual boot computer (linux debian 11 and windows 10). Inside debian, on my NTFS D disk, I created a folder to perform programming tests. After accessing that same folder with windows, I created a new project in visual studio inside that same folder that I had created in linux. The creation of the project went without problems, however when I tried to run the project (F5), I received the same error from this topic. I tried all the solutions I found on the internet, and nothing worked. I gave all permissions to my admin user and it still didn't work. Then I realized that even going straight to the folder where the application's executable was and clicking directly on it, I still received the access denied error message. So, I took the project out of the folder I had created in linux, and it worked. So, what I could conclude, is that because the folder where my project was was created in linux, for some reason, my windows didn't trust this folder, so it didn't allow running executables from inside that folder, even this one executable having been created by visual studio from within windows.
Just simply create a folder name as "projects" in c drive and copy paste the newly created project in it. Run the project by doing clean & Build or Rebuild method . It will work
open the folder which contains the solution in visual studio.
again, open your *.sln file by double clicking it inside the solution explore once opened try running the solution or rebuild the solution. once rebuild gets completed, it will open without error from next time.
My way of solving the error : error while trying to load project : Unable to start program and c:\Path\to\file.exe was simply by
First restart Visual Studio
Click the build icon
Select the rebuild option
Run the Program or Debug the Program
This was a weird one. Going to put what happened to me here because it might happen to someone else. Everything was fine with the app until suddenly after some fairly insignificant code changes I suddenly started getting this error. Visual Studio was compiling the executable just fine. But, the moment I tried to run it (either from Visual Studio or directly) the executable file would be automatically deleted right out of the Debug folder. Super odd--never seen anything like it. I began to get suspicious that perhaps an anti-virus or the OS was somehow identifying a checksum or some signature in the executable as "dangerous". Or perhaps some obscure compilation bug was corrupting the executable. So on a hunch I made another innocuous change (added a couple of lines of code to color code some text in a rich text box) and the problem went away.

What do I need from visual studio to run application without visual studio

I'm not very familiar with VS.
I have inherited a set of VS projects and I can run the one I'm currently interested in within Visual Studio.
But, when I take the generated .exe file and try to run it from the cmd line, I get an error:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ...
So how do I find this missing assembly, where should I put it (ie. in the same folder as the .exe)?
Please point me in the right direction.
I'm presuming you have moved the file from the build folder so I would copy all the dlls in the folder where your exe was built to your new location.
Maybe your machine is missing some asset or libraries (*.dll). i thinks right direction is trying to check the source code, try to compile the source code on your machine to see what is happening on your machine, which kind of file or library are missing. if you dont want to install visual studio, you can try SharpDevelop IDE here http://www.icsharpcode.net/opensource/sd/Default.aspx

Could not load file or assembly itextsharp

I had build setup file from my winform application.
Then I installed it to my other computer, everything was working normally however when I clicked the SaveToPDF button which saves the gridview to pdf file
I encountered with this error :
Could not load file or assembly itextsharp, Version = 4.1.6.15 , Culture=neutral, PublicKey Token=8354ae6d2174ddca'
or one of its dependencies. The system cannot find the file specified.
If I run application from visual studio everything works pretty good.
Therefore while building the setup File iTextSharp content may be lost or while installing from setup iTextSharp content lost.
I'm stuck with this problem and dont know how to fix.
Any help would be appreciated.
Right-click on iTextSharp and select Properties. Set "Copy Local" to True.
Also I'd recommend using NuGet for package management. If setting Copy Local doesn't work or if it's already set to true, remove the reference and using Package Manager Console enter this:
Install-Package iTextSharp
UPDATE:
I tried with the InstallShield 2015 trial. Here's my experience. I'm guessing it's pertinent to your problem:
I tried a Basic MSI project and in Application File I pointed the primary output of the project using iTextSharp assembly. When I built the project I got an error "-6213 - Internal Build Error" Apparently it's a known issue with the .NET projects. Here is their article suggesting a workaround: https://flexeracommunity.force.com/customer/articles/en_US/ERRDOC/Q109089
The suggestion is turning off Dependency Scanning at build. I did that and the project compiled fine. But when I installed it only the exe for the application was deployed and iTextSharp wasn't. So this may be your case. Do you recall disabling scanning dependencies?
I removed the Project Output and added the desired files manually. This time it gave another internal error but fixed it with their suggestion (replacing ISWIScanners.dll with a new one they provide and rebuild). This time I could get all the files I wanted deployed but of course it's not ideal.
I'd suggest adding the files manually and applying the workaround. Alternatively, you can give Wix (http://wixtoolset.org) a go - a free and open-source installer. I haven't used it myself but heard it on DotNetRocks podcast. It's free so it might be worth a shot.
I hope this helps you.

File or Assembly Cannot be Loaded Error

I am working on a Setup program which creates a .msi file. There is a CustomAction program associated with it which is written in C#. There are three COM object references made in this CustomAction program which are necessary in order for it to work. They are as follows.
Active DS IIS Namespace Provide (C:\Windows\System32\inetsrv\adsiis.dll)
Windows Script Host Object Model (C:\Windows\System32\wshom.ocx)
NetFwTypeLib (C:\Windows\System32\FirewallAPI.dll)
As added information, following are the tasks I use these DLLs in my program for.
To set MIME settings for a particular file type.
To create a desktop shortcut to a folder.
To register a program as a firewall exception
.
Now, here is my problem. When I rebuild the C# program and execute the CustomAction program from within Visual Studio, it works fine and I can get the above three tasks done like a charm. However, when I actually build the .msi and try to execute it and install the program on my system, it gives an error. I'm using a Japanese OS so it gives the error in Japanese so I'll try to translate the error message in to English as best as I can. The error is something like this:
*
File or assembly 'Interop.IISOle,
Version = 1.0.0.0, Culture = neutral,
PublicKeyToken = null', or one of its
dependencies could not be loaded.
Cannot find the file specified.
*
This particular error message is given because it relates to the first dll (adsiis.dll) because it is the one which contains the IISOle namespace. Similarly it gives error messages relates to all the three COM objects which I made references to from my program. Now what I can understand from this is, somehow when this code is inside the .msi file it cannot find the appropriate COM objects. I'm really confused why this happens as the Setup gives the same error when I try to install the program even on the same machine which I used to code the CustomAction. Funnily it executes flawlessly from withing Visual Studio Interface. Please do help me with this. Thanks in advance!
Note that I'm working on Windows Vista Business, but I need my Setup to be able to install on a variety of Windows OS ranging from Windows Server 2003 to Windows 7.
Just encountered this today. Go to "Turn Windows features on or off" and scope out everything under IIS, including the IIS 6 stuff.
Make sure that the feature "IIS Metabase and IIS 6 configuration compatibility" is checked, found under "Internet Information Services" > "Web Management Tools" > "IIS 6 Management Compatibility".
Anton, finally I found out what was wrong.
When I reference, for instance, dsiis.dll then Visual Studio places an Interop module, namely Interop.IISOle.dll inside the bin directory of my CustomAction program. Which is where the CustomAction.exe can also be found. It does the same process when I reference the other two COM objects; wshom.ocx and FirewallAPI.dll. But my actual setup program which is written using Wix copies this CustomAction.exe to some other directory and the .msi uses that particular CustomAction.exe file. The problem occurs since Interop.IISOle.dll (and the others as well) cannot be found there. (The error message said what I needed to look for from the beginning it seems; I was foolish not to look for it but thinking there might be bigger problems)
So this is what I did. I instructed the Wix project to copy those Interop DLL files to the same place where the CustomAction.exe which is used by the installer resides. That solved the problem so easily.
I'm totally a newbie when it comes to Wix, plus we needs to use the CustomAction for 2 and 3 because of some reasons.

How to Use Scintilla .NET in C# Project?

I am attempting to use Scintilla .NET in a project (I want a good editor + syntax highlighting, etc). Unfortunately, when I reference the binaries in my project, I can't seem to actually use the Scintilla controls. I get two different errors.
The first happens when adding
SciLexer.dll as a reference to my
project. I get a message that says:
A reference to SciLexer.dll could
not be added. Please make sure the
file is accessible, and that it is a
valid assembly or COM component.
The second error occurs when I try to use the controls from ScintillaNET.dll. If I try to drag the component into a form, I get the following message: Failed to create component Scintilla. The error message follows: System.ComponentModel.Win32Exception: %1 is not a valid Win32 application at ScintillaNet.Scintilla.get_CreateParams()
Any help with either of these problems would be much appreciated. For the record, I am running Visual Studio 2008 running on a 64-bit Windows 7 platform.
Thanks.
It's been a little while since I used Scintilla, but my understanding is that SciLexer.dll is an entirely native DLL, which is why you can't add a reference to it from Visual Studio.
Instead, you should 'arrange' for SciLexer.dll to appear in the right directory at runtime so that it can be loaded by ScintillaNET.dll. The safest way to do this would be to add SciLexer.dll to your Visual Studio project as a plain file (not as a reference), then change the properties on the file to have it copied to the output directory when your project is built.
Given that you're on 64-bit, I expect that you'll need to build your app specifically as 32-bit and not AnyCPU. As I say, it's been a while since I did this, but when I did, Scintilla only had 32-bit binaries.
I got round the issue by copying the files to C:\Windows\SysWOW64
Got the idea from #weston's post.
I use ScintillaNET (C# port). It is easy to use, but it is a memory hog.
https://github.com/jacobslusser/ScintillaNET
Click on RUN and select MyComputer Right click on MyComputer Go to Properties then
Click on Advanced System Settings .
After that select Advanced and Click on Environment Variables.
Here we can add the value and path.
Value : what ever you like " Eg : Scintilla
Value path : where the downloaded dll kept ." EG: D:\prathap\DLL\
Download Path :https://scintillanet.codeplex.com/releases
Select the downloads from right hand side on the screen.
Then in the application add the Scintill Dll as a reference and other 2 dll as existing files.
Right click on project ADD -- Addexisting files -- then select the files from local system and make sure that you keep the 2 files "Copy to Output directory = Copy Always.
Then run the application it will work.
i added reference to Scintilla.dll instead of SciLexer.dll - and it worked

Categories