Last post Jul 21, 2017 08:58 AM by PatriceSc
Jul 12, 2017 08:11 PM|GADOI2|LINK
I have several dlls
One handles ErrorHandling
I could pass to the ErrorHandling.dll System.Reflection.MethodBase.GetCurrentMethod.Name AND GetExecutingAssembly().GetName().Name
from any of the other dll's methods that are erroring... but that makes for a couple of extra lines I would like to avoid...
I would prefer to Get that information inside ErrorHandling.dll
something like GetCallingAssembly or looking at System.Diagnostics.StackTrace....
Jul 12, 2017 08:37 PM|A2H|LINK
looking at System.Diagnostics.StackTrace....
You can try with the below code
var callerAssemblies = new StackTrace().GetFrames()
.Select(x => x.GetMethod().ReflectedType.Assembly).Distinct()
.Where(x => x.GetReferencedAssemblies().Any(y => y.FullName == Assembly.GetExecutingAssembly().FullName));
Make sure you have added references to the below 3 dlls in your project
Jul 12, 2017 08:39 PM|GADOI2|LINK
Thanks - I will try...
Jul 13, 2017 11:44 AM|GADOI2|LINK
i get the following error:
: 'System.Data.Index' is not accessible in this
context because it is 'Friend'.
This is the code in VB:
y.FullName = Assembly.GetExecutingAssembly().FullName))
The code is in a dll called by another dll called by an asp.net web page.
I need to read-up on Link (I know nothing about it...) (yet another language to learn....:-()
Jul 21, 2017 08:35 AM|Cathy Zou|LINK
Are you want to get dll method from another ddl
Try to use the following code:
Assembly SampleAssembly = Assembly.LoadFrom(filename);
Type myType = SampleAssembly.GetTypes();
MethodInfo Method = myType.GetMethod("myVoid");
object myInstance = Activator.CreateInstance(myType);
Related links for your reference:
Jul 21, 2017 08:58 AM|PatriceSc|LINK
You don't get an Exception for which you have a call stack? Maybe also something such as https://msdn.microsoft.com/en-us/library/hh534540(v=vs.110).aspx
Make sure you do add some value. I don't remember to have problems at finding the DLL once I know about an error as you have the full namespace information etc...