C# SciLexer.dll question - c#

I am using ScintillaNET a wrapper of the Scintilla control. I've edited the a lexer a bit and would like to try and see if the changes work, but the problem is I don't know which SciLexer.dll file it's using on my computer. The one in the application's directory did not seem to make a difference.
So my question is basically, how do I know which SciLexer.dll file my application is using and how can I set it to use the one in the application's directory?

Using Visual Studio, check to see which DLL your project references:
With your project/solution open, expand the "References" folder in the Solution Explorer, and locate the name of the SciLexer.dll you are currently referencing.
Double-click on the relevant assembly to display it in the Object Browser.
In the bottom-right pane of the Object Browser, you will see the full path on disk to the specific DLL that your project is referencing.
This is the DLL that you need to change/update. Or, you could remove the existing reference and add a new one to the DLL in the directory that you want your application to use.

Related

VS/C# Equivalent of Java/Eclipse "resource folder"?

While using Java in Eclipse IDE, one can add a folder to the "Build Path" using the "Add Class Folder" option in the "Libraries" tab, which allows the resources in that folder to get compiled inside the application's jar file, rather than outside or not at all.
.
With this, one can get the resources inside the folder as a URL via the Class.getResource(String name)method. I am already informed about C#'s equivalent: Assembly.GetManifestResourceStream(string name) or Assembly.GetManifestResourceInfo(string resourceName) methods, but I am not aware of C#'s "Build Path" equivalence in Visual Studio (I am using 2019, if you wished to know). Could somebody please explain how I would accomplish Java's build path resource folder in C#?
(Note that I am looking to create a resource folder where anything put inside the folder would be considered an application resource. I am not looking for a way to add one or more resource files individually.)
Any replies would be greatly appreciated! :)
After a little research, I had found a solution for this problem. There are in fact two possible solutions to this issue.
.NET Core Solution
The first involves editing the .csproj file of your C# project. This solution is only available in .Net Core.
You can add this code snippet to your file and change the {PATH_TO_RESOUCE_FOLDER_HERE} folder to your desired folder.
<ItemGroup>
<EmbeddedResource Include="{PATH_TO_RESOUCE_FOLDER_HERE}\**" />
</ItemGroup>
Now any item placed in that folder will be considered an embedded resource Assembly.GetManifestResourceStream(string name) method.
Regular .NET Solution
The second method involves using a .resx file to encapsulate all of your resources
In Visual Studio 2019, you can create a .resx file by right clicking on the location in your project where you wish to add the file to, and navigating to Add > New Item (you may also press Ctrl+Shift+A). You can now navigate to the item that quotes "Resources File" and select it. You can now use this GUI to insert your resources (for a deeper explanation, click on this or this link. For use cases, see this MSDN).
The "Resources File" option
Note that this solution will also work in .NET Core.
I hope this answer helped you as much as it did me! :)
You just create a folder and name it as you like it, say 'Resources'. Add any file you want in there to be treated as a resource by your application.
Then navigate to the properties of every resource file (you can press F4) and in the menu you can choose what you want the compiler do with that file (Compile Action is the option name if I remember well). There you select the type as a resource, the namespace (your Build Path), and whether you like the file to be copied every time you compile your application, and so on.

Can't add existing Form and User control C#

I want to add existing User control and Form but I can't. Please give me a solution
Image 1. Solution explorer
Existing User control
Check if you paste the x.cs, x.Designer.cs, x.resx files into your project.
Check if you include them in the project.
The simple method is to copy the relevant files directly, and then right-click in the solution project, so that all the files are included in the project. Of course, you can also open see all files options and then include these files in the project
The InitializeComponent() method is generally in x.Designer.cs. If it is indeed in the x.Designer.cs file and you have not copied it, you will definitely not find it.

Where to copy a 3rd party assembly in your Visual Studio project?

My operating system is Widows 7. I am using Visual Studio 2015.
I have a solution Sln1 which has 2 projects Proj1 and Proj2 both projects are of Class Library type.
In Windows Explorer I can see:
I have a folder c:\MyWork\Sln1 which has the solution file named
Sln1.sln and it also has 2 folders named Proj1 and Proj2.
I have a folder c:\MyWork\Sln1\Proj1 which has the project file named
Proj1.csproj and it also has 3 folders named bin, obj and Properties.
I have a folder c:\MyWork\Sln1\Proj2 which has the project file named
Proj2.csproj and it also has 3 folders named bin, obj and Properties.
I have a 3rd party assembly (Telerik.Web.UI.dll) which is in folder C:\Program Files (x86)\Telerik\UI for ASP.NET AJAX Q3 2015\Bin45.
I want to use this 3rd party assembly in the source code of Proj2 only. But I dont want the project Proj2 to access it from its current location. Instead I want the project Proj2 to have its own copy of this 3rd party assembly. How can I do that?
Copy the dll file to the desired location for example (solution/project/lib). Then in vs2015 open the solution explorer Ctrl + Alt + L.
Then under the project, you want to add the lib to right-click on reference.
Then click on add reference. Go to the browse tab and in the right bottom side click on browse.
Here you can select the dll you want to reference in the project. The 3th party library is now ready to use in your project.
Since you want the 3rd party library in the "Proj2" project location, just copy the DLL file (i.e. Telerik.Web.UI.dll) to a folder in that section (for example under lib, etc.) then in your project(s) go to your Solution Explorer, under the References right click and choose "Add Reference...", then click on Browse and choose your DLL accordingly from the location that you copied earlier.
I hope this will be a useful tip for you.
The most important thing to take into account is version control. No matter where you put it, make sure that the library is under version control, or at least that sufficient information to retrieve it. Also, check that you reference it in your project using relative paths, so anyone can build using only files within his own working copy.
I generally use a structure like this:
\
\libraries
\lib1
\lib2
\source
\proy1
\proy2
So that it's easy to checkout the whole thing, incluiding all dependencies and use those for building everything.

