I have some pdf's templates that are being used across many web applications.
Can I add pdf's files to dll project?
Thanks
J
You can certainly add them to the project, but I don't think that's what you're asking.
Even if you add them to the project, they will not be embedded into the DLL. You could use some kind of hideous base64 encoding in a string, and deserialise it later, but that's just horrible.
Your best bet would be a shared directory or server, or just to submit to copying the PDF to each application directory manually.
Related
I am building a projects by C#. It contains many folders, each folder represents for a function. Now I want to make a .dll file for each of them. Is there any tools can help me to do it?
And after that I want to merge them together. Is there any solution for me to do it?
Thank you,
You are searching for modules in .NET. Where module is a file (not a DLL) with self sufficient (from structure perspective) content which can be read and executed by CLR virtual machine into machine code.
Read this for detailed explanation: How to: Build a Multifile Assembly
You will need to do a little command line execution, no direct visual studio support, afaik.
You might want to move from a folder structure to a project structure. Each project will automatically have its own .dll file. Then you can have a central project that has references to each of them.
It would be a good idea to group together certain code files by project for other reasons too. Suppose you have a lot of extension methods that could easily be re-used for other coding projects. You might separate these classes into a Util project / namespace for easy re-use and access across other projects.
Is it possible to embed an exe file in a class library (dll file)?
I want to use this exe without the necessity of copying it manually to my workstation. In other words, if I want to use my C# class library in another app, I won't need to copy these exe files in a folder and pass the path of this folder in my app.
If there is a way how to do this, it would be great.
sorry but what I mean is just, I made a library for screenshots using Selenium Webdriver and when creating a new webdriver object, I need to pass the exe file of the webdriver.
what I need the most is that I don't want to copy the exe file if I will use this library to another workstation for example, I want everything to be packaged as one file
Thank you
Well, technically you can embed a binary file as a resource within a DLL (by adding the file as a binary resource through the project properties), but you'll still need to save the file to disk in order to execute it (which is assume what you're trying to do) and will possibly have security issues unless your application is fully trusted.
If the binary file is a resource you can extract the bytes from the static Properties class:
byte[] exe = Properties.Resources.MyExe;
and save it to disk like any other byte array.
If you own the code for the EXE then it would be a lot better for you to turn your EXE code into a library. Then you'll be able to refer to that library from anywhere and call any public functionnality it has. It's a far, far, FAR better approach.
Should you still need to run that code as a standalone process, nothing prevents you from making a new EXE front that will refer to that same library.
Now if you do not have the code, then depending on your deployment strategy you may prefer creating a reusable deployment component / module that can be attached to other application setups.
I have formed a number of source code files as my library. For example, I wrote LinqExtension.cs providing Median() function.
Now I'm working on a project which needs LinqExtension.cs. As usually, I link the file to the project. As introduced here. The reason that I link files rather than copying them is to keep the files at a single location. If I modify a file, all dependent projects get affected.
I also add the project to Subversion and upload to and download from Google Code. The linked file is not under version control.
I work on the project at home as well as at office. I hate copying the linked file to my office, which makes the file not single.
I figure out a solution that add <Compile Include="http://www.example.com/LinqExtension.cs"/> to csproj file so that the file only exists on the Internet. Once I upload a new verison of the file, all dependent projects get affected. Unfortunately the solution doesn't work.
Any other suggesions or better practice?
A better way would be to share your core library at the binary level, rather than at source code. You could set up a private Nuget repository to make this easier.
If it is absolutely necessary to share files, you can use pre-build actions in your project to copy the file from a common location, or even download them from google code. It's not clean, but if you don't want to use source control for it then I don't think you will find a clean way.
I like to keep a library folder of binaries in my Dropbox. That way Common libraries that I use can be accessed from my home and work project workspaces and the service keeps the version up to date.
I am creating a C# class library for use by other developers. How should I package it up - just zip up the DLL and put it on the website?
The recommended way is to upload the code source including build scripts to a web site such as googlecode so that other developers could download it and compile it but if it is closed source library zipping the assembly (mylibrary.DLL), documentation (mylibrary.XML) and debug information file (mylibrary.PDB) should be enough.
If it is just a DLL then I wouldn't bother zipping it. However it would be nice if you did zip up some documentation with it along with a sample configuration file if applicable.
Well, have you ever used another third party one? What would you like to see in the perfectly packaged third party download?
I'd zip it up with the following in at a minimum:
your dll in a /bin/ folder
readme (txt or html) explaining what it is, how to install and where to get more info
if you are including the source then
* source in /source/ folder
* Any tests in a /tests/ folder
If its something good you might want to stick it up on google code or codeplex rather than your own site?
Yes.
You should include documentation in your ZIP file, including a link back to your website. NDoc is great for generating documentation from your XML comments.
Look at 3rd party prijects for inspiration, but yes, a zipped dll is fine.
If your documentation is large then you should put it into a separate zip, and if your releasing the source you should put that into a 3rd zip.
Either way your dll should comes with a readme describing what version it is, what the purpose is, who wrote it and how to get in touch with them, along with any dependencies or other useful snippets of information.
Documentation is really important!
I would suggest that, if this is a product, you would want a setup project that installs it. This would include placing it in the GAC and leaving documentation somewhere.
edit
Just to clarify, I mean real documentation, not just what's automatically generated from comments.
I would like to localize my c# class library
The library will output a .dll file, which I will distribute to .net application bin folders.
I want localization in the class library but I do not want to have to recompile the DLL each time a localization change is required.
So ideally....
have c# class with resx files outside the assembly, so that when the contents of the resx changes, all that should be required is that the asp.net host application might require a restart.
Best case scenario, is that the asp.net host application doesn't require a restart.
Thanks in advance for your advice - the resx file will just hold string values.
If possible I would like to do this using a best practice method, or at least without writing a whole custom localization solution.
Check this stackoverflow question.
Is there any performance difference in using .resx file and satellite assembly?
Looks like you can have a seperate resource dll.