How do I include a .jpg into a dll? - c#

I have a third-party application that creates a dll file out my .cs code.
In my .cs code I reference a file.
How do I compile the dll or .cs to include the .jpg file along with the code?
The options I have for the third-party application does not allow me to export the .jpg
The import process only looks at the .cs and the associated .dll.
Is there a way to add the file to the dll once the third-party application has created the dll in the export process with visual stuido or something?

Yes this is possible. If the file is used by your code in the dll then the file needs to be embedded thorugh the Properties >> Build Action >> Embedded Resource setting:
(EDIT) Visual Studio Code variant
You have to edit the .csproj and change the node that represents your file to:
<EmbeddedResource Include="Resources\yourEmbeddedResource.json" />
Source:
https://starbeamrainbowlabs.com/blog/article.php?article=posts/180-Embedding-Resources.html;
https://www.codeproject.com/Articles/114997/Embedding-and-Using-Resources-from-Net-Assembly;
How to mark a file as an embedded resource in Visual Studio Code?;

Related

Differences in visual studio settings between C++ and C# project

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.

How to organise C# source files in subfolders?

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/

Compile a .dll file of dlib

I want to import a script that uses Dlib. Problem is that it won't compile without .dll file of Dlib.
Is there any way to get it into my project?
I have .lib file but I don't think there is a way to convert that to .dll.
#ali I made a make file of the dlib file using c-make and then used visual basic to compile it but in export setting I changed the. Exe to. Dll

Create .xml and .pdb files from .dll file

I have a .dll file from a Silverlight class library. How can I create a .pdb and a .xml file from this .dll file?
You can't. Whoever supplies the DLL must supply the auxiliary files too.
And if you have the source code you can generate them on your own by making sure you build as debug rather than retail/free.
Why do you want them?

Convert .cs to .dll

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.

Categories

Resources