如何在 C# 项目中使用 Scintilla .NET?
我正在尝试在项目中使用 Scintilla .NET(我想要一个好的编辑器+语法突出显示等)。不幸的是,当我在项目中引用二进制文件时,我似乎无法实际使用 Scintilla 控件。我收到两个不同的错误。
第一个发生在添加时 SciLexer.dll 作为我的参考 项目。我收到一条消息说: 对 SciLexer.dll 的引用可以 不被添加。请确保 文件是可访问的,并且它是 有效的程序集或 COM 组件。
当我尝试使用 ScintillaNET.dll 中的控件时,发生第二个错误。如果我尝试将组件拖动到表单中,则会收到以下消息:无法创建组件 Scintilla。错误消息如下: System.ComponentModel.Win32Exception: %1 不是 ScintillaNet.Scintilla.get_CreateParams() 处的有效 Win32 应用程序
任何有关这些问题的帮助将不胜感激。郑重声明,我正在运行在 64 位 Windows 7 平台上运行的 Visual Studio 2008。
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
自从我使用 Scintilla 以来已经有一段时间了,但我的理解是 SciLexer.dll 是一个完全本机的 DLL,这就是为什么您无法从 Visual Studio 添加对它的引用。
相反,您应该“安排”SciLexer.dll 在运行时出现在正确的目录中,以便 ScintillaNET.dll 可以加载它。最安全的方法是将 SciLexer.dll 作为普通文件(而不是参考)添加到 Visual Studio 项目中,然后更改文件的属性,以便在生成项目时将其复制到输出目录。
鉴于您使用的是 64 位,我希望您需要 专门构建您的应用程序作为 32 位而不是 AnyCPU。正如我所说,我已经有一段时间没有这样做了,但当我这样做时,Scintilla 只有 32 位二进制文件。
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.
我通过将文件复制到
C:\Windows\SysWOW64
解决了这个问题。从 @weston 的帖子中得到了这个想法。
I got round the issue by copying the files to
C:\Windows\SysWOW64
Got the idea from @weston's post.
我使用 ScintillaNET(C# 端口)。它很容易使用,但它很消耗内存。
https://github.com/jacobslusser/ScintillaNET
I use ScintillaNET (C# port). It is easy to use, but it is a memory hog.
https://github.com/jacobslusser/ScintillaNET
单击“运行”并选择“我的电脑” 右键单击“我的电脑”,转到“属性”,然后
单击高级系统设置。
之后选择高级并单击环境变量。
在这里我们可以添加值和路径。
值:您喜欢什么“例如:Scintilla
值路径:下载的 dll 保存的位置”。 EG: D:\prathap\DLL\
下载路径 :https://scintillanet.codeplex.com/releases
从屏幕右侧选择下载。
然后在应用程序中添加 Scintill Dll 作为参考,添加其他 2 个 dll 作为现有文件。
右键单击项目 ADD -- 添加现有文件 -- 然后从本地系统中选择文件,并确保保留 2 个文件“复制到输出目录 = 始终复制”。
然后运行应用程序,它将起作用。
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.
我添加了对 Scintilla.dll 而不是 SciLexer.dll 的引用 - 并且它有效
i added reference to Scintilla.dll instead of SciLexer.dll - and it worked