Click here to Skip to main content
16,004,882 members
Home / Discussions / C#
   

C#

 
GeneralRe: Printing using LPT Pin
Christian Graus18-Feb-07 20:33
protectorChristian Graus18-Feb-07 20:33 
GeneralRe: Printing using LPT Pin
sianatia18-Feb-07 21:56
sianatia18-Feb-07 21:56 
QuestionHTML in a DataGridView Pin
Darkness8418-Feb-07 17:12
Darkness8418-Feb-07 17:12 
AnswerRe: HTML in a DataGridView Pin
Judah Gabriel Himango19-Feb-07 15:40
sponsorJudah Gabriel Himango19-Feb-07 15:40 
Questionvalidation and htmls (.cs) and javascript Pin
kalyan_241618-Feb-07 17:11
kalyan_241618-Feb-07 17:11 
AnswerRe: validation and htmls (.cs) and javascript Pin
Christian Graus18-Feb-07 17:43
protectorChristian Graus18-Feb-07 17:43 
QuestionFrom Raw USB to Disk Pin
Simplexity18-Feb-07 15:49
Simplexity18-Feb-07 15:49 
QuestionEmit private field get/set (FieldAccessException) [modified] Pin
U-P-G-R-A-Y-E-D-D18-Feb-07 13:30
U-P-G-R-A-Y-E-D-D18-Feb-07 13:30 
I'm working on a serializer and I've run into an issue with private field access. When I emit and run the IL code to access the private field of a class, it results in a FieldAccessException. I've gone looking for information on this but found very little. One of the suggestions was that the class I emit, that has the code that accesses the private fields must be have a special permissions attribute.

So I added the following to my type builder for the class:

Type[] ctorParams = new Type[] { typeof(SecurityAction) };<br />
<br />
ConstructorInfo ci = typeof(ReflectionPermissionAttribute).GetConstructor(ctorParams);<br />
PropertyInfo pi = typeof(ReflectionPermissionAttribute).GetProperty("Unrestricted");<br />
            <br />
CustomAttributeBuilder cab = new CustomAttributeBuilder(ci, new object[] { SecurityAction.Assert }, new PropertyInfo[] { pi }, new object[] { true });<br />
<br />
typeBuilder.SetCustomAttribute(cab);


However, this still results in the same FieldAccessException. Does anyone have any experience with private field access via the ILGenerator, and could shed some light on this for me, I would be very happy.

I've also tried:

typeBuilder.AddDeclarativeSecurity(SecurityAction.Demand, new PermissionSet(PermissionState.Unrestricted));

With the same result.
QuestionBiggest .NET open source project? Pin
cebyrjoe218-Feb-07 13:28
cebyrjoe218-Feb-07 13:28 
AnswerRe: Biggest .NET open source project? Pin
Thomas Stockwell19-Feb-07 6:44
professionalThomas Stockwell19-Feb-07 6:44 
QuestionHow do I change a control's content through the Controls collection? Pin
David Fleming18-Feb-07 11:07
David Fleming18-Feb-07 11:07 
AnswerRe: How do I change a control's content through the Controls collection? Pin
Christian Graus18-Feb-07 11:10
protectorChristian Graus18-Feb-07 11:10 
GeneralRe: How do I change a control's content through the Controls collection? Pin
David Fleming18-Feb-07 14:20
David Fleming18-Feb-07 14:20 
QuestionOverlay Pin
Scalee18-Feb-07 9:53
Scalee18-Feb-07 9:53 
QuestionJust a thought...why is my application taking so much RAM? Pin
sharpiesharpie18-Feb-07 8:25
sharpiesharpie18-Feb-07 8:25 
AnswerRe: Just a thought...why is my application taking so much RAM? Pin
Pete O'Hanlon18-Feb-07 8:30
mvePete O'Hanlon18-Feb-07 8:30 
AnswerRe: Just a thought...why is my application taking so much RAM? Pin
Judah Gabriel Himango18-Feb-07 8:44
sponsorJudah Gabriel Himango18-Feb-07 8:44 
GeneralRe: Just a thought...why is my application taking so much RAM? Pin
sharpiesharpie18-Feb-07 9:03
sharpiesharpie18-Feb-07 9:03 
GeneralRe: Just a thought...why is my application taking so much RAM? Pin
Judah Gabriel Himango18-Feb-07 9:26
sponsorJudah Gabriel Himango18-Feb-07 9:26 
GeneralRe: Just a thought...why is my application taking so much RAM? Pin
Christian Graus18-Feb-07 11:09
protectorChristian Graus18-Feb-07 11:09 
AnswerRe: Just a thought...why is my application taking so much RAM? Pin
Christian Graus18-Feb-07 9:17
protectorChristian Graus18-Feb-07 9:17 
GeneralRe: Just a thought...why is my application taking so much RAM? Pin
sharpiesharpie18-Feb-07 9:24
sharpiesharpie18-Feb-07 9:24 
GeneralRe: Just a thought...why is my application taking so much RAM? Pin
Christian Graus18-Feb-07 9:58
protectorChristian Graus18-Feb-07 9:58 
GeneralRe: Just a thought...why is my application taking so much RAM? Pin
Dave Kreskowiak18-Feb-07 12:02
mveDave Kreskowiak18-Feb-07 12:02 
AnswerRe: Just a thought...why is my application taking so much RAM? Pin
Scott Dorman18-Feb-07 13:53
professionalScott Dorman18-Feb-07 13:53 

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.