Answered by:
Inheritance security rules violated while overriding member

Question
-
User1052662409 posted
Hi All,
I got the titled error when I try to upload files on server (Although it works fine when I try to upload those files through my local machine.)
I got an solution here https://stackoverflow.com/questions/3055792/inheritance-security-rules-violated-while-overriding-member-securityruleset-le
But how to Mark
GetObjectData
withSecurityCriticalAttribute?
I nee the implementation.
Please suggest.
Tuesday, June 25, 2019 7:12 PM
Answers
-
User1052662409 posted
Sorry I forgot to update on the post.
Yes it worked for me
[SecurityCritical] public class UploadFiles { ... }
But one more thing I did. I gave the full trust permission to my domain where my application is hosted.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 28, 2019 6:48 AM
All replies
-
User475983607 posted
demoninside9
Hi All,
I got the titled error when I try to upload files on server (Although it works fine when I try to upload those files through my local machine.)
I got an solution here https://stackoverflow.com/questions/3055792/inheritance-security-rules-violated-while-overriding-member-securityruleset-le
But how to Mark
GetObjectData
withSecurityCriticalAttribute?
I nee the implementation.
Please suggest.
Can you clarify? You're overriding GetObjectData? Share the code that reproduces the issue and explain the expected results as there might be a better solution.
Tuesday, June 25, 2019 7:48 PM -
User1052662409 posted
mgebhard
Can you clarify? You're overriding GetObjectData? Share the code that reproduces the issue and explain the expected results as there might be a better solution.I am trying to upload/download files, which I can upload easily with my local machine without any issue. (When I run my application in visual studio).
Below is my class to uploal
public class UploadFiles { public bool sendMyFileToS3(string bucketName, string keyName, string filePath) { try { var client = new AmazonS3Client(RegionEndpoint.APSouth1); PutObjectRequest putRequest = new PutObjectRequest { BucketName = bucketName, Key = keyName, FilePath = filePath, ContentType = "text/plain" }; PutObjectResponse response = client.PutObject(putRequest); } catch (AmazonS3Exception amazonS3Exception) { if (amazonS3Exception.ErrorCode != null && (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") || amazonS3Exception.ErrorCode.Equals("InvalidSecurity"))) { WebMsgBox.Show("Check the provided AWS Credentials."); } else { WebMsgBox.Show("Error occurred: " + amazonS3Exception.Message); } } return true; //indicate that the file was sent } }
And the below code I am using to implement my upload class.
if (FileUpload1.HasFile) { FileUpload1.SaveAs(Server.MapPath("DPRExpenseDocs/" + filename)); supporting_docs = "DPRExpenseDocs/" + filename; string bucketname = "XXXXXXXXX"; string path = Server.MapPath("DPRExpenseDocs/" + filename); UploadFiles obj = new UploadFiles(); bool uploaded; uploaded = obj.sendMyFileToS3(bucketname, filename, path); if (uploaded) { WebMsgBox.Show("uploaded"); } else { WebMsgBox.Show("Server error"); } }
But it shows error
Inheritance security rules violated while overriding member: MyBusinessException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
Please suggest.
Wednesday, June 26, 2019 3:12 AM -
User839733648 posted
Hi demoninside9,
But it shows error
Inheritance security rules violated while overriding member: MyBusinessException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
According to your description, I'd like to ask that which row does this error happen?
I got an solution here https://stackoverflow.com/questions/3055792/inheritance-security-rules-violated-while-overriding-member-securityruleset-le
But how to Mark GetObjectData with SecurityCriticalAttribute?
From the solution link you shared, the way of dealing with the issue is to add [SecurityCritical] before your method declaration.
The SecurityCriticalAttribute is equivalent to a link demand for full trust.
A type or member marked with the SecurityCriticalAttribute can be called only by fully trusted code; it does not have to demand specific permissions.
It cannot be called by partially trusted code.
You maybe write like:
[SecurityCritical] public class UploadFiles { ... }
Best Regards,
Jenifer
Wednesday, June 26, 2019 7:37 AM -
User1052662409 posted
[SecurityCritical] public class UploadFiles { ... }
I tried but not working. Same result
Inheritance security rules violated while overriding member: 'Amazon.S3.AmazonS3Exception.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
Wednesday, June 26, 2019 12:26 PM -
User839733648 posted
Hi demoninside9,
Inheritance security rules violated while overriding member: 'Amazon.S3.AmazonS3Exception.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.From the message, I think that the issue is related to the AmazonS3.
AmazonS3 is provided by Amazon and I'm not able to use that SDK to reproduce your issue.
I suggest that you could go to the official AWS Developer Community to ask for help: https://forums.aws.amazon.com/forum.jspa?forumID=61
Best Regards,
Jenifer
Friday, June 28, 2019 6:28 AM -
User1052662409 posted
Sorry I forgot to update on the post.
Yes it worked for me
[SecurityCritical] public class UploadFiles { ... }
But one more thing I did. I gave the full trust permission to my domain where my application is hosted.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 28, 2019 6:48 AM