473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to change a C# application into Control(DLL)

3
Hi
I have a application developed by C#. Now I want change it into an OCX control or a DLL for other program can call the function in it.
I am quit new on C#. Would you give me brife idea how can I do it? Any infomation will be very helpfull.
Thanks!
Mar 15 '07 #1
3 1462
SammyB
807 Expert 512MB
Hi
I have a application developed by C#. Now I want change it into an OCX control or a DLL for other program can call the function in it.
I am quit new on C#. Would you give me brife idea how can I do it? Any infomation will be very helpfull.
Thanks!
First, I assume that you are using Microsoft C# 2003 or 2005. If not, this will not be very helpful.
  1. Create a new Windows Application project
  2. Add a button to the project & double-click on the button
  3. Add this line of code to the click event:
Expand|Select|Wrap|Line Numbers
  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3.     MessageBox.Show( ClassLibrary1.Class1.MyFun(1).ToString());
  4. }
  1. Click on Save All to save the solution and files.
  2. Right-click on the solution and select Add, New Project, Class Library. This will be your dll.
  3. Add your function to the library. In my case I added MyFun:
Expand|Select|Wrap|Line Numbers
  1. namespace ClassLibrary1
  2. {
  3.     public class Class1
  4.     {
  5.         public static int MyFun(int i)
  6.         {
  7.             return i * 42;
  8.         }
  9.     }
  10. }
  1. Right-click on the solution and select Build Solution
  2. You will get an error stating that the name ClassLibrary1 does not exist. However, your dll will have been built. You may want to use Explorer to see its location.
  3. Add a reference to your dll: right-click on References for your Windows App, select Add Reference, Browse, go up one level, then drill down ClassLibrary1/bin/Debug, select the dll, and press OK.
  4. Press F5 to run your app.
You can use this dll in any other project by just adding a reference to it. You do not need to include the code in the solution. It's confusing the first time, but it gets easier. Obviously, you will want to use meaningful names instead of the default WindowsApplication, ClassLibrary, MyFun, etc. HTH --Sam
Mar 16 '07 #2
dorinbogdan
839 Expert 512MB
If want to call a .Net dll from VB6 or ASP, see this thread.
Mar 16 '07 #3
zzhou
3
This is just I want.Greate answer! Thank you so much!!!
My IDE is VS 2005. I will follow these step and have a try.
Thanks again both of you!
Mar 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Paul | last post by:
Title: What are the Consequences of Aspx page separate from app DLL Hi JL; I am working on a big asp.net application. When we migrate the dll (or dlls) to the production server, all users who are...
1
by: Paul | last post by:
Title: What are the Consequences of Aspx page separate from app DLL Hi JL; I am working on a big asp.net application. When we migrate the dll (or dlls) to the production server, all users who are...
0
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file. One project that build a class library dll One project that build a windows control dll In...
0
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file. called A One project that build a user control dll called B One project that build a class...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.