Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My main question is can I use (dll Libraries as databases?) to store text and images and sound files maybe?
If yes- how can I do that, and please specify.
If No- :\

--------------
Thank you in advance, Awaiting your answer.
Posted
Comments
Kim Togo 17-Jan-12 12:53pm    
I do not see the point in that.
Using a dedicate database is much better.
Sergey Alexandrovich Kryukov 17-Jan-12 13:09pm    
Maybe this is no more that ugly phrasing. Maybe be OP merely needs resources but does not know how to call them.
I provided some explanation in my answer, please see.
--SA
Sergey Alexandrovich Kryukov 17-Jan-12 12:53pm    
What is "dll libraries as databases"? Do you realize that you cannot modify any loaded DLLs during run time?
--SA

1 solution

Please see the comments by Kim and myself to the question. As you formulated it, it makes no sense.

But I hope you need something different: how to store images in the executable module like a DLL. First of all, you develop not DLLs, you develop assemblies. There is no fundamental difference between DLLs and EXEs, which are merely the parts of the executable file names. One of the ways to embed data in them is using resources, in particular, *.resx resources. You don't even need to use Resource Manager or something. You should better put images in separate files and add them in your resource as files. The file will be copied to your project file system (so be sure to avoid having double copies; your source file should be either outside the project or at the same very location where Visual Studio puts the target file) add to the project and also add the reference to it to the resource file. Unlike other data files, your image files will not be copied to output directory but rather embedded in executable. You will get everything to reference the data embedded: look at the auto-generated C# file: you will find a static class with static property of the name similar or identical to the file name. If the file was *.jpg or *.png, the type of the property will be System.Drawing.Image. Just use it in your code.

As you need to use your executable as a library, you will also need to create a separate public class with public properties or methods used to expose the images to the user.

However, resources are not like database, not at all. First of all, you cannot modify them during run time — they are strictly read-only, as there is no a way to modify any executable file loaded for execution.

—SA
 
Share this answer
 
v2
Comments
Kim Togo 17-Jan-12 13:35pm    
Well explained SA, my 5.
Sergey Alexandrovich Kryukov 17-Jan-12 13:48pm    
Thank you, Kim.
--SA
fjdiewornncalwe 17-Jan-12 14:27pm    
+5. Very nice.
Sergey Alexandrovich Kryukov 17-Jan-12 14:55pm    
Thank you, Marcus.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900