How to Use Scintilla .NET in C# Project? - c#

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

Related

Can't rebuild my application anymore

I'll give you 2 versions of my problem to describe it, first the short version.
When I try to build my application it does that perfectly and my app works but when I try to rebuild it, that fails and gives an error message saying that 2 files are missing (bin/debug/MusicPlayer.exe and bin/debug/MusicPlayer.pdb). When I then try to build normally, it fails to with the same error.
Now the longer version:
The way this happened was quite out of nowhere, I program on 2 different locations (both in Visual Studio 2010 sp1) but to always have the recent version in the right place I copy the entire solution folder to a usb stick, this folder I copy over again on the other PC and use it to continue were I left off, I've done this many times without problem. Yesterday however, I got an exception while testing the app. But instead of showing this in my code, it was complaining that it could not find the program.cs file (it was there, but apparently it had a different checksum (md5) and it asked me to use this one. After a while I found what part of my code caused the exception and fixed it. Since then I haven't got that error anymore. But when I later tried to rebuild instead of build, it gave me the error described in the short version. I have tried to fix it, but apparently I was not very successful.
Basically, what I think it does is delete the files in the debug folder that need rebuilding and then gives me the error of missing files (the files that it deleted) and thus failing to rebuild succesfully because these deleted files the normal build option won't work to.
(What I then do is re-copy them from my usb to make the normal build work).
Don't know if it's important, but I program in C# and I'm still learning.
Also when I copied it to my usb I believe I had no errors and the app was working fine (except the part I fixed later, which I could not test at that location). And when I build the entire solution it gives some warning ==> "Assembly 'bun/debug/MusicPlayer.exe' is incorrectly specified as file" and this for 5 files.
Does anyone know how to fix this rebuild problem and if necessary the warnings?
Thanks in advance
(and sorry for my bad English)
OK it seems like you might be confusing yourself with your directory structure here. If you want to add Content or Resources (Images, Text Files, etc.) you should place them in a folder within your project (not called bin or obj). All your build files will go here. Instead place the Content in another folder and Right Click -> Properties and Set the build action to "Content" or "Resource" and set the Copy to Output Directory (bin folder) to "Do not Copy" or "Copy if newer."
The project is failing because you have the built executable "MusicPlayer.exe" in your project. So Visual Studio is trying to build an executable file in adding to the project. Restructure your directories or remove "MusicPlayer.exe" ever time your build your project.
Do you have any anti-virus software running? They can go way too aggressive on removable drives. You are actually continuously deleting and creating a runnable program on usb stick by recompiling.
Just a guess tho...
Sounds to me like you have a pre- or post-build event with a hardcoded path in it. Fix that using variables and it should be ok.

HtmlAgilityPack Reference not found only after building my application

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

How to Setup Sqlite for HHpc/Windowsce Device in Visual Studio Smart Device Project?

In winforms application/asp.net sqlite works if i reference sqlite.dll.
But when i try this to smart Device Project it fails to build because
of this error:
Can't find PInvoke DLL 'SQLite.Interop.DLL'.
What did i did is also reference system.Data.SqLite.dll in my project file, add also it windows folder of my device(Windows SE Emulator/Datalogic Memor windows ce 5.0).
Any one here experience this and resolve this problem?
Currently i am using SQLcompact 3.5 for the handhelds but i encounter drawbacks in terms of speed and capacity and i know that sqlite will solve it.
Thanks in Regards.
I Got the solution:
We need to Add SQLite.Interop.066.DLL in the project root folder.
Then right click to SQLite.Interop.066.DL to view its properties.
Next Set its Build Action = Content
and
Copy to Output Directory = Copy if newer
Rebuild/Build the project and try to test it again.

Why won't the debugger update?

