共享代码 [英] Sharing Code

查看:48
本文介绍了共享代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,


我想编写任意数量的类,然后使用任何

数量的.NET应用程序中的类。


因为我们应该离开DLL Hell和ActiveX对象背后,什么有

取得它的位置。


任何人都可以指出我正确的方向开始学习最好的

编写例程库然后能够从几个不同的.NET应用程序访问那些

例程的方法吗?


谢谢。


-

Jonathan Wood

SoftCircuits编程
http://www.softcircuits.com

解决方案

Jonathan Wood写道:


问候,


我想写任意数量的课程,然后使用这些课程来自

的任意数量的.NET应用程序。


因为我们假设已经离开了DLL Hell和ActiveX对象背后,什么

已经占据了它的位置。



我们仍在使用dll文件。我们刚刚离开了我们身后的大部分地狱般的部分




例如:


避免使用DLL地狱:在Microsoft中引入应用程序元数据

..NET Framework
http://msdn.microsoft.com/msdnmag/is...a/default.aspx


任何人都可以指出我正确的方向开始学习

编写例程库的最佳方法然后能够访问

来自几个不同的例程.NET应用程序?



创建一个类库项目并在其中放入一些类。你可以

编译这个并使用生成的dll文件,或者将项目添加到

任何解决方案。


-

G?跑Andersson

_____
http://www.guffa.com


这是一块蛋糕。你基本上创建了一个类库项目。那个

会创建一个DLL。您的所有类都将位于一个或多个名称空间中,这些名称空间是您在该DLL中创建的。


在使用该库的项目中,您只需添加一个引用你的项目中的$

中的DLL。

假设你有MyLib命名空间和MyClass类。

然后,您创建一个应用程序。在你的应用程序项目中,你会得到
参考MyLib.dll


在你的代码中,你会做这样的事情:


使用MyLib;


void SomeMethod()

{

MyClass myClass = new MyClass( );

}


这就是它的全部内容。不可能简单得多。


您只需将DLL的副本部署在与

应用程序相同的目录中。


事情会变得更复杂。您可以开始签署已签名的应用程序

和版本问题,但在大多数情况下,这很容易。


Pete


" Jonathan Wood" < jw *** @ softcircuits.com写信息

新闻:%2 **************** @ TK2MSFTNGP05.phx.gbl ...


问候,


我想写任意数量的课程,然后使用这些课程来自

任意数量的.NET应用程序。


因为我们假设已经离开了DLL Hell和ActiveX对象背后,什么

已经占据了它的位置。


任何人都可以指出我正确的方向开始学习

编写例程库然后能够从几个不同的.NET应用程序访问这些例程的最佳方法吗?


谢谢。


-

Jonathan Wood

SoftCircuits编程
http://www.softcircuits.com



Jonathan Wood写道:


问候,


我想写任意数量的课程,然后使用这些课程<来自任意数量的.NET应用程序的



因为我们假设已经离开了DLL Hell和ActiveX对象背后,

取而代之的是什么。


任何人都可以指出我正确的方向开始学习

编写例程库然后能够从几个不同的.NET应用程序访问这些例程的最佳方法吗?



你把它们放在DLL中。这不会导致DLL Hell。因为这样的DLL通常会部署app local和app local。 - 在应用程序''bin''

目录中,而不是像%systemroot%这样愚蠢的地方。


-cd


Greetings,

I''d like to write any number of classes and then use those classes from any
number of .NET applications.

Since we''ve supposedly left "DLL Hell" and ActiveX objects behind, what has
taken it''s place.

Can anyone point me in the right direction getting started learning the best
way to write a library of routines and then being able to access those
routines from several different .NET applications?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

解决方案

Jonathan Wood wrote:

Greetings,

I''d like to write any number of classes and then use those classes from
any number of .NET applications.

Since we''ve supposedly left "DLL Hell" and ActiveX objects behind, what
has taken it''s place.

We are still using dll files. We just left most of the hellish parts of
it behind us.

For example:

Avoiding DLL Hell: Introducing Application Metadata in the Microsoft
..NET Framework
http://msdn.microsoft.com/msdnmag/is...a/default.aspx

Can anyone point me in the right direction getting started learning the
best way to write a library of routines and then being able to access
those routines from several different .NET applications?

Create a Class Library project and put some classes in it. You can
either compile this and use the dll file produced, or add the project to
any solution.

--
G?ran Andersson
_____
http://www.guffa.com


It''s a piece of cake. You basically create a "Class Library" project. That
will create a DLL. All your classes will be in one or more namespaces that
you create inside that DLL.

In projects that use that library, you simply add a reference to the DLL in
your project.

Let''s say you have the namespace MyLib and the class MyClass in it.

You then create an application. In your application project, you''ll
reference MyLib.dll

In your code, you''ll do something like this:

using MyLib;

void SomeMethod()
{
MyClass myClass = new MyClass();
}

And that''s all there is to it, really. Couldn''t be much simpler.

You simply deploy a copy of the DLL in the same directory as your
application.

Thing can get more complex. You can start getting into signed applications
and versioning issues, but for the most part, it''s pretty easy.

Pete

"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...

Greetings,

I''d like to write any number of classes and then use those classes from
any number of .NET applications.

Since we''ve supposedly left "DLL Hell" and ActiveX objects behind, what
has taken it''s place.

Can anyone point me in the right direction getting started learning the
best way to write a library of routines and then being able to access
those routines from several different .NET applications?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com



Jonathan Wood wrote:

Greetings,

I''d like to write any number of classes and then use those classes
from any number of .NET applications.

Since we''ve supposedly left "DLL Hell" and ActiveX objects behind,
what has taken it''s place.

Can anyone point me in the right direction getting started learning
the best way to write a library of routines and then being able to
access those routines from several different .NET applications?

You put them in DLLs. This doesn''t result in "DLL Hell" because such DLLs
are then generally deployed "app local" - in the applications ''bin''
directory, rather than in some silly place like %systemroot%.

-cd


这篇关于共享代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