I have a dll that I am trying to create an instance of but is saying the protection level is high. I've read that I can use reflection to create this instance. Anyone know the proper syntax for doing this?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Oct 30, 2014, 5:54 AM EDT
First create this simple dll, marc_test.dll :
// marc_test.cs
Now create the following executable which loads the dll at runtime (place the dll in the same folder as the executable to facilitate this):
The output,as expected, is:
Notice a couple of points here:
1. Although MyClass2 is internal to the dll, we are still able to create an instance of it.
2. Also, even though MyClass2.MyMethod2 is an internal method, we can still call it just by changing the BindingFlags variable to include BindingFlags.NonPublic rather than BindingFlags.Public.