怎么编写纯资源Dll,以及如何调用(C#)

gsmlovezwy 2008-12-17 09:46:11
如题,谢谢!
...全文
483 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
bdtmgk 2009-03-03
  • 打赏
  • 举报
回复
有个外部DLL文件,我点生成,在bin下产生了对应的dll文件。
但是如何在aspx中使用例如
<%@ Register TagPrefix="F1" Namespace="FreeTextBoxControls" Assembly="FreeTextBox"%>
加以引用呢?
还发现了项目中包含一个licenses.licx的文件,查了下是版权的相关。
现在引用外部的dll我都不会啊!!!
viena 2009-01-07
  • 打赏
  • 举报
回复
倒分,关100天
周公 2008-12-17
  • 打赏
  • 举报
回复
上面的就是读纯资源的用法,不过人家是在同一个程序集的,如果你要用的话,需要做一些变通。
killer_liqiao 2008-12-17
  • 打赏
  • 举报
回复
up
周公 2008-12-17
  • 打赏
  • 举报
回复
在WinForm里你经常用,可能却没有留意,里面就有很多类似于下面的代码:

//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行库版本:2.0.50727.1433
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------

namespace ImageAssistant.Properties {
using System;


/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {

private static global::System.Resources.ResourceManager resourceMan;

private static global::System.Globalization.CultureInfo resourceCulture;

[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}

/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ImageAssistant.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}

/// <summary>
/// 为使用此强类型资源类的所有资源查找
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}

internal static System.Drawing.Bitmap back {
get {
object obj = ResourceManager.GetObject("back", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap BreakpointHS {
get {
object obj = ResourceManager.GetObject("BreakpointHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap DeleteFolderHS {
get {
object obj = ResourceManager.GetObject("DeleteFolderHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap DeleteHS {
get {
object obj = ResourceManager.GetObject("DeleteHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap Edit_RedoHS {
get {
object obj = ResourceManager.GetObject("Edit_RedoHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap Edit_UndoHS {
get {
object obj = ResourceManager.GetObject("Edit_UndoHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap EditInformationHS {
get {
object obj = ResourceManager.GetObject("EditInformationHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap FINDCOMP_00 {
get {
object obj = ResourceManager.GetObject("FINDCOMP_00", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap FormRunHS {
get {
object obj = ResourceManager.GetObject("FormRunHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap fSEARCH_00 {
get {
object obj = ResourceManager.GetObject("fSEARCH_00", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Icon Gear {
get {
object obj = ResourceManager.GetObject("Gear", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}

internal static System.Drawing.Icon logo {
get {
object obj = ResourceManager.GetObject("logo", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}

internal static System.Drawing.Bitmap openfolderHS {
get {
object obj = ResourceManager.GetObject("openfolderHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap OpenSelectedItemHS {
get {
object obj = ResourceManager.GetObject("OpenSelectedItemHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap PropertiesHS {
get {
object obj = ResourceManager.GetObject("PropertiesHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap saveHS {
get {
object obj = ResourceManager.GetObject("saveHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

internal static System.Drawing.Bitmap StopHS {
get {
object obj = ResourceManager.GetObject("StopHS", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}
周公 2008-12-17
  • 打赏
  • 举报
回复
ResourceManager 类可以查找区域性特定的资源,当本地化资源不存在时提供代用资源,并支持资源序列化。

通过 ResourceManager 的方法,调用方可使用 GetObject 和 GetString 两种方法访问特定区域性的资源。默认情况下,这些方法返回某区域性的资源,该区域性由执行调用的线程的当前区域性设置决定。(有关更多信息,请参见 Thread.CurrentUICulture。)调用方可使用 ResourceManager.GetResourceSet 方法获取表示特定区域性的资源的 ResourceSet,并忽略区域性代用规则。然后可以使用 ResourceSet 来按名称访问为该区域性本地化的资源。

理想情况下,应该为每种语言创建资源,或者至少为每种语言的有意义子集创建资源。资源文件名遵循“基名称.区域性名称.resources”的命名约定,其中基名称是应用程序名或类名(取决于期望的详细程度)。CultureInfo 的 Name 属性用来确定区域性名称。非特定语言区域性的资源(由 InvariantCulture 返回)应该命名为“基名称.resources”。

例如,假定某个程序集在基名称为 "MyResources" 的资源文件中有几个资源。这些资源文件的名称将为 "MyResources.ja-JP.resources"、"MyResources.de.resources"、"MyResources.zh-CHS.resources" 或 "MyResources.fr-BE.resources" 等,它们分别包含用于日语、德语、简体中文和法语(比利时)的资源。默认资源文件应该命名为 MyResources.resources。区域性特定的资源文件通常打包在每种区域性的附属程序集内。默认资源文件应该在主程序集内。

现在假定已创建 ResourceManager 来表示具有此基名称的资源。通过使用 ResourceManager,可以调用 GetResourceSet(new CultureInfo ("ja-JP"), TRUE, FALSE),从而获取封装 "MyResources.ja-JP.resources" 的 ResourceSet。或者,如果已知 "MyResources" 包含名为 "TOOLBAR_ICON" 的资源,则可通过调用 GetObject("TOOLBAR_ICON", new CultureInfo("ja-JP")),获取针对日本进行了本地化的资源的值。
Zoezs 2008-12-17
  • 打赏
  • 举报
回复
DLL编译好了,就可以直接调用啊。
chinaicm 2008-12-17
  • 打赏
  • 举报
回复
文不对题?
请问你看了吗?
Dic4000 2008-12-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 chinaicm 的回复:]
http://www.cnblogs.com/lsjwzh/archive/2007/12/22/1011050.html

关于PublicKeyToken的讲解,对你应该有帮助的.
[/Quote]

文不对题
chinaicm 2008-12-17
  • 打赏
  • 举报
回复
http://www.cnblogs.com/lsjwzh/archive/2007/12/22/1011050.html

关于PublicKeyToken的讲解,对你应该有帮助的.

110,546

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