Move VC# Project And Maintain Links

How do you move a Visual Studio C# project and maintain the linked files?
For example;
I have a VC# Project that sits in folder: A/V2013_Project.
This VC# Project links to files A/Image/a.png this is because we have many other projects that use this file also.
I want to move my project to A/Release/V2013_Project. Ie move the project to a sub-folder.
I'm not renaming anything in the new project, not changing anything else except for the location of the project.
When I move the project all my links fail (theres more than 50) and most of my references fail. By fail, I mean they no longer point to the file. Within the newly moved VC# project; when I click on a linked file VC# displays an error:
Cannot find the file A/Image/a.png. It may have been moved or deleted.
But this file was never moved. Its still in exactly the same place.
How can I move a VC# project and maintain the links and references? Are there any 3rd party addons that can do this?
Edit: Using wintermute's advice; the links are indeed relative and not absolute. For example;
<Resource Include="..\..\Resources\Other\Images\TOOLBAR_close.png">
<Link>Resources\Other\Images\TOOLBAR_close.png</Link>
</Resource>
Any ideas how I can make links absolute in VC#?
It depends on how the file is linked. It isn't clear from your question.
Some files are references by the .csproj file. Close Visual Studio down (just to be sure) and open the .csproj file with Notepad or some other text editor. See if the files you're talking about are referenced there. If so, add the text "..\" in front of each file name, indicating they are one directory higher up, relative to the project location.
Some files are referenced in the .resx file(s). In this case Visual Studio should have included the name of the .resx file as part of the error message. This can be fixed using Visual Studio's editor. Double-click on the error message and it should open the .resx file with the file reference that is in error as the selected line. Again, add "..\" in front of the file name.
You say you have 50 references. Hopefully this means you can search-and-replace to add the "..\" text to the relevant file names.
Edit:
You posted an edit to your question, showing this line:
<Resource Include="..\..\Resources\Other\Images\TOOLBAR_close.png">
If you really want to make this absolute, then just do it.
<Resource Include="D:\Merlinia\Trunk-Debug\Add-Ons\Picture Editor\VS2012 projects\PictureEditor\Resources\Other\Images\TOOLBAR_close.png">
But as I mention in a comment on your question, make sure this is the best way to fix the problem.

How to include other files to the output directory in C# upon build?

I have some library files needed for my application to work.
My application has a setup and deployment included.
I already know that in order for a library file to be added to the output directory of the application when installing, I just have to reference those libraries inside the .NET IDE before building... the only problem is that these libraries can't be referenced... So I need to be able to copy these libraries to the installation directory of my application... At the moment, I am copying these libraries manually...
Addendum
I also did try to add these library files as an Existing Item to my project and marked each library files' Copy to Output Directory to Copy if newer on their properties but still not getting the solution I want.
Update 1
Thanks for you help guys it helped me solve my problem, I managed to make the solutions you posted work except for one... #Matthew Watson's post.. I even managed to find a solution too so I wanted to share it with you also.
Heres what I did:
I opened the setup and deployment project in my application.
Under the Application Folder Tree, on it's right side, I right clicked..
then clicked Add..
then clicked File
and then browsed for the files I wanted to add to the installation directory
and click open.
But out of curiosity...I am still trying to make what #Matthew Watson posted work...
Update 2
I forgot to update this post yesterday, I already manage to make Matthew Watson's solution worked yesterday. Thank you again for all your help guys.
You can add files to your project and select their properties: "Build Action" as "Content" and "Copy to output directory" as "Copy Always" or Copy if Newer (the latter is preferable because otherwise the project rebuilds fully every time you build it).
Then those files will be copied to your output folder.
This is better than using a post build step because Visual Studio will know that the files are part of the project. (That affects things like ClickOnce applications which need to know what files to add to the clickonce data.)
You will also be more easily able to see which files are in the project because they will be listed with the source code files rather than hidden in a post-build step. And also Source Control can be used with them more easily.
Once you have added "Content" files to your project, you will be able to add them to a Visual Studio 2010 Setup and Deployment project as follows:
Go into your Setup project and add to your "Application Folder" output the Project Output called "Content Files". If you right-click the Content Files after adding them you can select "outputs" and see what it's going to copy.
Note that Setup and Deployment projects are NOT supported in Visual Studio 2012.
You can use Visual Studio Post Build Event - Copy to Relative Directory Location. Which are basically scripts that are executed on build of specified project.
So you can use it to copy binaries you need, before actually running your application.

Categories