Click here to Skip to main content
15,749,185 members
Home / Discussions / C#
   

C#

 
GeneralRe: Cash for Help! Pin
J4amieC6-Sep-07 12:17
J4amieC6-Sep-07 12:17 
QuestionWeb Service returning DateTime one hour out Pin
funkymint6-Sep-07 1:08
funkymint6-Sep-07 1:08 
QuestionReally simple question on Drop Down List Boxes Pin
Infernojericho6-Sep-07 0:42
Infernojericho6-Sep-07 0:42 
AnswerRe: Really simple question on Drop Down List Boxes Pin
Sandeep Akhare6-Sep-07 0:54
Sandeep Akhare6-Sep-07 0:54 
GeneralRe: Really simple question on Drop Down List Boxes Pin
Infernojericho6-Sep-07 1:03
Infernojericho6-Sep-07 1:03 
GeneralRe: Really simple question on Drop Down List Boxes Pin
Sandeep Akhare6-Sep-07 1:25
Sandeep Akhare6-Sep-07 1:25 
QuestionDynamically create a delegate signature Pin
Leonardo Pelisoli6-Sep-07 0:42
Leonardo Pelisoli6-Sep-07 0:42 
AnswerRe: Dynamically create a delegate signature Pin
TJoe6-Sep-07 8:55
TJoe6-Sep-07 8:55 
The code below should do what you want, but I have not tested it. The core code comes from here[^].

<br />
AssemblyName assembly = new AssemblyName();<br />
assembly.Version = new Version(1, 0, 0, 0);<br />
assembly.Name = "ReflectionEmitDelegateTest";<br />
<br />
AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assembly,<br />
    AssemblyBuilderAccess.Run);<br />
<br />
ModuleBuilder modbuilder = assemblyBuilder.DefineDynamicModule("MyModule", true);<br />
<br />
TypeBuilder typeBuilder = modbuilder.DefineType("MyDelegateType",<br />
    TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed |<br />
    TypeAttributes.AnsiClass | TypeAttributes.AutoClass,<br />
    typeof(MulticastDelegate));<br />
<br />
ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.RTSpecialName |<br />
    MethodAttributes.HideBySig | MethodAttributes.Public,<br />
    CallingConventions.Standard,<br />
    new Type[] { typeof(object), typeof(System.IntPtr) });<br />
constructorBuilder.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);<br />
<br />
// Build the parameters<br />
Type[] paramTypes = new Type[2];<br />
paramTypes[0] = typeof(Int32);<br />
paramTypes[1] = typeof(String);<br />
<br />
// Define the Invoke method for the delegate<br />
MethodBuilder methodBuilder = typeBuilder.DefineMethod("Invoke",<br />
    MethodAttributes.Public | MethodAttributes.HideBySig |<br />
    MethodAttributes.NewSlot | MethodAttributes.Virtual,<br />
    typeof(Int32),<br />
    paramTypes);<br />
methodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed);<br />
<br />
// Get the type<br />
Type type = typeBuilder.CreateType();<br />
<br />
// Create an instance<br />
Delegate del = Marshal.GetDelegateForFunctionPointer(pfn, type);<br />
del.DynamicInvoke(1, "2");<br />


Take care,
Tom

-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com

GeneralRe: Dynamically create a delegate signature Pin
Leonardo Pelisoli6-Sep-07 22:23
Leonardo Pelisoli6-Sep-07 22:23 
QuestionUPnP InvokeAction Pin
MicealG6-Sep-07 0:27
MicealG6-Sep-07 0:27 
Questioncompare MS Word Documents Pin
Nitin.raj6-Sep-07 0:05
Nitin.raj6-Sep-07 0:05 
AnswerRe: compare MS Word Documents Pin
originSH6-Sep-07 0:08
originSH6-Sep-07 0:08 
GeneralRe: compare MS Word Documents Pin
Nitin.raj6-Sep-07 0:11
Nitin.raj6-Sep-07 0:11 
GeneralRe: compare MS Word Documents Pin
originSH6-Sep-07 0:22
originSH6-Sep-07 0:22 
GeneralRe: compare MS Word Documents Pin
mav.northwind6-Sep-07 0:26
mav.northwind6-Sep-07 0:26 
QuestionMethod to set time Pin
iet20005-Sep-07 23:59
iet20005-Sep-07 23:59 
AnswerRe: Method to set time Pin
Vikram A Punathambekar6-Sep-07 0:14
Vikram A Punathambekar6-Sep-07 0:14 
GeneralRe: Method to set time Pin
iet20006-Sep-07 1:19
iet20006-Sep-07 1:19 
QuestionCompare Word docs Pin
Nitin.raj5-Sep-07 23:53
Nitin.raj5-Sep-07 23:53 
AnswerRe: Compare Word docs Pin
originSH6-Sep-07 0:05
originSH6-Sep-07 0:05 
Questioncrystal report export problem Pin
sakthi dasan5-Sep-07 23:38
sakthi dasan5-Sep-07 23:38 
QuestionLicencing Problem urgent Pin
Nishad855-Sep-07 23:34
Nishad855-Sep-07 23:34 
AnswerRe: Licencing Problem urgent Pin
MicealG6-Sep-07 1:27
MicealG6-Sep-07 1:27 
QuestionString.IsNullOrEmpty Pin
nasambur5-Sep-07 23:31
nasambur5-Sep-07 23:31 
AnswerRe: String.IsNullOrEmpty Pin
originSH5-Sep-07 23:49
originSH5-Sep-07 23:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.