Ive had this problem multiple times and it ruins my projects, I make some changes, like say I have a button in the top left corner of the form and move it to the top right corner, then I press debug but nothing happens to the form, it doesn't change the button is still in the top left-hand corner instead of the top right, and it also doesn't except any new code, its like it saved the project right there and won't move on. Does any one know why or had this problem before?
Please, Help!!!!
Additional Details:
Compiler: Microsoft Visual C# 2008 Express Edition
I once fixed this problem by rebuilding the solution, but its never worked again.
Hey, I got it fixed, I right clicked Form1 in the solution explorer, clicked properties and change the Build Action to none then back to Compile and it seems to be working.
In the Visual Studio settings under Projects and Solutions->Build and Run change the option On Run, when projects are out of date: from Never Build to Always Build
Tools > Options > Projects and Solutions > Build and Run > On Run, when projects are out of date: "Always Build"
In addition to #SwDevMan81's answer with whom I agree, I would say that setting both the output and reference paths may help avoid such behaviour for class libraries. For instance, your application references a class library that you are currently writing, and you perform some changes to this referenced library, but the changes don't show.
What happens is that the compiler will copy localy (to the project's output directory) thereferenced DLL and as long as it is there, it won't get updated. You may verify it by clicking right on the referenced assembly, then clicking Properties. Look at the Filepath property. If you see it doesn't match your actual filepath, then you will have to make sure to set the reference path accordingly in the project properties, then removing then removing the actual reference to add it where the actual build is, that is, where your class library output folder is set. So, whenever you regenerate your class library, your application gets the update automatically. Here's an example:
Application Project references : The ClassLibrary1.dll assembly.
Once you will generate your application, the ClassLibrary1.dll file will be copied to your application output directory. Let's suppose C:\Open\Projects\ApplicationProject1\Debug\bin. So, this directory will now contain the ClassLibrary1.dll file.
You rewrite a method to behave completely differently;
You regenerate the ClassLibrary1 assembly;
You rerun your application (remember that the file already exists!);
Ends up wondering why the changes didn't take effect? That is because your application referenced the cached assembly within its Debug\bin folder.
To workaround:
Remove the assembly reference from your application project;
Go to the project's properties and click the Reference Path tab;
Browse to your ClassLibrary1 output folder, then open it;
Your Reference Path property is now set for this library, then re-add the ClassLibrary1 assembly to your application project;
Run once, stop running, and see if the Path property of your referenced assembly is still the same as the one in the project's Reference Path property;
You're done (if everything worked fine).
C:\Open\Projects\ClassLibrary1\Debug\bin\ClassLibrary1.dll
In the end, this might be the cause of your problem if your GUI Forms are part of a class library, and the solution I described should work.
SwDevMan81 and Tanner's answers didn't work for me.
However,
Build > Rebuild Solution
... did!
Had The Same issue. Build > Rebuild Solution also worked for me

Breakpoint not hooked up when debugging in VS.Net 2005

Been running into this problem lately... When debugging an app in VS.Net 2005, breakpoints are not connected. Error indicates that the compiled code is not the same as the running version and therefore there's a mismatch that causes the breakpoint to be disconnected.
Cleaned solution of all bin file and re-compile doesn't help. Not just happening on a single box or person either.
Added Note:
This solution is in TFS for Source Control. If I delete my local TFS repository and get it from source control from scratch, SOMETIMES the problem goes away. I've also tried un-installing and re-installed Visual Studio. That also SOMETIMES helps. That fact that both of those work some of the time indicates that the problem isn't caused by either directly.
Maybe this suggestion might help:
While debugging in Visual Studio, click on Debug > Windows > Modules. The IDE will dock a Modules window, showing all the modules that have been loaded for your project.
Look for your project's DLL, and check the Symbol Status for it.
If it says Symbols Loaded, then you're golden. If it says something like Cannot find or open the PDB file, right-click on your module, select Load Symbols, and browse to the path of your PDB.
I've found that it's sometimes necessary to:
stop the debugger
close the IDE
close the hosting application
nuke the obj and bin folders
restart the IDE
rebuild the project
go through the Modules window again
Once you browse to the location of your PDB file, the Symbol Status should change to Symbols Loaded, and you should now be able to set and catch a breakpoint at your line in code.
Source: The breakpoint will not currently be hit. No symbols have been loaded for this document.
http://dpotter.net/Technical/2009/05/upgrading-to-ie8-breaks-debugging-with-visual-studio-2005/
In Options -> Debugging you can uncheck "require source files to exactly match the original version", which may help.
Is the build configuration set to Release?
Do you have a reference to an external DLL where the breakpoint is set?
Are you creating a DLL project that is consumed by an external executable? Are you using .NET or COM?
If you are using the COM Interop with .NET, the DLL versions can sometimes be a problem when the executable loads the DLL. For instance, if your daily build cranks out an incrementing build number but your debug DLL has a smaller build number, the executable won't load the debug DLL. To fix this, you will need to scan the HKEY_CLASSES_ROOT\CLSID directory in your registry for the GUID/CLSID of your .NET/COM component. Under InProc32, delete entries with a higher version number than your debug DLL.
Again, the above only applies to .NET + COM Interop DLLs.
I've had a similar problem in the past.
It was solved by closing Visual Studio and deleting the temporary ASP.NET generated assembly files for the project under "C:\WINDOWS\Microsoft.NET\Framework{framework version}\Temporary ASP.NET Files", re-opening the project.
Read the post here and the comments to resolve it.
AviewAnew - had already done that at the request of the MS tech person. It didn't help to uncheck require source file to match version.
Mike L - configuration is set to DEBUG and there are now external DLL. Using all local projects except framework references.
Are you sure the .pdb files are in the same folder as the executable you are running? Make sure the last modified date of both files match, and that VS is attached to that exe (and no other).
Do you have a post build step that touches your binaries in any way? If so, this can confuse the debugger and make it look like your symbols don't match your exe/dll because of the incorrect size/timestamp.
In the past I have sometimes found that switching off compiler optimisations can solve 'missing' breakpoints, as the optimiser had determined (correctly) that the code was not being called, and removed them from the compiled versions.
This does sound like a different issue, but it might be worth making sure that optimisation is switched off in Debug mode. [Project / Properties, Build settings tab]
Sure there are no Debug attributes on the code that prevent code from being debugged, such as DebuggerHidden or DebuggerStepThrough, at any point of the application?
Can you step through your code up to the line of the breakpoint instead of running and waiting for it to hit? Can you step through code at all?

Categories