I'm a C++ programmer, currently learning C#. just wonder how do i set the following configuration in a C# project which i usually do in a C++ project?
1)Additional Include Directories (any .h files not in project directory, C# .cs file need add? or just add in project?)
2)Preprocessor Definitions (got such thing in c#?)
3)Additional library Directories (library files directories path)
4)Additional Dependencies (lib file names)
Maybe you can refer to the following explanation.
1)C# can create a .cs file automatically if you add the program. Also, you can add other .cs file in the program.
2)It seems that C# program doesn't have Preprocessor Definitions.
3)As usual, Additional library Directories should be 'solution\TestDLL\bin\Debug\TestDLL.dll'.
4)Additional Dependencies has TestDLL.pdb files.
Related
We have a C# UI project with bunch of resx files for supported languages. When it is built, the localization support dlls get placed under culture-code\MyTool.resources.dll in the $(TargetDir) of the project. Example is es\MyTool.resources.dll for Spanish.
I am looking for a way to generate these dlls in $(TargetDir)\langsupport\culture-code\MyTool.resources.dll. I know how to make the tool look for langsupport at runtime through app config. This question is about csproj magic to change the output path of resource dlls.
BACKGROUND
I'm mostly programming in embedded C/C++ but sometimes I have to do some C# programming for our API. For this I'm using Visual Studio 2017 to create an API DLL for our customers.
The C# API and our C/C++ firmware are using a common set of status codes. I have a Lua script that generates these codes to a .h (for C/C++) and a .cs (for C#) file so they always are in sync.
All source files that are shared across products and platforms are in a special project called "Common" (checked-in to Subversion).
When we create new projects and use any "common" file, we put them in a sub folder called "Common\" so we know that there is no point in messing with them. Subversion will check out these "Common" files as externals of a specific revision used by each project.
In C/C++ it's no problem at all to have source code organized in several levels of folders, all source files have a relative path to the root project folder.
THE PROBLEM
So in this C# project I organize the source code as usual:
ProjectRoot\source.cs
ProjectRoot\Common\EStatusCodes.cs
In the ProjectRoot\ we have all .cs files for this C# project, and in ProjectRoot\Common\ are the external files from subversion's "Common" project.
So after the checkout of the external EStatusCodes.cs into the ProjectRoot\Common\ folder I add it to the C# project by "Add->Add Existing..." and then I point out the ProjectRoot\Common\EStatusCodes.cs file.
The file shows up in the Project but for some reason Visual Studio has COPIED the file form the ProjectRoot\Common folder to the ProjectRoot\ folder and is then using the copy! (The file's path in properties is set to the ProjectRoot\ folder.
So If we add more status codes to the "Common" project, this C# project don't get the update because Visual Studio now always use the copied version of the file from ProjectRoot\ and don't care if ProjectRoot\Common\EStatusCodes.cs has been updated.
I tried to add the Common folder to "Properties->Reference Path", but it still copies the file every time I add it to the project.
Is it possible at all to have source files somewhere else than in the C# project's root folder?
In the Add Existing dialog, there should be a small down arrow next to the Add button. If you click this, you'll see an option to "Add As Link". This will add the file as a reference link to the original file and any changes to the original will reflect in your project.
We have a similar way in C# project: add existing file to project as "Add as link".
Please refer this link for more details:
https://grantwinney.com/visual-studio-add-file-as-link/
I am converting multiple .IL files into .cs, Now I want to create a single c# project with these .cs files. And then i want a .dll file for this project.
I have already created a c# project. I created a folder "Application" into this project. Now I am moving all the .cs files into this folder. After compiling this c# project i am getting its .dll file into bin folder.
Is this steps correct?
I use the Nuget Package Costura.Fody for it.
It merges everything into the target .exe, but maybe as Class Project it merges everything into one DLL?
You should give it a try:
https://www.nuget.org/packages/Costura.Fody/
The steps are correct as long as the result satisfies the initial task.
What you described sounds legitimate. Now it's your turn to check if the dll works as intended.
I'm not sure if this question has been asked or not.
I have created a DLL in C#. My DLL depends on other DLLs. When someone compile their project using my DLL, the other DLLs will get copy to the projectDir.
However, the other DLLs depend on some text files and some other executable files. The problem is that the text files and executable files don't get copy to the projectDir. Unfortunate, that will cause the project to crash when running.
My question is, how can I load those text files and executable files to the projectDir whenever my DLLs is compiled?
Thanks.
Depending on how you are sharing it you could also look at using Nuget to publish out your DLL. With Nuget you are able to specify and bring across dependent files and libraries that will be added to your any project just by including them as content in the DLL project.
How can I compile a .cs file into a DLL?
My project name is WA. In my bin folder after the compilation, I found:
WA.exe
WA.vshost.exe
WA.pdb
You have to compile it:
csc /t:library source.cs -> source.dll
Are you using Visual Studio?
If you create a Class Library project in VS, add your .cs file and then compile the project, the output will be a .dll file.
You use a compiler. Csc.exe comes with the .NET Framework.
Check this link: http://msdn.microsoft.com/en-us/library/78f4aasd.aspx
You can also use an IDE like Visual Studio if you want the development process to be easier.
Its automatically created for you when you run a build in visual studio. Check the bin folder in your project folder.
For your information there are two kinds of DLL file which named "Managed" and "Un-Managed". Managed type is which you can use and add to your references in Visual Studio IDE.
However, if you want to convert each classes separately to Dll, you can use new windows application-> class library. After debugging and running that you can find DLL file in your source destination. Try it.
P.S: Usually you forced to use more than one class in one DLL file.