search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
.NET Framework GroupsView
Deployment Server
.NET Distributed_Apps
.NET
.NET ADO.NET
.NET ASP.NET
.NET ASP.NET Security
.NET ASP.NET Webcontrols
.NET ASP.NET Web Services
.NET Clr
.NET Compact Framework
.NET Drawing
.NET Interop
.NET Micro Porting
.NET Performance
.NET Web Services
.NET Windows Forms
.NET Windows Forms Controls
.NET General
.NET Csharp
.NET Visual Basic
.NET Vc
.NET Security
.NET Xml
Scripting Jscript
Scripting Visual Basicscript
Scripting Wsh
Smartphone Developer
Visual Basic Com
Visual Basic Controls
Visual Basic Crystal
Visual Basic Database Ado
Visual Basic Syntax
Visual Basic Vista Compatibility
Visual Basic Winapi
Vc Atl
Vc Debugger
Vc Language
Vc Mfc
Vc Stl
Visio Developer Visual Basica
Vsnet Debugging
Windows Powershell
Windowsce Embedded Vc
Xml
Xsl

Group SummariesView
.NET Framework
Access
BizTalk
Certifications
CRM
DDK
Exchange Server
FoxPro
French
French .NET
Games
German
German .NET
Graphic Design
IIS
Internet
ISA Server
Italian
Italian .NET
Maps
MCIS
Miscellaneous
Mobile Application Development
Money
MSN
Networking
Office
Ops Mgr
Publisher
Security
SharePoint
Small Business
Spanish
Spanish .NET
SQL Server
Systems Management Server
Transaction Server
Virtual PC / Virtual Server
Visual Studio
Win32
Windows 2000
Windows 2003 Server
Windows 7
Windows Live
Windows Media
Windows Update
Windows Vista
Windows XP
 

View All Microsoft NET Csharp Posts  Ask A New Question 

What does it mean with Module when using AttributeUsage - Tony Johansson

Wednesday, October 08, 2008 2:15 PM

Hello!

You can set target Module for AttributeUsage.

I just wonder what does it mean with module ?

//Tony
reply
 

Your assembly. - Peter Morris

Wednesday, October 08, 2008 2:43 PM

Your assembly.  For example create a WinForm app and look in
Properties\AssemblyInfo.cs

[assembly: AssemblyTitle("AccommodationManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AccommodationManager")]
[assembly: AssemblyCopyright("Copyright ©  2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

I often use this with plugins

[assembly: ReportProducerLibrary]

then on my classes

[ReportProducer]


This way when I am looking for plugins in assemblies I know not to bother
iterating all the types in the assembly if the assembly isn't tagged as a
ReportProducerLibrary.




--
Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com
reply

Hello! - Tony Johansson

Wednesday, October 08, 2008 3:01 PM

Hello!

Did you answer what Module menas. I cannot find any
understandable answer about this Module.

Can you perhaps explain in another way?

//Tony
reply

What does it mean with Module when using AttributeUsage - Peter Morris

Thursday, October 09, 2008 3:54 AM

For some reason I read as "Assembly".  This is what a module is:
http://bytes.com/forum/thread250595.html

From my memory of reading Richter's book on .NET 1.1 some years ago you can
make an assembly up from multiple modules, however, the C# compiler creates
only a single module per assembly.  I suspect VB.net lets you create modules
within an assembly, but I don't touch that language and it's purely a guess.
Anyway, the following code illustrates that defining an attribute on a
module in C# applies it to all classes within the assembly...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Linq;
using System.Reflection;

namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var classes =
from c in typeof(Form1).Assembly.GetTypes()
where c.Module.GetCustomAttributes(typeof(MyModuleAttribute),
true).Length > 0
select c;

foreach (Type c in classes)
System.Diagnostics.Debug.WriteLine("Defined on: " + c.Name);
}
}
}



using System;
using System.Collections.Generic;
using System.Text;

namespace WindowsFormsApplication3.CompanyStuff
{
class Company
{
}
}



using System;
using System.Collections.Generic;
using System.Text;

[module: WindowsFormsApplication3.MyModule]
namespace WindowsFormsApplication3.PersonStuff
{
class Person
{
}
}



using System;
using System.Collections.Generic;
using System.Text;

namespace WindowsFormsApplication3
{
[AttributeUsage(AttributeTargets.Module)]
public class MyModuleAttribute : Attribute
{
}
}





--
Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com
reply

Previous Microsoft NET Csharp conversation.