Closed W1zzardTPU closed 10 months ago
Hi,
There is certainly no reason why those paths shouldn't be configurable.
One option would be to create nullable public static string properties which the control would use as primary source and fallback to the defaults.
Other would be to have a property for a nullable Action or Func
Scintilla.Something = () =>
{
// Your code here...
}
Would you like to create a PR as a suggestion for the modification you suggested?
Yeah, seems simple enough. Unfortunately I don't have the time at the moment, still wanted to let you know
Thank you
Hi, Sorry for the silence - I have been busy as always 🙂The original idea is nice, I just don't think it is worth implementing with this much interest and possible useful use cases. If someone creates a PR and the code checks, that is fine, otherwise I'll just leave this hanging here...
If you persist, I tested a solution similar to that used by certain products (like Syncfusion) to check the existence of licenses. This solution consists of a function IMPRATIVELY called before the creation of the first instance of the control (see example below) ScintillaNET.Scintilla therefore in the main entry point of the application for the reasons described previously (see https:// learn.microsoft.com/en-us/previous-versions/dotnet/netframework-3.0/ms182351(v=vs.80)?redirectedfrom=MSDN).
static void Main() { ScintillaNET.Scintilla.SetScintillaDllPath(@"I:\LGProjects\Scintilla\VPK v.5.3.2.7\original\Scintilla.NET-v.5.3.2.7\native"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
And the description of the function:
/// <summary> /// /// </summary> /// <param name="path">Path or filename of the native Scintilla DLL</param> /// <remarks> /// If path is a directory, if the scintilla.dll is not in the directory, we search in the path/X(64 or X86, depending on the platform) directory. /// /// </remarks> /// <exception cref="InvalidOperationException"></exception> static public void SetScintillaDllPath (string path)
I added a property:
/// <summary> /// Gets the path of the Scintilla.dll user by the control. /// </summary> [Description("The path of the native Scintilla DLL"), Category("Design")] public string ScintillaDllPath => scintillaDllPath;
For the reasons described above: 1 - having referenced the package allows you to call the
SetScintillaDllPath(...)
function in the program entry point. 2 - This function cannot be called in the Form code. 3 - The native dll Scintilla.dll (version 5xxx) automatically loads the Lexilla.dll dll in the same directory as it, we cannot change the path of Lexilla.dll. 4 - In design mode, this function cannot be called, the native dlls used in this mode are those of the package. 5 - It is possible to call the SetScintillaDllPath function with a path relative to that of the application executable.Attached a package to test: Scintilla.NET.5.2.9-alpha7.zip (Normaly, following https://learn.microsoft.com/en-us/nuget/concepts/package-versioning, the version should be a 5.3.0-alpahn)
Excellent idea, this approach should work very well. Can you submit a PR?
Just after this proposal, I developed a more flexible and open version. If anyone is interested, I can send them the sources because I am not a contributor (nor do I wish to appear as such).
Definitely interested, w1zzard@techpowerup.com
I'm not against the idea...I think there are some inherent challenges and use case aspects to consider, but I'd be interested in hearing you out.
"What is the objective of this need to customize modulePathScintilla and modulePathLexilla?" ..."
For me: to be able to ship a single binary, that extracts the DLLs to %TEMP% or another temporary location. Also not a fan of the two-folder structure with two files each
"to be able to ship a single binary, that extracts the DLLs to %TEMP% or another temporary location". Wouldn't you wish that the scintilla and lexilla dlls were embedded into Scintilla.NET?
Sure, but that's not possible from what I understand.. can't load native DLLs from memory
For example, you can read https://stackoverflow.com/questions/72264/how-can-a-c-windows-dll-be-merged-into-a-c-sharp-application-exe
Yup that's pretty much what I want to do. Store the DLLs in the binary, extract it to the filesystem, load it from temp.
Boxedapp is not an option because it's closed-source, commercial and using a code cave to load a DLL from memory will get flagged by antiviruses anyway
The other answers are for managed DLLs only
@W1zzardTPU for these two comments:
"to be able to ship a single binary, that extracts the DLLs to %TEMP% or another temporary location." "Also not a fan of the two-folder structure with two files each".
Can you elaborate more on what the scenario is you are trying to accomplish with extracting the dll's to a temp folder? Also, what problem does the two folder structure currently create and what is your suggestion for how to handle all 4 dll's?
I'd like to request the ability to customize modulePathScintilla and modulePathLexilla
Right now this isn't possible because the relevant parts in Scintilla.cs are marked as private (not protected)
Another option could be to allow us to define some configuration options, or just expose the statics and make them writeable