U P G R A Y E D D
Posts
-
To exit applicationwas pressed, or because the login process completed and it's time to move onto different things, without exiting the application. -
Problems getting method called correctlyYou are using the variables firstNum and secondNum, and have not assigned them a value. Local variables must have a value assigned to them before they can be used. You said something receives two numbers and parses them into ints, I can only assume it looks like this:
Int32.Parse(strFirstNumber); Int32.Parse(strSecondNumber);
Well, when you do that you must not be storing those values into either firstNum or secondNum. So after declaring firstNum and secondNum, aka "int firstNum, secondNum;" you need to say something like:firstNum = Int32.Parse(strFirstNumber); secondNum = Int32.Parse(strSecondNumber);
Then call:DetermineNumberSum(firstNum, secondNum);
-
Emit private field get/set (FieldAccessException) [modified]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) }; ConstructorInfo ci = typeof(ReflectionPermissionAttribute).GetConstructor(ctorParams); PropertyInfo pi = typeof(ReflectionPermissionAttribute).GetProperty("Unrestricted"); CustomAttributeBuilder cab = new CustomAttributeBuilder(ci, new object[] { SecurityAction.Assert }, new PropertyInfo[] { pi }, new object[] { true }); 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.