Shahgee
Shahgee

Reputation: 3405

writing dll , c# (concept)

I have a basic question.

1- I want to use Science.dll provided at

http://www.sciencecode.com/

I want to add some new functions in some XXX.cs files and also some new YYY.cs files. Then I want to make dll of them again (Science.dll with changes) and use it. How it can be done.

Should I make a new project and add all more than 100 files (already given on website) in that project and some my new YYY.cs files and then what should be next step???

2- I wanna ask about best way to put many different functions in one 'utilities.cs' file. Say I have different static functions *printmatrix, read_text_file,* etc. What should I do, so that I directly use them in main program. What should be the way in c#.In c++ I wrote header file and cpp file named utilities and then I used these functions.

Any good idea.

Upvotes: 0

Views: 177

Answers (2)

nickotech2000
nickotech2000

Reputation: 259

First you make a new project taht has reference on the science.dll.in Visual studio You can inheritance its class and add yours functionality. You can use partial class that has the same name as in the science.dll. and add your functionality eg: science.dll

public class Calc
{
   public Int32 Add(Int32 a, Int32 b){..implementation...}
}

yourproject.dll

public partial class Calc
{
   public Int32 Minus(Int32 a, Int32 b) {..implementation..}
}

You can use extension method with your functionality. This is depend on your implementation. For detail implementation you can see on MSDN : http://msdn.microsoft.com/library for both C# and VB.NET on both syntak

In the caller project, make sure add reference both science.dll and yourproject.dll.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038780

You cannot modify an existing assembly unless you have the source code of it. What you could do is create a new class library project in Visual Studio, add Science.dll as a reference and then add your own functions which could use functions in the referenced assembly. When you compile your project it will produce another assembly.

Upvotes: 2

Related Questions